From bed55af1ee98b386de9060b6b65e7aa7c9bf1428 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 14 Aug 2003 20:00:46 +0000 Subject: 2003-08-14 Joel Sherrill * Makefile.am: Add fileio to list of interactive tests. * src/sync.c: New file. --- cpukit/libcsupport/ChangeLog | 5 +++ cpukit/libcsupport/Makefile.am | 2 +- cpukit/libcsupport/src/sync.c | 69 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 cpukit/libcsupport/src/sync.c (limited to 'cpukit') 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 + + * Makefile.am: Add fileio to list of interactive tests. + * src/sync.c: New file. + 2003-08-05 Till Strauman 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 +#include + +#include +/* +#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ + +#include +#include +*/ + +/* 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; +} -- cgit v1.2.3