Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / fs / udf / namei.c
index 86cf34e..ab9a762 100644 (file)
@@ -4,11 +4,6 @@
  * PURPOSE
  *      Inode name handling routines for the OSTA-UDF(tm) filesystem.
  *
- * CONTACTS
- *      E-mail regarding any portion of the Linux UDF file system should be
- *      directed to the development team mailing list (run by majordomo):
- *              linux_udf@hpesjro.fc.hp.com
- *
  * COPYRIGHT
  *      This file is distributed under the terms of the GNU General Public
  *      License (GPL). Copies of the GPL can be obtained from:
@@ -119,7 +114,7 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
                crc = udf_crc(fibh->ebh->b_data, fibh->eoffset, crc);
        }
 
-       cfi->descTag.descCRC = cpu_to_le32(crc);
+       cfi->descTag.descCRC = cpu_to_le16(crc);
        cfi->descTag.descCRCLength = cpu_to_le16(crclen);
 
        for (i=0; i<16; i++)
@@ -159,14 +154,12 @@ udf_find_entry(struct inode *dir, struct dentry *dentry,
        char *nameptr;
        uint8_t lfi;
        uint16_t liu;
-       loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
-       lb_addr bloc, eloc;
+       loff_t size;
+       kernel_lb_addr bloc, eloc;
        uint32_t extoffset, elen, offset;
        struct buffer_head *bh = NULL;
 
-       if (!dir)
-               return NULL;
-
+       size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
        f_pos = (udf_ext0_offset(dir) >> 2);
 
        fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
@@ -303,7 +296,7 @@ static struct dentry *
 udf_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
 {
        struct inode *inode = NULL;
-       struct fileIdentDesc cfi, *fi;
+       struct fileIdentDesc cfi;
        struct udf_fileident_bh fibh;
 
        if (dentry->d_name.len > UDF_NAME_LEN-2)
@@ -314,7 +307,7 @@ udf_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
        /* temporary shorthand for specifying files by inode number */
        if (!strncmp(dentry->d_name.name, ".B=", 3) )
        {
-               lb_addr lb = { 0, simple_strtoul(dentry->d_name.name+3, NULL, 0) };
+               kernel_lb_addr lb = { 0, simple_strtoul(dentry->d_name.name+3, NULL, 0) };
                inode = udf_iget(dir->i_sb, lb);
                if (!inode)
                {
@@ -325,7 +318,7 @@ udf_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
        else
 #endif /* UDF_RECOVERY */
 
-       if ((fi = udf_find_entry(dir, dentry, &fibh, &cfi)))
+       if (udf_find_entry(dir, dentry, &fibh, &cfi))
        {
                if (fibh.sbh != fibh.ebh)
                        udf_release_data(fibh.ebh);
@@ -360,7 +353,7 @@ udf_add_entry(struct inode *dir, struct dentry *dentry,
        uint8_t lfi;
        uint16_t liu;
        int block;
-       lb_addr bloc, eloc;
+       kernel_lb_addr bloc, eloc;
        uint32_t extoffset, elen, offset;
        struct buffer_head *bh = NULL;
 
@@ -655,7 +648,7 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, struct
        }
        cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
        cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
-       *(uint32_t *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
+       *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
                cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
        udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
        if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
@@ -698,7 +691,7 @@ static int udf_mknod(struct inode * dir, struct dentry * dentry, int mode, dev_t
        }
        cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
        cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
-       *(uint32_t *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
+       *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
                cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
        udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
        if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
@@ -746,7 +739,7 @@ static int udf_mkdir(struct inode * dir, struct dentry * dentry, int mode)
        inode->i_nlink = 2;
        cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
        cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(dir));
-       *(uint32_t *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
+       *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
                cpu_to_le32(UDF_I_UNIQUE(dir) & 0x00000000FFFFFFFFUL);
        cfi.fileCharacteristics = FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT;
        udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL);
@@ -765,7 +758,7 @@ static int udf_mkdir(struct inode * dir, struct dentry * dentry, int mode)
        }
        cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
        cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
-       *(uint32_t *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
+       *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
                cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
        cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY;
        udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
@@ -788,7 +781,7 @@ static int empty_dir(struct inode *dir)
        loff_t f_pos;
        loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
        int block;
-       lb_addr bloc, eloc;
+       kernel_lb_addr bloc, eloc;
        uint32_t extoffset, elen, offset;
        struct buffer_head *bh = NULL;
 
@@ -861,7 +854,7 @@ static int udf_rmdir(struct inode * dir, struct dentry * dentry)
        struct inode * inode = dentry->d_inode;
        struct udf_fileident_bh fibh;
        struct fileIdentDesc *fi, cfi;
-       lb_addr tloc;
+       kernel_lb_addr tloc;
 
        retval = -ENOENT;
        lock_kernel();
@@ -887,7 +880,7 @@ static int udf_rmdir(struct inode * dir, struct dentry * dentry)
        inode->i_size = 0;
        mark_inode_dirty(inode);
        dir->i_nlink --;
-       inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
+       inode->i_ctime = dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb);
        mark_inode_dirty(dir);
 
 end_rmdir:
@@ -906,7 +899,7 @@ static int udf_unlink(struct inode * dir, struct dentry * dentry)
        struct udf_fileident_bh fibh;
        struct fileIdentDesc *fi;
        struct fileIdentDesc cfi;
-       lb_addr tloc;
+       kernel_lb_addr tloc;
 
        retval = -ENOENT;
        lock_kernel();
@@ -928,7 +921,7 @@ static int udf_unlink(struct inode * dir, struct dentry * dentry)
        retval = udf_delete_entry(dir, fi, &fibh, &cfi);
        if (retval)
                goto end_unlink;
-       dir->i_ctime = dir->i_mtime = CURRENT_TIME;
+       dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb);
        mark_inode_dirty(dir);
        inode->i_nlink--;
        mark_inode_dirty(inode);
@@ -971,7 +964,7 @@ static int udf_symlink(struct inode * dir, struct dentry * dentry, const char *
        if (UDF_I_ALLOCTYPE(inode) != ICBTAG_FLAG_AD_IN_ICB)
        {
                struct buffer_head *bh = NULL;
-               lb_addr bloc, eloc;
+               kernel_lb_addr bloc, eloc;
                uint32_t elen, extoffset;
 
                block = udf_new_block(inode->i_sb, inode,
@@ -1085,7 +1078,7 @@ static int udf_symlink(struct inode * dir, struct dentry * dentry, const char *
                uint64_t uniqueID;
                lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse);
                uniqueID = le64_to_cpu(lvhd->uniqueID);
-               *(uint32_t *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
+               *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
                        cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL);
                if (!(++uniqueID & 0x00000000FFFFFFFFUL))
                        uniqueID += 16;
@@ -1142,7 +1135,7 @@ static int udf_link(struct dentry * old_dentry, struct inode * dir,
                uint64_t uniqueID;
                lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse);
                uniqueID = le64_to_cpu(lvhd->uniqueID);
-               *(uint32_t *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
+               *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
                        cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL);
                if (!(++uniqueID & 0x00000000FFFFFFFFUL))
                        uniqueID += 16;
@@ -1158,7 +1151,7 @@ static int udf_link(struct dentry * old_dentry, struct inode * dir,
                udf_release_data(fibh.ebh);
        udf_release_data(fibh.sbh);
        inode->i_nlink ++;
-       inode->i_ctime = CURRENT_TIME;
+       inode->i_ctime = current_fs_time(inode->i_sb);
        mark_inode_dirty(inode);
        atomic_inc(&inode->i_count);
        d_instantiate(dentry, inode);
@@ -1178,7 +1171,7 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry,
        struct fileIdentDesc *ofi = NULL, *nfi = NULL, *dir_fi = NULL, ocfi, ncfi;
        struct buffer_head *dir_bh = NULL;
        int retval = -ENOENT;
-       lb_addr tloc;
+       kernel_lb_addr tloc;
 
        lock_kernel();
        if ((ofi = udf_find_entry(old_dir, old_dentry, &ofibh, &ocfi)))
@@ -1231,7 +1224,7 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry,
                }
                if (!dir_fi)
                        goto end_rename;
-               tloc = cpu_to_lelb(dir_fi->icb.extLocation);
+               tloc = lelb_to_cpu(dir_fi->icb.extLocation);
                if (udf_get_lb_pblock(old_inode->i_sb, tloc, 0)
                                        != old_dir->i_ino)
                        goto end_rename;
@@ -1251,7 +1244,7 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry,
         * Like most other Unix systems, set the ctime for inodes on a
         * rename.
         */
-       old_inode->i_ctime = CURRENT_TIME;
+       old_inode->i_ctime = current_fs_time(old_inode->i_sb);
        mark_inode_dirty(old_inode);
 
        /*
@@ -1269,17 +1262,17 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry,
        if (new_inode)
        {
                new_inode->i_nlink--;
-               new_inode->i_ctime = CURRENT_TIME;
+               new_inode->i_ctime = current_fs_time(new_inode->i_sb);
                mark_inode_dirty(new_inode);
        }
-       old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
+       old_dir->i_ctime = old_dir->i_mtime = current_fs_time(old_dir->i_sb);
        mark_inode_dirty(old_dir);
 
        if (dir_fi)
        {
-               dir_fi->icb.extLocation = lelb_to_cpu(UDF_I_LOCATION(new_dir));
+               dir_fi->icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(new_dir));
                udf_update_tag((char *)dir_fi, (sizeof(struct fileIdentDesc) +
-                       cpu_to_le16(dir_fi->lengthOfImpUse) + 3) & ~3);
+                       le16_to_cpu(dir_fi->lengthOfImpUse) + 3) & ~3);
                if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB)
                {
                        mark_inode_dirty(old_inode);