diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-04-06 13:21:09 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-05-29 23:28:36 -0400 |
commit | 4085e155b14a89ee36f7bfc5bd07294b0c34b0e6 (patch) | |
tree | cf654d15d2a7cfd7c6e329f957665c2cecc3ccd4 /fs/hpfs | |
parent | 185553b22436fe754f4ae8ec11344e822bb83717 (diff) |
hpfs: get rid of bitfields endianness wanking in extended_attribute
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/hpfs')
-rw-r--r-- | fs/hpfs/anode.c | 4 | ||||
-rw-r--r-- | fs/hpfs/ea.c | 34 | ||||
-rw-r--r-- | fs/hpfs/hpfs.h | 31 |
3 files changed, 35 insertions, 34 deletions
diff --git a/fs/hpfs/anode.c b/fs/hpfs/anode.c index 08b503e8ed29..3cb4d9c3eca4 100644 --- a/fs/hpfs/anode.c +++ b/fs/hpfs/anode.c | |||
@@ -483,8 +483,8 @@ void hpfs_remove_fnode(struct super_block *s, fnode_secno fno) | |||
483 | else hpfs_remove_dtree(s, le32_to_cpu(fnode->u.external[0].disk_secno)); | 483 | else hpfs_remove_dtree(s, le32_to_cpu(fnode->u.external[0].disk_secno)); |
484 | ea_end = fnode_end_ea(fnode); | 484 | ea_end = fnode_end_ea(fnode); |
485 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) | 485 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) |
486 | if (ea->indirect) | 486 | if (ea_indirect(ea)) |
487 | hpfs_ea_remove(s, ea_sec(ea), ea->anode, ea_len(ea)); | 487 | hpfs_ea_remove(s, ea_sec(ea), ea_in_anode(ea), ea_len(ea)); |
488 | hpfs_ea_ext_remove(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l)); | 488 | hpfs_ea_ext_remove(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l)); |
489 | brelse(bh); | 489 | brelse(bh); |
490 | hpfs_free_sectors(s, fno, 1); | 490 | hpfs_free_sectors(s, fno, 1); |
diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c index cd098e3eb0e6..7cd0092771f4 100644 --- a/fs/hpfs/ea.c +++ b/fs/hpfs/ea.c | |||
@@ -23,15 +23,15 @@ void hpfs_ea_ext_remove(struct super_block *s, secno a, int ano, unsigned len) | |||
23 | return; | 23 | return; |
24 | } | 24 | } |
25 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return; | 25 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return; |
26 | if (ea->indirect) { | 26 | if (ea_indirect(ea)) { |
27 | if (ea_valuelen(ea) != 8) { | 27 | if (ea_valuelen(ea) != 8) { |
28 | hpfs_error(s, "ea->indirect set while ea->valuelen!=8, %s %08x, pos %08x", | 28 | hpfs_error(s, "ea_indirect(ea) set while ea->valuelen!=8, %s %08x, pos %08x", |
29 | ano ? "anode" : "sectors", a, pos); | 29 | ano ? "anode" : "sectors", a, pos); |
30 | return; | 30 | return; |
31 | } | 31 | } |
32 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 9, ex+4)) | 32 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 9, ex+4)) |
33 | return; | 33 | return; |
34 | hpfs_ea_remove(s, ea_sec(ea), ea->anode, ea_len(ea)); | 34 | hpfs_ea_remove(s, ea_sec(ea), ea_in_anode(ea), ea_len(ea)); |
35 | } | 35 | } |
36 | pos += ea->namelen + ea_valuelen(ea) + 5; | 36 | pos += ea->namelen + ea_valuelen(ea) + 5; |
37 | } | 37 | } |
@@ -81,7 +81,7 @@ int hpfs_read_ea(struct super_block *s, struct fnode *fnode, char *key, | |||
81 | struct extended_attribute *ea_end = fnode_end_ea(fnode); | 81 | struct extended_attribute *ea_end = fnode_end_ea(fnode); |
82 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) | 82 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) |
83 | if (!strcmp(ea->name, key)) { | 83 | if (!strcmp(ea->name, key)) { |
84 | if (ea->indirect) | 84 | if (ea_indirect(ea)) |
85 | goto indirect; | 85 | goto indirect; |
86 | if (ea_valuelen(ea) >= size) | 86 | if (ea_valuelen(ea) >= size) |
87 | return -EINVAL; | 87 | return -EINVAL; |
@@ -101,10 +101,10 @@ int hpfs_read_ea(struct super_block *s, struct fnode *fnode, char *key, | |||
101 | return -EIO; | 101 | return -EIO; |
102 | } | 102 | } |
103 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return -EIO; | 103 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return -EIO; |
104 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea->indirect ? 8 : 0), ex + 4)) | 104 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea_indirect(ea) ? 8 : 0), ex + 4)) |
105 | return -EIO; | 105 | return -EIO; |
106 | if (!strcmp(ea->name, key)) { | 106 | if (!strcmp(ea->name, key)) { |
107 | if (ea->indirect) | 107 | if (ea_indirect(ea)) |
108 | goto indirect; | 108 | goto indirect; |
109 | if (ea_valuelen(ea) >= size) | 109 | if (ea_valuelen(ea) >= size) |
110 | return -EINVAL; | 110 | return -EINVAL; |
@@ -119,7 +119,7 @@ int hpfs_read_ea(struct super_block *s, struct fnode *fnode, char *key, | |||
119 | indirect: | 119 | indirect: |
120 | if (ea_len(ea) >= size) | 120 | if (ea_len(ea) >= size) |
121 | return -EINVAL; | 121 | return -EINVAL; |
122 | if (hpfs_ea_read(s, ea_sec(ea), ea->anode, 0, ea_len(ea), buf)) | 122 | if (hpfs_ea_read(s, ea_sec(ea), ea_in_anode(ea), 0, ea_len(ea), buf)) |
123 | return -EIO; | 123 | return -EIO; |
124 | buf[ea_len(ea)] = 0; | 124 | buf[ea_len(ea)] = 0; |
125 | return 0; | 125 | return 0; |
@@ -136,8 +136,8 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si | |||
136 | struct extended_attribute *ea_end = fnode_end_ea(fnode); | 136 | struct extended_attribute *ea_end = fnode_end_ea(fnode); |
137 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) | 137 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) |
138 | if (!strcmp(ea->name, key)) { | 138 | if (!strcmp(ea->name, key)) { |
139 | if (ea->indirect) | 139 | if (ea_indirect(ea)) |
140 | return get_indirect_ea(s, ea->anode, ea_sec(ea), *size = ea_len(ea)); | 140 | return get_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), *size = ea_len(ea)); |
141 | if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { | 141 | if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { |
142 | printk("HPFS: out of memory for EA\n"); | 142 | printk("HPFS: out of memory for EA\n"); |
143 | return NULL; | 143 | return NULL; |
@@ -159,11 +159,11 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si | |||
159 | return NULL; | 159 | return NULL; |
160 | } | 160 | } |
161 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return NULL; | 161 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return NULL; |
162 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea->indirect ? 8 : 0), ex + 4)) | 162 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea_indirect(ea) ? 8 : 0), ex + 4)) |
163 | return NULL; | 163 | return NULL; |
164 | if (!strcmp(ea->name, key)) { | 164 | if (!strcmp(ea->name, key)) { |
165 | if (ea->indirect) | 165 | if (ea_indirect(ea)) |
166 | return get_indirect_ea(s, ea->anode, ea_sec(ea), *size = ea_len(ea)); | 166 | return get_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), *size = ea_len(ea)); |
167 | if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { | 167 | if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { |
168 | printk("HPFS: out of memory for EA\n"); | 168 | printk("HPFS: out of memory for EA\n"); |
169 | return NULL; | 169 | return NULL; |
@@ -199,9 +199,9 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
199 | struct extended_attribute *ea_end = fnode_end_ea(fnode); | 199 | struct extended_attribute *ea_end = fnode_end_ea(fnode); |
200 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) | 200 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) |
201 | if (!strcmp(ea->name, key)) { | 201 | if (!strcmp(ea->name, key)) { |
202 | if (ea->indirect) { | 202 | if (ea_indirect(ea)) { |
203 | if (ea_len(ea) == size) | 203 | if (ea_len(ea) == size) |
204 | set_indirect_ea(s, ea->anode, ea_sec(ea), data, size); | 204 | set_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), data, size); |
205 | } else if (ea_valuelen(ea) == size) { | 205 | } else if (ea_valuelen(ea) == size) { |
206 | memcpy(ea_data(ea), data, size); | 206 | memcpy(ea_data(ea), data, size); |
207 | } | 207 | } |
@@ -220,12 +220,12 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
220 | return; | 220 | return; |
221 | } | 221 | } |
222 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return; | 222 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return; |
223 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea->indirect ? 8 : 0), ex + 4)) | 223 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea_indirect(ea) ? 8 : 0), ex + 4)) |
224 | return; | 224 | return; |
225 | if (!strcmp(ea->name, key)) { | 225 | if (!strcmp(ea->name, key)) { |
226 | if (ea->indirect) { | 226 | if (ea_indirect(ea)) { |
227 | if (ea_len(ea) == size) | 227 | if (ea_len(ea) == size) |
228 | set_indirect_ea(s, ea->anode, ea_sec(ea), data, size); | 228 | set_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), data, size); |
229 | } | 229 | } |
230 | else { | 230 | else { |
231 | if (ea_valuelen(ea) == size) | 231 | if (ea_valuelen(ea) == size) |
diff --git a/fs/hpfs/hpfs.h b/fs/hpfs/hpfs.h index 8b0650aae328..ca90bde6564c 100644 --- a/fs/hpfs/hpfs.h +++ b/fs/hpfs/hpfs.h | |||
@@ -528,32 +528,23 @@ struct anode | |||
528 | run, or in multiple runs. Flags in the fnode tell whether the EA list | 528 | run, or in multiple runs. Flags in the fnode tell whether the EA list |
529 | is immediate, in a single run, or in multiple runs. */ | 529 | is immediate, in a single run, or in multiple runs. */ |
530 | 530 | ||
531 | enum {EA_indirect = 1, EA_anode = 2, EA_needea = 128 }; | ||
531 | struct extended_attribute | 532 | struct extended_attribute |
532 | { | 533 | { |
533 | #ifdef __LITTLE_ENDIAN | 534 | u8 flags; /* bit 0 set -> value gives sector number |
534 | u8 indirect: 1; /* 1 -> value gives sector number | ||
535 | where real value starts */ | 535 | where real value starts */ |
536 | u8 anode: 1; /* 1 -> sector is an anode | 536 | /* bit 1 set -> sector is an anode |
537 | that points to fragmented value */ | ||
538 | u8 flag23456: 5; | ||
539 | u8 needea: 1; /* required ea */ | ||
540 | #else | ||
541 | u8 needea: 1; /* required ea */ | ||
542 | u8 flag23456: 5; | ||
543 | u8 anode: 1; /* 1 -> sector is an anode | ||
544 | that points to fragmented value */ | 537 | that points to fragmented value */ |
545 | u8 indirect: 1; /* 1 -> value gives sector number | 538 | /* bit 7 set -> required ea */ |
546 | where real value starts */ | ||
547 | #endif | ||
548 | u8 namelen; /* length of name, bytes */ | 539 | u8 namelen; /* length of name, bytes */ |
549 | u8 valuelen_lo; /* length of value, bytes */ | 540 | u8 valuelen_lo; /* length of value, bytes */ |
550 | u8 valuelen_hi; /* length of value, bytes */ | 541 | u8 valuelen_hi; /* length of value, bytes */ |
551 | u8 name[0]; | 542 | u8 name[]; |
552 | /* | 543 | /* |
553 | u8 name[namelen]; ascii attrib name | 544 | u8 name[namelen]; ascii attrib name |
554 | u8 nul; terminating '\0', not counted | 545 | u8 nul; terminating '\0', not counted |
555 | u8 value[valuelen]; value, arbitrary | 546 | u8 value[valuelen]; value, arbitrary |
556 | if this.indirect, valuelen is 8 and the value is | 547 | if this.flags & 1, valuelen is 8 and the value is |
557 | u32 length; real length of value, bytes | 548 | u32 length; real length of value, bytes |
558 | secno secno; sector address where it starts | 549 | secno secno; sector address where it starts |
559 | if this.anode, the above sector number is the root of an anode tree | 550 | if this.anode, the above sector number is the root of an anode tree |
@@ -561,6 +552,16 @@ struct extended_attribute | |||
561 | */ | 552 | */ |
562 | }; | 553 | }; |
563 | 554 | ||
555 | static inline bool ea_indirect(struct extended_attribute *ea) | ||
556 | { | ||
557 | return ea->flags & EA_indirect; | ||
558 | } | ||
559 | |||
560 | static inline bool ea_in_anode(struct extended_attribute *ea) | ||
561 | { | ||
562 | return ea->flags & EA_anode; | ||
563 | } | ||
564 | |||
564 | /* | 565 | /* |
565 | Local Variables: | 566 | Local Variables: |
566 | comment-column: 40 | 567 | comment-column: 40 |