diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2003-08-14 20:00:46 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2003-08-14 20:00:46 +0000 |
commit | bed55af1ee98b386de9060b6b65e7aa7c9bf1428 (patch) | |
tree | bc84edbca4fedebe56882021ef767e2f7b8e7ca6 /cpukit/libcsupport | |
parent | 2003-08-14 Joel Sherrill <joel@OARcorp.com> (diff) | |
download | rtems-bed55af1ee98b386de9060b6b65e7aa7c9bf1428.tar.bz2 |
2003-08-14 Joel Sherrill <joel@OARcorp.com>
* Makefile.am: Add fileio to list of interactive tests.
* src/sync.c: New file.
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r-- | cpukit/libcsupport/ChangeLog | 5 | ||||
-rw-r--r-- | cpukit/libcsupport/Makefile.am | 2 | ||||
-rw-r--r-- | cpukit/libcsupport/src/sync.c | 69 |
3 files changed, 75 insertions, 1 deletions
diff --git a/cpukit/libcsupport/ChangeLog b/cpukit/libcsupport/ChangeLog index 401f13b3dd..a520d4c332 100644 --- a/cpukit/libcsupport/ChangeLog +++ b/cpukit/libcsupport/ChangeLog @@ -1,3 +1,8 @@ +2003-08-14 Joel Sherrill <joel@OARcorp.com> + + * Makefile.am: Add fileio to list of interactive tests. + * src/sync.c: New file. + 2003-08-05 Till Strauman <strauman@slac.stanford.edu> PR 442/filesystem diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am index 41497338ad..d420513fd9 100644 --- a/cpukit/libcsupport/Makefile.am +++ b/cpukit/libcsupport/Makefile.am @@ -117,7 +117,7 @@ SYSTEM_CALL_C_FILES = src/open.c src/close.c src/read.c src/write.c \ src/unlink.c src/umask.c src/ftruncate.c src/utime.c src/fstat.c \ src/fcntl.c src/fpathconf.c src/getdents.c src/fsync.c src/fdatasync.c \ src/pipe.c src/dup.c src/dup2.c src/symlink.c src/readlink.c src/creat.c \ - src/chroot.c + src/chroot.c src/sync.c DIRECTORY_SCAN_C_FILES = src/opendir.c src/closedir.c src/readdir.c \ src/readdir_r.c src/rewinddir.c src/scandir.c src/seekdir.c \ diff --git a/cpukit/libcsupport/src/sync.c b/cpukit/libcsupport/src/sync.c new file mode 100644 index 0000000000..f91dfd52e7 --- /dev/null +++ b/cpukit/libcsupport/src/sync.c @@ -0,0 +1,69 @@ +/* + * sync() - XXX ??? where is this defined + * + * This function operates by as follows: + * for all threads + * for all FILE * + * fsync() + * fdatasync() + * + * COPYRIGHT (c) 1989-2003. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +/* this is needed to get the fileno() prototype */ +#if defined(__STRICT_ANSI__) +#undef __STRICT_ANSI__ +#endif +#include <unistd.h> +#include <stdio.h> + +#include <rtems.h> +/* +#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ + +#include <rtems/libio_.h> +#include <rtems/seterr.h> +*/ + +/* XXX check standards -- Linux version appears to be void */ +void _fwalk(struct _reent *, void *); + +static void sync_wrapper(FILE *f) +{ + int fn = fileno(f); + + fsync(fn); + fdatasync(fn); +} + +/* iterate over all FILE *'s for this thread */ +static void sync_per_thread(Thread_Control *t) +{ + struct reent *current_reent; + + /* + * The sync_wrapper() function will operate on the current thread's + * reent structure so we will temporarily use that. + */ + current_reent = _Thread_Executing->libc_reent; + _Thread_Executing->libc_reent = t->libc_reent; + _fwalk (t->libc_reent, sync_wrapper); + _Thread_Executing->libc_reent = current_reent; +} + +int sync(void) +{ + rtems_iterate_over_all_threads(sync_per_thread); + return 0; +} |