Whamcloud - gitweb
*** empty log message ***
[fs/lustre-release.git] / libsysio / src / file_hack.c
index 524fb55..2eb6105 100644 (file)
@@ -46,6 +46,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <sys/queue.h>
 
 #include "sysio.h"
@@ -105,6 +106,7 @@ _sysio_fnew(struct inode *ino, int flags)
                return NULL;
 
        _SYSIO_FINIT(fil, ino, flags);
+       F_REF(fil);
        I_REF(ino);
 
        return fil;
@@ -121,6 +123,7 @@ _sysio_fgone(struct file *fil)
        assert(!fil->f_ref);
        assert(fil->f_ino);
        err = (*fil->f_ino->i_ops.inop_close)(fil->f_ino);
+       I_RELE(fil->f_ino);
        assert(!err);
        free(fil);
 }
@@ -185,7 +188,7 @@ fd_grow(oftab_t *oftab, size_t n)
        return 0;
 }
 
-#if ZERO_SUM_MEMORY
+#ifdef ZERO_SUM_MEMORY
 static void free_oftab(oftab_t *ot)
 {
        if (ot->table) {
@@ -360,8 +363,8 @@ _sysio_fd_dup(int oldfd, int newfd, int force)
 
        init_oftab();
 
-       if (oldfd == newfd)
-               return 0;
+       if (oldfd == newfd && oldfd >= 0)
+               return newfd;
 
        fil = _sysio_fd_find(oldfd);
        if (!fil)