repair sysv_write_inode(), switch sysv to simple_fsync()
[safe/jmp/linux-2.6] / fs / ufs / namei.c
index 364bb92..23119fe 100644 (file)
 
 #include <linux/time.h>
 #include <linux/fs.h>
-#include <linux/ufs_fs.h>
 #include <linux/smp_lock.h>
-#include "swab.h"      /* will go away - see comment in mknod() */
-#include "util.h"
-
-/*
-#undef UFS_NAMEI_DEBUG
-*/
-#define UFS_NAMEI_DEBUG
 
-#ifdef UFS_NAMEI_DEBUG
-#define UFSD(x) printk("(%s, %d), %s: ", __FILE__, __LINE__, __FUNCTION__); printk x;
-#else
-#define UFSD(x)
-#endif
+#include "ufs_fs.h"
+#include "ufs.h"
+#include "util.h"
 
 static inline int ufs_add_nondir(struct dentry *dentry, struct inode *inode)
 {
@@ -68,10 +58,10 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, stru
        lock_kernel();
        ino = ufs_inode_by_name(dir, dentry);
        if (ino) {
-               inode = iget(dir->i_sb, ino);
-               if (!inode) {
+               inode = ufs_iget(dir->i_sb, ino);
+               if (IS_ERR(inode)) {
                        unlock_kernel();
-                       return ERR_PTR(-EACCES);
+                       return ERR_CAST(inode);
                }
        }
        unlock_kernel();
@@ -90,8 +80,13 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, stru
 static int ufs_create (struct inode * dir, struct dentry * dentry, int mode,
                struct nameidata *nd)
 {
-       struct inode * inode = ufs_new_inode(dir, mode);
-       int err = PTR_ERR(inode);
+       struct inode *inode;
+       int err;
+
+       UFSD("BEGIN\n");
+       inode = ufs_new_inode(dir, mode);
+       err = PTR_ERR(inode);
+
        if (!IS_ERR(inode)) {
                inode->i_op = &ufs_file_inode_operations;
                inode->i_fop = &ufs_file_operations;
@@ -101,6 +96,7 @@ static int ufs_create (struct inode * dir, struct dentry * dentry, int mode,
                err = ufs_add_nondir(dentry, inode);
                unlock_kernel();
        }
+       UFSD("END: err=%d\n", err);
        return err;
 }
 
@@ -115,7 +111,6 @@ static int ufs_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t
        err = PTR_ERR(inode);
        if (!IS_ERR(inode)) {
                init_special_inode(inode, mode, rdev);
-               /* NOTE: that'll go when we get wide dev_t */
                ufs_set_inode_dev(inode->i_sb, UFS_I(inode), rdev);
                mark_inode_dirty(inode);
                lock_kernel();
@@ -134,7 +129,7 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry,
        struct inode * inode;
 
        if (l > sb->s_blocksize)
-               goto out;
+               goto out_notlocked;
 
        lock_kernel();
        inode = ufs_new_inode(dir, S_IFLNK | S_IRWXUGO);
@@ -152,7 +147,7 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry,
        } else {
                /* fast symlink */
                inode->i_op = &ufs_fast_symlink_inode_operations;
-               memcpy((char*)&UFS_I(inode)->i_u1.i_data,symname,l);
+               memcpy(UFS_I(inode)->i_u1.i_symlink, symname, l);
                inode->i_size = l-1;
        }
        mark_inode_dirty(inode);
@@ -160,6 +155,7 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry,
        err = ufs_add_nondir(dentry, inode);
 out:
        unlock_kernel();
+out_notlocked:
        return err;
 
 out_fail:
@@ -312,7 +308,7 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry,
                ufs_set_link(new_dir, new_de, new_page, old_inode);
                new_inode->i_ctime = CURRENT_TIME_SEC;
                if (dir_de)
-                       new_inode->i_nlink--;
+                       drop_nlink(new_inode);
                inode_dec_link_count(new_inode);
        } else {
                if (dir_de) {
@@ -359,7 +355,7 @@ out:
        return err;
 }
 
-struct inode_operations ufs_dir_inode_operations = {
+const struct inode_operations ufs_dir_inode_operations = {
        .create         = ufs_create,
        .lookup         = ufs_lookup,
        .link           = ufs_link,