Inotify: undefined reference to `anon_inode_getfd'
[safe/jmp/linux-2.6] / fs / jfs / jfs_inode.c
index ae2772c..829921b 100644 (file)
@@ -3,16 +3,16 @@
  *
  *   This program is free software;  you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or 
+ *   the Free Software Foundation; either version 2 of the License, or
  *   (at your option) any later version.
- * 
+ *
  *   This program is distributed in the hope that it will be useful,
  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
  *   the GNU General Public License for more details.
  *
  *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software 
+ *   along with this program;  if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
@@ -45,6 +45,24 @@ void jfs_set_inode_flags(struct inode *inode)
                inode->i_flags |= S_SYNC;
 }
 
+void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
+{
+       unsigned int flags = jfs_ip->vfs_inode.i_flags;
+
+       jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
+                          JFS_DIRSYNC_FL | JFS_SYNC_FL);
+       if (flags & S_IMMUTABLE)
+               jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
+       if (flags & S_APPEND)
+               jfs_ip->mode2 |= JFS_APPEND_FL;
+       if (flags & S_NOATIME)
+               jfs_ip->mode2 |= JFS_NOATIME_FL;
+       if (flags & S_DIRSYNC)
+               jfs_ip->mode2 |= JFS_DIRSYNC_FL;
+       if (flags & S_SYNC)
+               jfs_ip->mode2 |= JFS_SYNC_FL;
+}
+
 /*
  * NAME:       ialloc()
  *
@@ -61,7 +79,8 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
        inode = new_inode(sb);
        if (!inode) {
                jfs_warn("ialloc: new_inode returned NULL!");
-               return inode;
+               rc = -ENOMEM;
+               goto fail;
        }
 
        jfs_inode = JFS_IP(inode);
@@ -69,29 +88,38 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
        rc = diAlloc(parent, S_ISDIR(mode), inode);
        if (rc) {
                jfs_warn("ialloc: diAlloc returned %d!", rc);
-               make_bad_inode(inode);
-               iput(inode);
-               return NULL;
+               if (rc == -EIO)
+                       make_bad_inode(inode);
+               goto fail_put;
+       }
+
+       if (insert_inode_locked(inode) < 0) {
+               rc = -EINVAL;
+               goto fail_unlock;
        }
 
-       inode->i_uid = current->fsuid;
+       inode->i_uid = current_fsuid();
        if (parent->i_mode & S_ISGID) {
                inode->i_gid = parent->i_gid;
                if (S_ISDIR(mode))
                        mode |= S_ISGID;
        } else
-               inode->i_gid = current->fsgid;
+               inode->i_gid = current_fsgid();
+
+       /*
+        * New inodes need to save sane values on disk when
+        * uid & gid mount options are used
+        */
+       jfs_inode->saved_uid = inode->i_uid;
+       jfs_inode->saved_gid = inode->i_gid;
 
        /*
         * Allocate inode to quota.
         */
-       if (DQUOT_ALLOC_INODE(inode)) {
-               DQUOT_DROP(inode);
-               inode->i_flags |= S_NOQUOTA;
-               inode->i_nlink = 0;
-               iput(inode);
-               return NULL;
-       }
+       dquot_initialize(inode);
+       rc = dquot_alloc_inode(inode);
+       if (rc)
+               goto fail_drop;
 
        inode->i_mode = mode;
        /* inherit flags from parent */
@@ -101,14 +129,13 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
                jfs_inode->mode2 |= IDIRECTORY;
                jfs_inode->mode2 &= ~JFS_DIRSYNC_FL;
        }
-       else if (S_ISLNK(mode))
-               jfs_inode->mode2 &=
-                       ~(JFS_IMMUTABLE_FL|JFS_APPEND_FL);
-       else
+       else {
                jfs_inode->mode2 |= INLINEEA | ISPARSE;
+               if (S_ISLNK(mode))
+                       jfs_inode->mode2 &= ~(JFS_IMMUTABLE_FL|JFS_APPEND_FL);
+       }
        jfs_inode->mode2 |= mode;
 
-       inode->i_blksize = sb->s_blocksize;
        inode->i_blocks = 0;
        inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
        jfs_inode->otime = inode->i_ctime.tv_sec;
@@ -133,4 +160,15 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
        jfs_info("ialloc returns inode = 0x%p\n", inode);
 
        return inode;
+
+fail_drop:
+       dquot_drop(inode);
+       inode->i_flags |= S_NOQUOTA;
+fail_unlock:
+       inode->i_nlink = 0;
+       unlock_new_inode(inode);
+fail_put:
+       iput(inode);
+fail:
+       return ERR_PTR(rc);
 }