forked from Imagelibrary/rtems
2003-08-14 Joel Sherrill <joel@OARcorp.com>
* Makefile.am: Add fileio to list of interactive tests. * src/sync.c: New file.
This commit is contained in:
@@ -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>
|
2003-08-05 Till Strauman <strauman@slac.stanford.edu>
|
||||||
|
|
||||||
PR 442/filesystem
|
PR 442/filesystem
|
||||||
|
|||||||
@@ -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/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/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/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 \
|
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 \
|
src/readdir_r.c src/rewinddir.c src/scandir.c src/seekdir.c \
|
||||||
|
|||||||
69
cpukit/libcsupport/src/sync.c
Normal file
69
cpukit/libcsupport/src/sync.c
Normal file
@@ -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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user