diff options
Diffstat (limited to 'fs/ntfs/dir.c')
-rw-r--r-- | fs/ntfs/dir.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c index 93577561cdbe..46779471c542 100644 --- a/fs/ntfs/dir.c +++ b/fs/ntfs/dir.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /** | 1 | /** |
2 | * dir.c - NTFS kernel directory operations. Part of the Linux-NTFS project. | 2 | * dir.c - NTFS kernel directory operations. Part of the Linux-NTFS project. |
3 | * | 3 | * |
4 | * Copyright (c) 2001-2004 Anton Altaparmakov | 4 | * Copyright (c) 2001-2005 Anton Altaparmakov |
5 | * Copyright (c) 2002 Richard Russon | 5 | * Copyright (c) 2002 Richard Russon |
6 | * | 6 | * |
7 | * This program/include file is free software; you can redistribute it and/or | 7 | * This program/include file is free software; you can redistribute it and/or |
@@ -183,8 +183,7 @@ found_it: | |||
183 | name->len = 0; | 183 | name->len = 0; |
184 | *res = name; | 184 | *res = name; |
185 | } else { | 185 | } else { |
186 | if (name) | 186 | kfree(name); |
187 | kfree(name); | ||
188 | *res = NULL; | 187 | *res = NULL; |
189 | } | 188 | } |
190 | mref = le64_to_cpu(ie->data.dir.indexed_file); | 189 | mref = le64_to_cpu(ie->data.dir.indexed_file); |
@@ -444,8 +443,7 @@ found_it2: | |||
444 | name->len = 0; | 443 | name->len = 0; |
445 | *res = name; | 444 | *res = name; |
446 | } else { | 445 | } else { |
447 | if (name) | 446 | kfree(name); |
448 | kfree(name); | ||
449 | *res = NULL; | 447 | *res = NULL; |
450 | } | 448 | } |
451 | mref = le64_to_cpu(ie->data.dir.indexed_file); | 449 | mref = le64_to_cpu(ie->data.dir.indexed_file); |
@@ -610,7 +608,7 @@ dir_err_out: | |||
610 | // TODO: (AIA) | 608 | // TODO: (AIA) |
611 | // The algorithm embedded in this code will be required for the time when we | 609 | // The algorithm embedded in this code will be required for the time when we |
612 | // want to support adding of entries to directories, where we require correct | 610 | // want to support adding of entries to directories, where we require correct |
613 | // collation of file names in order not to cause corruption of the file system. | 611 | // collation of file names in order not to cause corruption of the filesystem. |
614 | 612 | ||
615 | /** | 613 | /** |
616 | * ntfs_lookup_inode_by_name - find an inode in a directory given its name | 614 | * ntfs_lookup_inode_by_name - find an inode in a directory given its name |
@@ -1101,7 +1099,7 @@ static inline int ntfs_filldir(ntfs_volume *vol, loff_t fpos, | |||
1101 | static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | 1099 | static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir) |
1102 | { | 1100 | { |
1103 | s64 ia_pos, ia_start, prev_ia_pos, bmp_pos; | 1101 | s64 ia_pos, ia_start, prev_ia_pos, bmp_pos; |
1104 | loff_t fpos; | 1102 | loff_t fpos, i_size; |
1105 | struct inode *bmp_vi, *vdir = filp->f_dentry->d_inode; | 1103 | struct inode *bmp_vi, *vdir = filp->f_dentry->d_inode; |
1106 | struct super_block *sb = vdir->i_sb; | 1104 | struct super_block *sb = vdir->i_sb; |
1107 | ntfs_inode *ndir = NTFS_I(vdir); | 1105 | ntfs_inode *ndir = NTFS_I(vdir); |
@@ -1122,7 +1120,8 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
1122 | vdir->i_ino, fpos); | 1120 | vdir->i_ino, fpos); |
1123 | rc = err = 0; | 1121 | rc = err = 0; |
1124 | /* Are we at end of dir yet? */ | 1122 | /* Are we at end of dir yet? */ |
1125 | if (fpos >= vdir->i_size + vol->mft_record_size) | 1123 | i_size = i_size_read(vdir); |
1124 | if (fpos >= i_size + vol->mft_record_size) | ||
1126 | goto done; | 1125 | goto done; |
1127 | /* Emulate . and .. for all directories. */ | 1126 | /* Emulate . and .. for all directories. */ |
1128 | if (!fpos) { | 1127 | if (!fpos) { |
@@ -1264,7 +1263,7 @@ skip_index_root: | |||
1264 | bmp_mapping = bmp_vi->i_mapping; | 1263 | bmp_mapping = bmp_vi->i_mapping; |
1265 | /* Get the starting bitmap bit position and sanity check it. */ | 1264 | /* Get the starting bitmap bit position and sanity check it. */ |
1266 | bmp_pos = ia_pos >> ndir->itype.index.block_size_bits; | 1265 | bmp_pos = ia_pos >> ndir->itype.index.block_size_bits; |
1267 | if (unlikely(bmp_pos >> 3 >= bmp_vi->i_size)) { | 1266 | if (unlikely(bmp_pos >> 3 >= i_size_read(bmp_vi))) { |
1268 | ntfs_error(sb, "Current index allocation position exceeds " | 1267 | ntfs_error(sb, "Current index allocation position exceeds " |
1269 | "index bitmap size."); | 1268 | "index bitmap size."); |
1270 | goto err_out; | 1269 | goto err_out; |
@@ -1301,7 +1300,7 @@ find_next_index_buffer: | |||
1301 | goto get_next_bmp_page; | 1300 | goto get_next_bmp_page; |
1302 | } | 1301 | } |
1303 | /* If we have reached the end of the bitmap, we are done. */ | 1302 | /* If we have reached the end of the bitmap, we are done. */ |
1304 | if (unlikely(((bmp_pos + cur_bmp_pos) >> 3) >= vdir->i_size)) | 1303 | if (unlikely(((bmp_pos + cur_bmp_pos) >> 3) >= i_size)) |
1305 | goto unm_EOD; | 1304 | goto unm_EOD; |
1306 | ia_pos = (bmp_pos + cur_bmp_pos) << | 1305 | ia_pos = (bmp_pos + cur_bmp_pos) << |
1307 | ndir->itype.index.block_size_bits; | 1306 | ndir->itype.index.block_size_bits; |
@@ -1309,7 +1308,8 @@ find_next_index_buffer: | |||
1309 | ntfs_debug("Handling index buffer 0x%llx.", | 1308 | ntfs_debug("Handling index buffer 0x%llx.", |
1310 | (unsigned long long)bmp_pos + cur_bmp_pos); | 1309 | (unsigned long long)bmp_pos + cur_bmp_pos); |
1311 | /* If the current index buffer is in the same page we reuse the page. */ | 1310 | /* If the current index buffer is in the same page we reuse the page. */ |
1312 | if ((prev_ia_pos & PAGE_CACHE_MASK) != (ia_pos & PAGE_CACHE_MASK)) { | 1311 | if ((prev_ia_pos & (s64)PAGE_CACHE_MASK) != |
1312 | (ia_pos & (s64)PAGE_CACHE_MASK)) { | ||
1313 | prev_ia_pos = ia_pos; | 1313 | prev_ia_pos = ia_pos; |
1314 | if (likely(ia_page != NULL)) { | 1314 | if (likely(ia_page != NULL)) { |
1315 | unlock_page(ia_page); | 1315 | unlock_page(ia_page); |
@@ -1441,7 +1441,7 @@ unm_EOD: | |||
1441 | ntfs_unmap_page(bmp_page); | 1441 | ntfs_unmap_page(bmp_page); |
1442 | EOD: | 1442 | EOD: |
1443 | /* We are finished, set fpos to EOD. */ | 1443 | /* We are finished, set fpos to EOD. */ |
1444 | fpos = vdir->i_size + vol->mft_record_size; | 1444 | fpos = i_size + vol->mft_record_size; |
1445 | abort: | 1445 | abort: |
1446 | kfree(name); | 1446 | kfree(name); |
1447 | done: | 1447 | done: |
@@ -1461,10 +1461,8 @@ err_out: | |||
1461 | unlock_page(ia_page); | 1461 | unlock_page(ia_page); |
1462 | ntfs_unmap_page(ia_page); | 1462 | ntfs_unmap_page(ia_page); |
1463 | } | 1463 | } |
1464 | if (ir) | 1464 | kfree(ir); |
1465 | kfree(ir); | 1465 | kfree(name); |
1466 | if (name) | ||
1467 | kfree(name); | ||
1468 | if (ctx) | 1466 | if (ctx) |
1469 | ntfs_attr_put_search_ctx(ctx); | 1467 | ntfs_attr_put_search_ctx(ctx); |
1470 | if (m) | 1468 | if (m) |
@@ -1495,7 +1493,7 @@ err_out: | |||
1495 | static int ntfs_dir_open(struct inode *vi, struct file *filp) | 1493 | static int ntfs_dir_open(struct inode *vi, struct file *filp) |
1496 | { | 1494 | { |
1497 | if (sizeof(unsigned long) < 8) { | 1495 | if (sizeof(unsigned long) < 8) { |
1498 | if (vi->i_size > MAX_LFS_FILESIZE) | 1496 | if (i_size_read(vi) > MAX_LFS_FILESIZE) |
1499 | return -EFBIG; | 1497 | return -EFBIG; |
1500 | } | 1498 | } |
1501 | return 0; | 1499 | return 0; |