diff options
| author | Steve French <sfrench@us.ibm.com> | 2006-03-07 16:47:30 -0500 |
|---|---|---|
| committer | Steve French <sfrench@us.ibm.com> | 2006-03-07 16:47:30 -0500 |
| commit | f6e77c94796edad172602234826a022d463d910e (patch) | |
| tree | f5cb0848c9e848499b0f0676fafe7ff207538ae8 /fs/cramfs/inode.c | |
| parent | beb84dc8186662b17d5ea510fabb85cb7e266d33 (diff) | |
| parent | d0b004840bd3b5ff2f2a0ad14fa0bd43349f5175 (diff) | |
Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cramfs/inode.c')
| -rw-r--r-- | fs/cramfs/inode.c | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index 7fe85415ae7c..8ad52f5bf255 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c | |||
| @@ -36,7 +36,7 @@ static DECLARE_MUTEX(read_mutex); | |||
| 36 | 36 | ||
| 37 | /* These two macros may change in future, to provide better st_ino | 37 | /* These two macros may change in future, to provide better st_ino |
| 38 | semantics. */ | 38 | semantics. */ |
| 39 | #define CRAMINO(x) ((x)->offset?(x)->offset<<2:1) | 39 | #define CRAMINO(x) (((x)->offset && (x)->size)?(x)->offset<<2:1) |
| 40 | #define OFFSET(x) ((x)->i_ino) | 40 | #define OFFSET(x) ((x)->i_ino) |
| 41 | 41 | ||
| 42 | 42 | ||
| @@ -66,8 +66,36 @@ static int cramfs_iget5_test(struct inode *inode, void *opaque) | |||
| 66 | 66 | ||
| 67 | static int cramfs_iget5_set(struct inode *inode, void *opaque) | 67 | static int cramfs_iget5_set(struct inode *inode, void *opaque) |
| 68 | { | 68 | { |
| 69 | static struct timespec zerotime; | ||
| 69 | struct cramfs_inode *cramfs_inode = opaque; | 70 | struct cramfs_inode *cramfs_inode = opaque; |
| 71 | inode->i_mode = cramfs_inode->mode; | ||
| 72 | inode->i_uid = cramfs_inode->uid; | ||
| 73 | inode->i_size = cramfs_inode->size; | ||
| 74 | inode->i_blocks = (cramfs_inode->size - 1) / 512 + 1; | ||
| 75 | inode->i_blksize = PAGE_CACHE_SIZE; | ||
| 76 | inode->i_gid = cramfs_inode->gid; | ||
| 77 | /* Struct copy intentional */ | ||
| 78 | inode->i_mtime = inode->i_atime = inode->i_ctime = zerotime; | ||
| 70 | inode->i_ino = CRAMINO(cramfs_inode); | 79 | inode->i_ino = CRAMINO(cramfs_inode); |
| 80 | /* inode->i_nlink is left 1 - arguably wrong for directories, | ||
| 81 | but it's the best we can do without reading the directory | ||
| 82 | contents. 1 yields the right result in GNU find, even | ||
| 83 | without -noleaf option. */ | ||
| 84 | if (S_ISREG(inode->i_mode)) { | ||
| 85 | inode->i_fop = &generic_ro_fops; | ||
| 86 | inode->i_data.a_ops = &cramfs_aops; | ||
| 87 | } else if (S_ISDIR(inode->i_mode)) { | ||
| 88 | inode->i_op = &cramfs_dir_inode_operations; | ||
| 89 | inode->i_fop = &cramfs_directory_operations; | ||
| 90 | } else if (S_ISLNK(inode->i_mode)) { | ||
| 91 | inode->i_op = &page_symlink_inode_operations; | ||
| 92 | inode->i_data.a_ops = &cramfs_aops; | ||
| 93 | } else { | ||
| 94 | inode->i_size = 0; | ||
| 95 | inode->i_blocks = 0; | ||
| 96 | init_special_inode(inode, inode->i_mode, | ||
| 97 | old_decode_dev(cramfs_inode->size)); | ||
| 98 | } | ||
| 71 | return 0; | 99 | return 0; |
| 72 | } | 100 | } |
| 73 | 101 | ||
| @@ -77,37 +105,7 @@ static struct inode *get_cramfs_inode(struct super_block *sb, | |||
| 77 | struct inode *inode = iget5_locked(sb, CRAMINO(cramfs_inode), | 105 | struct inode *inode = iget5_locked(sb, CRAMINO(cramfs_inode), |
| 78 | cramfs_iget5_test, cramfs_iget5_set, | 106 | cramfs_iget5_test, cramfs_iget5_set, |
| 79 | cramfs_inode); | 107 | cramfs_inode); |
| 80 | static struct timespec zerotime; | ||
| 81 | |||
| 82 | if (inode && (inode->i_state & I_NEW)) { | 108 | if (inode && (inode->i_state & I_NEW)) { |
| 83 | inode->i_mode = cramfs_inode->mode; | ||
| 84 | inode->i_uid = cramfs_inode->uid; | ||
| 85 | inode->i_size = cramfs_inode->size; | ||
| 86 | inode->i_blocks = (cramfs_inode->size - 1) / 512 + 1; | ||
| 87 | inode->i_blksize = PAGE_CACHE_SIZE; | ||
| 88 | inode->i_gid = cramfs_inode->gid; | ||
| 89 | /* Struct copy intentional */ | ||
| 90 | inode->i_mtime = inode->i_atime = inode->i_ctime = zerotime; | ||
| 91 | inode->i_ino = CRAMINO(cramfs_inode); | ||
| 92 | /* inode->i_nlink is left 1 - arguably wrong for directories, | ||
| 93 | but it's the best we can do without reading the directory | ||
| 94 | contents. 1 yields the right result in GNU find, even | ||
| 95 | without -noleaf option. */ | ||
| 96 | if (S_ISREG(inode->i_mode)) { | ||
| 97 | inode->i_fop = &generic_ro_fops; | ||
| 98 | inode->i_data.a_ops = &cramfs_aops; | ||
| 99 | } else if (S_ISDIR(inode->i_mode)) { | ||
| 100 | inode->i_op = &cramfs_dir_inode_operations; | ||
| 101 | inode->i_fop = &cramfs_directory_operations; | ||
| 102 | } else if (S_ISLNK(inode->i_mode)) { | ||
| 103 | inode->i_op = &page_symlink_inode_operations; | ||
| 104 | inode->i_data.a_ops = &cramfs_aops; | ||
| 105 | } else { | ||
| 106 | inode->i_size = 0; | ||
| 107 | inode->i_blocks = 0; | ||
| 108 | init_special_inode(inode, inode->i_mode, | ||
| 109 | old_decode_dev(cramfs_inode->size)); | ||
| 110 | } | ||
| 111 | unlock_new_inode(inode); | 109 | unlock_new_inode(inode); |
| 112 | } | 110 | } |
| 113 | return inode; | 111 | return inode; |
