* [ECOS] How to umount() or FSSYNC "/" with setinfo() and FS_INFO_SYNC?
@ 2015-07-23 17:37 E H
0 siblings, 0 replies; only message in thread
From: E H @ 2015-07-23 17:37 UTC (permalink / raw)
To: ecos-discuss
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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-07-23 17:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-23 17:37 [ECOS] How to umount() or FSSYNC "/" with setinfo() and FS_INFO_SYNC? E H
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).