Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpuffs Commit fix for misc/45029.



details:   https://anonhg.NetBSD.org/src/rev/2c8f176e2866
branches:  trunk
changeset: 766507:2c8f176e2866
user:      manu <manu%NetBSD.org@localhost>
date:      Fri Jun 24 16:59:29 2011 +0000

description:
Commit fix for misc/45029.
Approved by pooka@

diffstat:

 lib/libpuffs/null.c |  39 +++++++++++++++++++++++++++------------
 1 files changed, 27 insertions(+), 12 deletions(-)

diffs (65 lines):

diff -r 7b15789fe4ba -r 2c8f176e2866 lib/libpuffs/null.c
--- a/lib/libpuffs/null.c       Fri Jun 24 05:31:36 2011 +0000
+++ b/lib/libpuffs/null.c       Fri Jun 24 16:59:29 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: null.c,v 1.28 2009/10/18 20:14:06 pooka Exp $  */
+/*     $NetBSD: null.c,v 1.29 2011/06/24 16:59:29 manu Exp $   */
 
 /*
  * Copyright (c) 2007  Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: null.c,v 1.28 2009/10/18 20:14:06 pooka Exp $");
+__RCSID("$NetBSD: null.c,v 1.29 2011/06/24 16:59:29 manu Exp $");
 #endif /* !lint */
 
 /*
@@ -410,21 +410,36 @@
        struct puffs_node *pn = opc;
        int fd, rv;
        int fflags;
+       struct stat sb;
 
        rv = 0;
-       fd = writeableopen(PNPATH(pn));
-       if (fd == -1)
+       if (stat(PNPATH(pn), &sb) == -1)
                return errno;
+       if (S_ISDIR(sb.st_mode)) {
+               DIR *dirp;
+               if ((dirp = opendir(PNPATH(pn))) == 0)
+                       return errno;
+               fd = dirfd(dirp);
+               if (fd == -1)
+                       return errno;
 
-       if (how & PUFFS_FSYNC_DATAONLY)
-               fflags = FDATASYNC;
-       else
-               fflags = FFILESYNC;
-       if (how & PUFFS_FSYNC_CACHE)
-               fflags |= FDISKSYNC;
+               if (fsync(fd) == -1)
+                       rv = errno;
+       } else {
+               fd = writeableopen(PNPATH(pn));
+               if (fd == -1)
+                       return errno;
 
-       if (fsync_range(fd, fflags, offlo, offhi - offlo) == -1)
-               rv = errno;
+               if (how & PUFFS_FSYNC_DATAONLY)
+                       fflags = FDATASYNC;
+               else
+                       fflags = FFILESYNC;
+               if (how & PUFFS_FSYNC_CACHE)
+                       fflags |= FDISKSYNC;
+
+               if (fsync_range(fd, fflags, offlo, offhi - offlo) == -1)
+                       rv = errno;
+       }
 
        close(fd);
 



Home | Main Index | Thread Index | Old Index