diff options
Diffstat (limited to 'fs/bfs/dir.c')
-rw-r--r-- | fs/bfs/dir.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c index 5a1e5ce057ff..e240c335eb23 100644 --- a/fs/bfs/dir.c +++ b/fs/bfs/dir.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * fs/bfs/dir.c | 2 | * fs/bfs/dir.c |
3 | * BFS directory operations. | 3 | * BFS directory operations. |
4 | * Copyright (C) 1999,2000 Tigran Aivazian <tigran@veritas.com> | 4 | * Copyright (C) 1999,2000 Tigran Aivazian <tigran@veritas.com> |
5 | * Made endianness-clean by Andrew Stribblehill <ads@wompom.org> 2005 | ||
5 | */ | 6 | */ |
6 | 7 | ||
7 | #include <linux/time.h> | 8 | #include <linux/time.h> |
@@ -20,9 +21,9 @@ | |||
20 | #define dprintf(x...) | 21 | #define dprintf(x...) |
21 | #endif | 22 | #endif |
22 | 23 | ||
23 | static int bfs_add_entry(struct inode * dir, const char * name, int namelen, int ino); | 24 | static int bfs_add_entry(struct inode * dir, const unsigned char * name, int namelen, int ino); |
24 | static struct buffer_head * bfs_find_entry(struct inode * dir, | 25 | static struct buffer_head * bfs_find_entry(struct inode * dir, |
25 | const char * name, int namelen, struct bfs_dirent ** res_dir); | 26 | const unsigned char * name, int namelen, struct bfs_dirent ** res_dir); |
26 | 27 | ||
27 | static int bfs_readdir(struct file * f, void * dirent, filldir_t filldir) | 28 | static int bfs_readdir(struct file * f, void * dirent, filldir_t filldir) |
28 | { | 29 | { |
@@ -53,7 +54,7 @@ static int bfs_readdir(struct file * f, void * dirent, filldir_t filldir) | |||
53 | de = (struct bfs_dirent *)(bh->b_data + offset); | 54 | de = (struct bfs_dirent *)(bh->b_data + offset); |
54 | if (de->ino) { | 55 | if (de->ino) { |
55 | int size = strnlen(de->name, BFS_NAMELEN); | 56 | int size = strnlen(de->name, BFS_NAMELEN); |
56 | if (filldir(dirent, de->name, size, f->f_pos, de->ino, DT_UNKNOWN) < 0) { | 57 | if (filldir(dirent, de->name, size, f->f_pos, le16_to_cpu(de->ino), DT_UNKNOWN) < 0) { |
57 | brelse(bh); | 58 | brelse(bh); |
58 | unlock_kernel(); | 59 | unlock_kernel(); |
59 | return 0; | 60 | return 0; |
@@ -107,7 +108,7 @@ static int bfs_create(struct inode * dir, struct dentry * dentry, int mode, | |||
107 | inode->i_mapping->a_ops = &bfs_aops; | 108 | inode->i_mapping->a_ops = &bfs_aops; |
108 | inode->i_mode = mode; | 109 | inode->i_mode = mode; |
109 | inode->i_ino = ino; | 110 | inode->i_ino = ino; |
110 | BFS_I(inode)->i_dsk_ino = ino; | 111 | BFS_I(inode)->i_dsk_ino = cpu_to_le16(ino); |
111 | BFS_I(inode)->i_sblock = 0; | 112 | BFS_I(inode)->i_sblock = 0; |
112 | BFS_I(inode)->i_eblock = 0; | 113 | BFS_I(inode)->i_eblock = 0; |
113 | insert_inode_hash(inode); | 114 | insert_inode_hash(inode); |
@@ -139,7 +140,7 @@ static struct dentry * bfs_lookup(struct inode * dir, struct dentry * dentry, st | |||
139 | lock_kernel(); | 140 | lock_kernel(); |
140 | bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); | 141 | bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); |
141 | if (bh) { | 142 | if (bh) { |
142 | unsigned long ino = le32_to_cpu(de->ino); | 143 | unsigned long ino = (unsigned long)le16_to_cpu(de->ino); |
143 | brelse(bh); | 144 | brelse(bh); |
144 | inode = iget(dir->i_sb, ino); | 145 | inode = iget(dir->i_sb, ino); |
145 | if (!inode) { | 146 | if (!inode) { |
@@ -183,7 +184,7 @@ static int bfs_unlink(struct inode * dir, struct dentry * dentry) | |||
183 | inode = dentry->d_inode; | 184 | inode = dentry->d_inode; |
184 | lock_kernel(); | 185 | lock_kernel(); |
185 | bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); | 186 | bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); |
186 | if (!bh || de->ino != inode->i_ino) | 187 | if (!bh || le16_to_cpu(de->ino) != inode->i_ino) |
187 | goto out_brelse; | 188 | goto out_brelse; |
188 | 189 | ||
189 | if (!inode->i_nlink) { | 190 | if (!inode->i_nlink) { |
@@ -224,7 +225,7 @@ static int bfs_rename(struct inode * old_dir, struct dentry * old_dentry, | |||
224 | old_dentry->d_name.name, | 225 | old_dentry->d_name.name, |
225 | old_dentry->d_name.len, &old_de); | 226 | old_dentry->d_name.len, &old_de); |
226 | 227 | ||
227 | if (!old_bh || old_de->ino != old_inode->i_ino) | 228 | if (!old_bh || le16_to_cpu(old_de->ino) != old_inode->i_ino) |
228 | goto end_rename; | 229 | goto end_rename; |
229 | 230 | ||
230 | error = -EPERM; | 231 | error = -EPERM; |
@@ -270,7 +271,7 @@ struct inode_operations bfs_dir_inops = { | |||
270 | .rename = bfs_rename, | 271 | .rename = bfs_rename, |
271 | }; | 272 | }; |
272 | 273 | ||
273 | static int bfs_add_entry(struct inode * dir, const char * name, int namelen, int ino) | 274 | static int bfs_add_entry(struct inode * dir, const unsigned char * name, int namelen, int ino) |
274 | { | 275 | { |
275 | struct buffer_head * bh; | 276 | struct buffer_head * bh; |
276 | struct bfs_dirent * de; | 277 | struct bfs_dirent * de; |
@@ -304,7 +305,7 @@ static int bfs_add_entry(struct inode * dir, const char * name, int namelen, int | |||
304 | } | 305 | } |
305 | dir->i_mtime = CURRENT_TIME_SEC; | 306 | dir->i_mtime = CURRENT_TIME_SEC; |
306 | mark_inode_dirty(dir); | 307 | mark_inode_dirty(dir); |
307 | de->ino = ino; | 308 | de->ino = cpu_to_le16((u16)ino); |
308 | for (i=0; i<BFS_NAMELEN; i++) | 309 | for (i=0; i<BFS_NAMELEN; i++) |
309 | de->name[i] = (i < namelen) ? name[i] : 0; | 310 | de->name[i] = (i < namelen) ? name[i] : 0; |
310 | mark_buffer_dirty(bh); | 311 | mark_buffer_dirty(bh); |
@@ -317,7 +318,7 @@ static int bfs_add_entry(struct inode * dir, const char * name, int namelen, int | |||
317 | return -ENOSPC; | 318 | return -ENOSPC; |
318 | } | 319 | } |
319 | 320 | ||
320 | static inline int bfs_namecmp(int len, const char * name, const char * buffer) | 321 | static inline int bfs_namecmp(int len, const unsigned char * name, const char * buffer) |
321 | { | 322 | { |
322 | if (len < BFS_NAMELEN && buffer[len]) | 323 | if (len < BFS_NAMELEN && buffer[len]) |
323 | return 0; | 324 | return 0; |
@@ -325,7 +326,7 @@ static inline int bfs_namecmp(int len, const char * name, const char * buffer) | |||
325 | } | 326 | } |
326 | 327 | ||
327 | static struct buffer_head * bfs_find_entry(struct inode * dir, | 328 | static struct buffer_head * bfs_find_entry(struct inode * dir, |
328 | const char * name, int namelen, struct bfs_dirent ** res_dir) | 329 | const unsigned char * name, int namelen, struct bfs_dirent ** res_dir) |
329 | { | 330 | { |
330 | unsigned long block, offset; | 331 | unsigned long block, offset; |
331 | struct buffer_head * bh; | 332 | struct buffer_head * bh; |
@@ -346,7 +347,7 @@ static struct buffer_head * bfs_find_entry(struct inode * dir, | |||
346 | } | 347 | } |
347 | de = (struct bfs_dirent *)(bh->b_data + offset); | 348 | de = (struct bfs_dirent *)(bh->b_data + offset); |
348 | offset += BFS_DIRENT_SIZE; | 349 | offset += BFS_DIRENT_SIZE; |
349 | if (de->ino && bfs_namecmp(namelen, name, de->name)) { | 350 | if (le16_to_cpu(de->ino) && bfs_namecmp(namelen, name, de->name)) { |
350 | *res_dir = de; | 351 | *res_dir = de; |
351 | return bh; | 352 | return bh; |
352 | } | 353 | } |