[Libsysio-commit] HEAD: libsysio/src fsync.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2007-11-20 17:46:31
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv31140/src Modified Files: fsync.c Log Message: Modified to leverage the new F_FILEOK macro instead of a direct test. Index: fsync.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fsync.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- fsync.c 2 Jul 2007 18:58:16 -0000 1.10 +++ fsync.c 20 Nov 2007 17:46:28 -0000 1.11 @@ -45,38 +45,49 @@ #include <errno.h> #include <sys/types.h> #include <sys/stat.h> +#include <fcntl.h> #include <sys/queue.h> #include "sysio.h" -#include "file.h" #include "inode.h" +#include "file.h" int SYSIO_INTERFACE_NAME(fsync)(int fd) { - struct file *fil; int err; + struct file *fil; SYSIO_INTERFACE_DISPLAY_BLOCK; SYSIO_INTERFACE_ENTER(fsync, "%d", fd); + err = 0; + do { fil = _sysio_fd_find(fd); - if (!(fil && fil->f_pno)) - SYSIO_INTERFACE_RETURN(-1, -EBADF, fsync, "%d", 0); + if (!F_FILEOK(fil)) + err = -EBADF; + if (err) + break; err = PNOP_SYNC(fil->f_pno); + } while (0); SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fsync, "%d", 0); } int SYSIO_INTERFACE_NAME(fdatasync)(int fd) { - struct file *fil; int err; + struct file *fil; SYSIO_INTERFACE_DISPLAY_BLOCK; SYSIO_INTERFACE_ENTER(fdatasync, "%d", fd); + err = 0; + do { fil = _sysio_fd_find(fd); - if (!(fil && fil->f_pno)) - SYSIO_INTERFACE_RETURN(-1, -EBADF, fdatasync, "%d", 0); + if (!F_FILEOK(fil)) + err = -EBADF; + if (err) + break; err = PNOP_DATASYNC(fil->f_pno); + } while (0); SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fdatasync, "%d", 0); } |