vserver 1.9.3
[linux-2.6.git] / fs / hfsplus / catalog.c
index 03a01a3..b6c6cdb 100644 (file)
@@ -15,7 +15,7 @@
 
 int hfsplus_cat_cmp_key(hfsplus_btree_key *k1, hfsplus_btree_key *k2)
 {
-       u32 k1p, k2p;
+       __be32 k1p, k2p;
 
        k1p = k1->cat.parent;
        k2p = k2->cat.parent;
@@ -34,8 +34,10 @@ void hfsplus_cat_build_key(hfsplus_btree_key *key, u32 parent,
        if (str) {
                hfsplus_asc2uni(&key->cat.name, str->name, str->len);
                len = be16_to_cpu(key->cat.name.length);
-       } else
-               len = key->cat.name.length = 0;
+       } else {
+               key->cat.name.length = 0;
+               len = 0;
+       }
        key->key_len = cpu_to_be16(6 + 2 * len);
 }
 
@@ -165,11 +167,11 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir, struct qstr *str, struct ino
        if (err != -ENOENT) {
                if (!err)
                        err = -EEXIST;
-               goto out;
+               goto err2;
        }
        err = hfs_brec_insert(&fd, &entry, entry_size);
        if (err)
-               goto out;
+               goto err2;
 
        hfsplus_cat_build_key(fd.search_key, dir->i_ino, str);
        entry_size = hfsplus_cat_build_record(&entry, cnid, inode);
@@ -178,16 +180,24 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir, struct qstr *str, struct ino
                /* panic? */
                if (!err)
                        err = -EEXIST;
-               goto out;
+               goto err1;
        }
        err = hfs_brec_insert(&fd, &entry, entry_size);
-       if (!err) {
-               dir->i_size++;
-               mark_inode_dirty(dir);
-       }
-out:
+       if (err)
+               goto err1;
+
+       dir->i_size++;
+       dir->i_mtime = dir->i_ctime = CURRENT_TIME;
+       mark_inode_dirty(dir);
        hfs_find_exit(&fd);
+       return 0;
 
+err1:
+       hfsplus_cat_build_key(fd.search_key, cnid, NULL);
+       if (!hfs_brec_find(&fd))
+               hfs_brec_remove(&fd);
+err2:
+       hfs_find_exit(&fd);
        return err;
 }
 
@@ -259,6 +269,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
                goto out;
 
        dir->i_size--;
+       dir->i_mtime = dir->i_ctime = CURRENT_TIME;
        mark_inode_dirty(dir);
 out:
        hfs_find_exit(&fd);
@@ -304,6 +315,7 @@ int hfsplus_rename_cat(u32 cnid,
        if (err)
                goto out;
        dst_dir->i_size++;
+       dst_dir->i_mtime = dst_dir->i_ctime = CURRENT_TIME;
        mark_inode_dirty(dst_dir);
 
        /* finally remove the old entry */
@@ -315,6 +327,7 @@ int hfsplus_rename_cat(u32 cnid,
        if (err)
                goto out;
        src_dir->i_size--;
+       src_dir->i_mtime = src_dir->i_ctime = CURRENT_TIME;
        mark_inode_dirty(src_dir);
 
        /* remove old thread entry */