From: E H <etan61184@live.com>
To: "ecos-discuss@ecos.sourceware.org" <ecos-discuss@ecos.sourceware.org>
Subject: [ECOS] How to umount() or FSSYNC "/" with setinfo() and FS_INFO_SYNC?
Date: Thu, 23 Jul 2015 17:37:00 -0000 [thread overview]
Message-ID: <SNT147-W46E4907F316B55E826020587820@phx.gbl> (raw)
I have the following code:
#define RAMFILE_NAME "/file.ram"
#define SHOW_RESULT( _fn, _res ) \
printf("\n<FAIL>: " #_fn "() returned %ld %s\n", \
(unsigned long)_res, _res<0?strerror(errno):"");
int createfile( char *name )
{
int fd;
int err;
err = mount( "", "/", "ramfs" );
if ( err < 0 ) { SHOW_RESULT( mount, err ); }
else { printf("\nRAMFS mounted successfully"); }
err = chdir( "/" );
if( err < 0 ) SHOW_RESULT( chdir, err );
// if a file already exists, delete it
if ( access( name, F_OK ) == 0 ) { unlink(name); }
fd = open( name, O_RDWR | O_CREAT );
if( fd < 0 ) { SHOW_RESULT( open, fd ); }
return fd;
}
int umountFilesystem()
{
int err;
err = unlink(RAMFILE_NAME);
if ( err < 0 ) fprintf(stderr,"Failed to delete \"%s\" from RAMFS.",RAMFILE_NAME);
sleep(1);
err = umount("/");
if( err < 0 ) { SHOW_RESULT( umount, err ); }
return err;
}
I have a calling function that kicks off createFile(RAMFILE_NAME), does some work with the file and then calls umountFilesystem(), which returns the following error message through the SHOW_RESULT macro:
<FAIL>: umount() returned -1 Resource busy
The reason I'm trying to un-mount the file system (or FSSYNC) after unlinking the RAM file is due to the fact that the filesystem is buffered (see: https://www.sourceware.org/ml/ecos-discuss/2006-01/msg00160.html), which presents a problem for a limited-resource, embedded system that needs to create and delete files on a somewhat frequent basis. The solution discussed in that post is apparently to, "call it using a setinfo call with a FS_INFO_SYNC operation." However, I do not know how to implement this solution. Could you provide me an example or offer some help?
Thanks.
reply other threads:[~2015-07-23 17:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=SNT147-W46E4907F316B55E826020587820@phx.gbl \
--to=etan61184@live.com \
--cc=ecos-discuss@ecos.sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).