Whamcloud - gitweb
LU-864 test: Hostname name doesn't equal NID and use facet_mntpt
[fs/lustre-release.git] / libsysio / src / inode.c
index 0fa2cd0..fbe027d 100644 (file)
@@ -9,7 +9,7 @@
  *    terms of the GNU Lesser General Public License
  *    (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html)
  *
- *    Cplant(TM) Copyright 1998-2003 Sandia Corporation. 
+ *    Cplant(TM) Copyright 1998-2006 Sandia Corporation. 
  *    Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
  *    license for use of this work by or on behalf of the US Government.
  *    Export of this program may require a license from the United States
@@ -101,7 +101,7 @@ static size_t max_names = (2 * NAMES_TABLE_LEN);
  */
 #define PNODES_PER_CHUNK ((8 * 1024) / sizeof(struct pnode) - 2)
 
-#if ZERO_SUM_MEMORY
+#ifdef ZERO_SUM_MEMORY
 /*
  * Allocation information for pnodes bulk allocation.
  */
@@ -142,7 +142,7 @@ _sysio_i_init()
        for (i = 0; i < NAMES_TABLE_LEN; i++)
                LIST_INIT(&names[i]);
 
-#if ZERO_SUM_MEMORY
+#ifdef ZERO_SUM_MEMORY
        LIST_INIT(&pnblocks);
 #endif
        TAILQ_INIT(&_sysio_pnodes);
@@ -218,8 +218,7 @@ hash(struct file_identifier *fid)
 struct inode *
 _sysio_i_new(struct filesys *fs,
             struct file_identifier *fid,
-            mode_t type,
-            dev_t rdev,
+            struct intnl_stat *stat,
             unsigned immunity,
             struct inode_ops *ops,
             void *private)
@@ -240,24 +239,27 @@ _sysio_i_new(struct filesys *fs,
                return NULL;
        ino->i_ops = *ops;
        operations = *ops;
-       if (S_ISBLK(type) || S_ISCHR(type) || S_ISFIFO(type)) {
+       if (S_ISBLK(stat->st_mode) ||
+           S_ISCHR(stat->st_mode) ||
+           S_ISFIFO(stat->st_mode)) {
                struct inode_ops *o;
 
                /*
                 * Replace some operations sent with
                 * those from the device table.
                 */
-               o = _sysio_dev_lookup(type, rdev);
+               o = _sysio_dev_lookup(stat->st_mode, stat->st_rdev);
                operations.inop_open = o->inop_open;
                operations.inop_close = o->inop_close;
                operations.inop_read = o->inop_read;
                operations.inop_write = o->inop_write;
                operations.inop_pos = o->inop_pos;
                operations.inop_iodone = o->inop_iodone;
+               operations.inop_fcntl = o->inop_fcntl;
                operations.inop_datasync = o->inop_datasync;
                operations.inop_ioctl = o->inop_ioctl;
        }
-       I_INIT(ino, fs, type, rdev, &operations, fid, immunity, private);
+       I_INIT(ino, fs, stat, &operations, fid, immunity, private);
        ino->i_ref = 1;
        TAILQ_INSERT_TAIL(&_sysio_inodes, ino, i_nodes);
        head = &fs->fs_itbl[hash(fid) % FS_ITBLSIZ];
@@ -321,6 +323,8 @@ void
 _sysio_i_undead(struct inode *ino)
 {
        
+       if (ino->i_zombie)
+               return;
        LIST_REMOVE(ino, i_link);
        ino->i_zombie = 1;
 }
@@ -461,12 +465,12 @@ static void
 more_pnodes()
 {
        size_t  n;
-#if ZERO_SUM_MEMORY
+#ifdef ZERO_SUM_MEMORY
        struct pnodes_block *pnblk;
 #endif
        struct pnode *pno;
 
-#if ZERO_SUM_MEMORY
+#ifdef ZERO_SUM_MEMORY
        pnblk = malloc(sizeof(struct pnodes_block));
        pno = NULL;
        if (pnblk) {
@@ -485,7 +489,7 @@ more_pnodes()
        } while (--n);
 }
 
-#if ZERO_SUM_MEMORY
+#ifdef ZERO_SUM_MEMORY
 /*
  * Shutdown
  */
@@ -865,15 +869,23 @@ _sysio_setattr(struct pnode *pno,
               unsigned mask,
               struct intnl_stat *stbuf)
 {
-       /* It is possible that pno is null (for ftruncate call). */
+       /*
+        * It is possible that pno is null (for ftruncate call).
+        */
 
-       if (pno) {
-       assert(!(pno->p_base->pb_ino && ino) || pno->p_base->pb_ino == ino);
-       if (IS_RDONLY(pno, ino))
-               return -EROFS;
-       }
-       if (!ino && pno->p_base->pb_ino)
+       if (pno)
+               assert(!ino || pno->p_base->pb_ino == ino);
+       if (!ino)
                ino = pno->p_base->pb_ino;
+       assert(ino);
+
+       if (pno && IS_RDONLY(pno))
+               return -EROFS;
+
+       /*
+        * Determining permission to change the attributes is
+        * difficult, at best. Just try it.
+        */
        return (*ino->i_ops.inop_setattr)(pno, ino, mask, stbuf);
 }