aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hpfs/namei.c
diff options
context:
space:
mode:
authorMikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>2011-05-08 14:44:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-09 12:04:24 -0400
commit0b69760be6968c528869d4aec95ecf64dbf3e8bd (patch)
treeebc1f353c7df72bfe28b9da64af810c20ca8cdd4 /fs/hpfs/namei.c
parentbc8728ee56bca62df269b2dd159bc60838ac8e80 (diff)
HPFS: Fix endianity. Make hpfs work on big-endian machines
Fix endianity. Make hpfs work on big-endian machines. Signed-off-by: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/hpfs/namei.c')
-rw-r--r--fs/hpfs/namei.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 9c66f0ec8f8e..5a8de6a28e61 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -37,8 +37,8 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
37 if (!(mode & 0222)) dee.read_only = 1; 37 if (!(mode & 0222)) dee.read_only = 1;
38 /*dee.archive = 0;*/ 38 /*dee.archive = 0;*/
39 dee.hidden = name[0] == '.'; 39 dee.hidden = name[0] == '.';
40 dee.fnode = fno; 40 dee.fnode = cpu_to_le32(fno);
41 dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); 41 dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
42 result = new_inode(dir->i_sb); 42 result = new_inode(dir->i_sb);
43 if (!result) 43 if (!result)
44 goto bail2; 44 goto bail2;
@@ -46,7 +46,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
46 result->i_ino = fno; 46 result->i_ino = fno;
47 hpfs_i(result)->i_parent_dir = dir->i_ino; 47 hpfs_i(result)->i_parent_dir = dir->i_ino;
48 hpfs_i(result)->i_dno = dno; 48 hpfs_i(result)->i_dno = dno;
49 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); 49 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
50 result->i_ctime.tv_nsec = 0; 50 result->i_ctime.tv_nsec = 0;
51 result->i_mtime.tv_nsec = 0; 51 result->i_mtime.tv_nsec = 0;
52 result->i_atime.tv_nsec = 0; 52 result->i_atime.tv_nsec = 0;
@@ -69,21 +69,21 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
69 } 69 }
70 fnode->len = len; 70 fnode->len = len;
71 memcpy(fnode->name, name, len > 15 ? 15 : len); 71 memcpy(fnode->name, name, len > 15 ? 15 : len);
72 fnode->up = dir->i_ino; 72 fnode->up = cpu_to_le32(dir->i_ino);
73 fnode->dirflag = 1; 73 fnode->dirflag = 1;
74 fnode->btree.n_free_nodes = 7; 74 fnode->btree.n_free_nodes = 7;
75 fnode->btree.n_used_nodes = 1; 75 fnode->btree.n_used_nodes = 1;
76 fnode->btree.first_free = 0x14; 76 fnode->btree.first_free = cpu_to_le16(0x14);
77 fnode->u.external[0].disk_secno = dno; 77 fnode->u.external[0].disk_secno = cpu_to_le32(dno);
78 fnode->u.external[0].file_secno = -1; 78 fnode->u.external[0].file_secno = cpu_to_le32(-1);
79 dnode->root_dnode = 1; 79 dnode->root_dnode = 1;
80 dnode->up = fno; 80 dnode->up = cpu_to_le32(fno);
81 de = hpfs_add_de(dir->i_sb, dnode, "\001\001", 2, 0); 81 de = hpfs_add_de(dir->i_sb, dnode, "\001\001", 2, 0);
82 de->creation_date = de->write_date = de->read_date = gmt_to_local(dir->i_sb, get_seconds()); 82 de->creation_date = de->write_date = de->read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
83 if (!(mode & 0222)) de->read_only = 1; 83 if (!(mode & 0222)) de->read_only = 1;
84 de->first = de->directory = 1; 84 de->first = de->directory = 1;
85 /*de->hidden = de->system = 0;*/ 85 /*de->hidden = de->system = 0;*/
86 de->fnode = fno; 86 de->fnode = cpu_to_le32(fno);
87 mark_buffer_dirty(bh); 87 mark_buffer_dirty(bh);
88 brelse(bh); 88 brelse(bh);
89 hpfs_mark_4buffers_dirty(&qbh0); 89 hpfs_mark_4buffers_dirty(&qbh0);
@@ -137,8 +137,8 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
137 if (!(mode & 0222)) dee.read_only = 1; 137 if (!(mode & 0222)) dee.read_only = 1;
138 dee.archive = 1; 138 dee.archive = 1;
139 dee.hidden = name[0] == '.'; 139 dee.hidden = name[0] == '.';
140 dee.fnode = fno; 140 dee.fnode = cpu_to_le32(fno);
141 dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); 141 dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
142 142
143 result = new_inode(dir->i_sb); 143 result = new_inode(dir->i_sb);
144 if (!result) 144 if (!result)
@@ -152,7 +152,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
152 result->i_fop = &hpfs_file_ops; 152 result->i_fop = &hpfs_file_ops;
153 result->i_nlink = 1; 153 result->i_nlink = 1;
154 hpfs_i(result)->i_parent_dir = dir->i_ino; 154 hpfs_i(result)->i_parent_dir = dir->i_ino;
155 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); 155 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
156 result->i_ctime.tv_nsec = 0; 156 result->i_ctime.tv_nsec = 0;
157 result->i_mtime.tv_nsec = 0; 157 result->i_mtime.tv_nsec = 0;
158 result->i_atime.tv_nsec = 0; 158 result->i_atime.tv_nsec = 0;
@@ -173,7 +173,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
173 } 173 }
174 fnode->len = len; 174 fnode->len = len;
175 memcpy(fnode->name, name, len > 15 ? 15 : len); 175 memcpy(fnode->name, name, len > 15 ? 15 : len);
176 fnode->up = dir->i_ino; 176 fnode->up = cpu_to_le32(dir->i_ino);
177 mark_buffer_dirty(bh); 177 mark_buffer_dirty(bh);
178 brelse(bh); 178 brelse(bh);
179 179
@@ -225,8 +225,8 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
225 if (!(mode & 0222)) dee.read_only = 1; 225 if (!(mode & 0222)) dee.read_only = 1;
226 dee.archive = 1; 226 dee.archive = 1;
227 dee.hidden = name[0] == '.'; 227 dee.hidden = name[0] == '.';
228 dee.fnode = fno; 228 dee.fnode = cpu_to_le32(fno);
229 dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); 229 dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
230 230
231 result = new_inode(dir->i_sb); 231 result = new_inode(dir->i_sb);
232 if (!result) 232 if (!result)
@@ -235,7 +235,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
235 hpfs_init_inode(result); 235 hpfs_init_inode(result);
236 result->i_ino = fno; 236 result->i_ino = fno;
237 hpfs_i(result)->i_parent_dir = dir->i_ino; 237 hpfs_i(result)->i_parent_dir = dir->i_ino;
238 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); 238 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
239 result->i_ctime.tv_nsec = 0; 239 result->i_ctime.tv_nsec = 0;
240 result->i_mtime.tv_nsec = 0; 240 result->i_mtime.tv_nsec = 0;
241 result->i_atime.tv_nsec = 0; 241 result->i_atime.tv_nsec = 0;
@@ -256,7 +256,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
256 } 256 }
257 fnode->len = len; 257 fnode->len = len;
258 memcpy(fnode->name, name, len > 15 ? 15 : len); 258 memcpy(fnode->name, name, len > 15 ? 15 : len);
259 fnode->up = dir->i_ino; 259 fnode->up = cpu_to_le32(dir->i_ino);
260 mark_buffer_dirty(bh); 260 mark_buffer_dirty(bh);
261 261
262 insert_inode_hash(result); 262 insert_inode_hash(result);
@@ -300,8 +300,8 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
300 memset(&dee, 0, sizeof dee); 300 memset(&dee, 0, sizeof dee);
301 dee.archive = 1; 301 dee.archive = 1;
302 dee.hidden = name[0] == '.'; 302 dee.hidden = name[0] == '.';
303 dee.fnode = fno; 303 dee.fnode = cpu_to_le32(fno);
304 dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); 304 dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
305 305
306 result = new_inode(dir->i_sb); 306 result = new_inode(dir->i_sb);
307 if (!result) 307 if (!result)
@@ -309,7 +309,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
309 result->i_ino = fno; 309 result->i_ino = fno;
310 hpfs_init_inode(result); 310 hpfs_init_inode(result);
311 hpfs_i(result)->i_parent_dir = dir->i_ino; 311 hpfs_i(result)->i_parent_dir = dir->i_ino;
312 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); 312 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
313 result->i_ctime.tv_nsec = 0; 313 result->i_ctime.tv_nsec = 0;
314 result->i_mtime.tv_nsec = 0; 314 result->i_mtime.tv_nsec = 0;
315 result->i_atime.tv_nsec = 0; 315 result->i_atime.tv_nsec = 0;
@@ -332,7 +332,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
332 } 332 }
333 fnode->len = len; 333 fnode->len = len;
334 memcpy(fnode->name, name, len > 15 ? 15 : len); 334 memcpy(fnode->name, name, len > 15 ? 15 : len);
335 fnode->up = dir->i_ino; 335 fnode->up = cpu_to_le32(dir->i_ino);
336 hpfs_set_ea(result, fnode, "SYMLINK", symlink, strlen(symlink)); 336 hpfs_set_ea(result, fnode, "SYMLINK", symlink, strlen(symlink));
337 mark_buffer_dirty(bh); 337 mark_buffer_dirty(bh);
338 brelse(bh); 338 brelse(bh);
@@ -382,7 +382,7 @@ again:
382 if (de->directory) 382 if (de->directory)
383 goto out1; 383 goto out1;
384 384
385 fno = de->fnode; 385 fno = le32_to_cpu(de->fnode);
386 r = hpfs_remove_dirent(dir, dno, de, &qbh, 1); 386 r = hpfs_remove_dirent(dir, dno, de, &qbh, 1);
387 switch (r) { 387 switch (r) {
388 case 1: 388 case 1:
@@ -465,7 +465,7 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
465 if (n_items) 465 if (n_items)
466 goto out1; 466 goto out1;
467 467
468 fno = de->fnode; 468 fno = le32_to_cpu(de->fnode);
469 r = hpfs_remove_dirent(dir, dno, de, &qbh, 1); 469 r = hpfs_remove_dirent(dir, dno, de, &qbh, 1);
470 switch (r) { 470 switch (r) {
471 case 1: 471 case 1:
@@ -608,7 +608,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
608 drop_nlink(old_dir); 608 drop_nlink(old_dir);
609 } 609 }
610 if ((fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) { 610 if ((fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) {
611 fnode->up = new_dir->i_ino; 611 fnode->up = cpu_to_le32(new_dir->i_ino);
612 fnode->len = new_len; 612 fnode->len = new_len;
613 memcpy(fnode->name, new_name, new_len>15?15:new_len); 613 memcpy(fnode->name, new_name, new_len>15?15:new_len);
614 if (new_len < 15) memset(&fnode->name[new_len], 0, 15 - new_len); 614 if (new_len < 15) memset(&fnode->name[new_len], 0, 15 - new_len);