drm/radeon: fix PM on non-vram cards.
[safe/jmp/linux-2.6] / fs / hpfs / inode.c
index bcf6ee3..1042a9b 100644 (file)
@@ -6,6 +6,8 @@
  *  inode VFS functions
  */
 
+#include <linux/smp_lock.h>
+#include <linux/slab.h>
 #include "hpfs_fn.h"
 
 void hpfs_init_inode(struct inode *i)
@@ -45,7 +47,7 @@ void hpfs_read_inode(struct inode *i)
        struct fnode *fnode;
        struct super_block *sb = i->i_sb;
        struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
-       unsigned char *ea;
+       void *ea;
        int ea_size;
 
        if (!(fnode = hpfs_map_fnode(sb, i->i_ino, &bh))) {
@@ -60,14 +62,14 @@ void hpfs_read_inode(struct inode *i)
        if (hpfs_sb(i->i_sb)->sb_eas) {
                if ((ea = hpfs_get_ea(i->i_sb, fnode, "UID", &ea_size))) {
                        if (ea_size == 2) {
-                               i->i_uid = le16_to_cpu(*(u16*)ea);
+                               i->i_uid = le16_to_cpu(*(__le16*)ea);
                                hpfs_inode->i_ea_uid = 1;
                        }
                        kfree(ea);
                }
                if ((ea = hpfs_get_ea(i->i_sb, fnode, "GID", &ea_size))) {
                        if (ea_size == 2) {
-                               i->i_gid = le16_to_cpu(*(u16*)ea);
+                               i->i_gid = le16_to_cpu(*(__le16*)ea);
                                hpfs_inode->i_ea_gid = 1;
                        }
                        kfree(ea);
@@ -87,7 +89,7 @@ void hpfs_read_inode(struct inode *i)
                        int rdev = 0;
                        umode_t mode = hpfs_sb(sb)->sb_mode;
                        if (ea_size == 2) {
-                               mode = le16_to_cpu(*(u16*)ea);
+                               mode = le16_to_cpu(*(__le16*)ea);
                                hpfs_inode->i_ea_mode = 1;
                        }
                        kfree(ea);
@@ -95,7 +97,7 @@ void hpfs_read_inode(struct inode *i)
                        if (S_ISBLK(mode) || S_ISCHR(mode)) {
                                if ((ea = hpfs_get_ea(i->i_sb, fnode, "DEV", &ea_size))) {
                                        if (ea_size == 4)
-                                               rdev = le32_to_cpu(*(u32*)ea);
+                                               rdev = le32_to_cpu(*(__le32*)ea);
                                        kfree(ea);
                                }
                        }
@@ -111,7 +113,7 @@ void hpfs_read_inode(struct inode *i)
                }
        }
        if (fnode->dirflag) {
-               unsigned n_dnodes, n_subdirs;
+               int n_dnodes, n_subdirs;
                i->i_mode |= S_IFDIR;
                i->i_op = &hpfs_dir_iops;
                i->i_fop = &hpfs_dir_ops;
@@ -148,7 +150,7 @@ static void hpfs_write_inode_ea(struct inode *i, struct fnode *fnode)
                   we'd better not overwrite them
                hpfs_error(i->i_sb, "fnode %08x has some unknown HPFS386 stuctures", i->i_ino);
        } else*/ if (hpfs_sb(i->i_sb)->sb_eas >= 2) {
-               u32 ea;
+               __le32 ea;
                if ((i->i_uid != hpfs_sb(i->i_sb)->sb_uid) || hpfs_inode->i_ea_uid) {
                        ea = cpu_to_le32(i->i_uid);
                        hpfs_set_ea(i, fnode, "UID", (char*)&ea, 2);
@@ -165,6 +167,7 @@ static void hpfs_write_inode_ea(struct inode *i, struct fnode *fnode)
                          && i->i_mode != ((hpfs_sb(i->i_sb)->sb_mode & ~(S_ISDIR(i->i_mode) ? 0222 : 0333))
                          | (S_ISDIR(i->i_mode) ? S_IFDIR : S_IFREG))) || hpfs_inode->i_ea_mode) {
                                ea = cpu_to_le32(i->i_mode);
+                               /* sick, but legal */
                                hpfs_set_ea(i, fnode, "MODE", (char *)&ea, 2);
                                hpfs_inode->i_ea_mode = 1;
                        }
@@ -250,25 +253,37 @@ void hpfs_write_inode_nolock(struct inode *i)
                        de->file_size = 0;
                        hpfs_mark_4buffers_dirty(&qbh);
                        hpfs_brelse4(&qbh);
-               } else hpfs_error(i->i_sb, "directory %08x doesn't have '.' entry", i->i_ino);
+               } else
+                       hpfs_error(i->i_sb,
+                               "directory %08lx doesn't have '.' entry",
+                               (unsigned long)i->i_ino);
        }
        mark_buffer_dirty(bh);
        brelse(bh);
 }
 
-int hpfs_notify_change(struct dentry *dentry, struct iattr *attr)
+int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
 {
        struct inode *inode = dentry->d_inode;
-       int error=0;
+       int error = -EINVAL;
+
        lock_kernel();
-       if ( ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) ||
-            (hpfs_sb(inode->i_sb)->sb_root == inode->i_ino) ) {
-               error = -EINVAL;
-       } else if ((error = inode_change_ok(inode, attr))) {
-       } else if ((error = inode_setattr(inode, attr))) {
-       } else {
-               hpfs_write_inode(inode);
-       }
+       if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root)
+               goto out_unlock;
+       if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size)
+               goto out_unlock;
+
+       error = inode_change_ok(inode, attr);
+       if (error)
+               goto out_unlock;
+
+       error = inode_setattr(inode, attr);
+       if (error)
+               goto out_unlock;
+
+       hpfs_write_inode(inode);
+
+ out_unlock:
        unlock_kernel();
        return error;
 }