Commit c4c99543 authored by Al Viro's avatar Al Viro

hpfs: get rid of bitfields in struct fnode

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 4085e155
...@@ -479,13 +479,13 @@ void hpfs_remove_fnode(struct super_block *s, fnode_secno fno) ...@@ -479,13 +479,13 @@ void hpfs_remove_fnode(struct super_block *s, fnode_secno fno)
struct extended_attribute *ea; struct extended_attribute *ea;
struct extended_attribute *ea_end; struct extended_attribute *ea_end;
if (!(fnode = hpfs_map_fnode(s, fno, &bh))) return; if (!(fnode = hpfs_map_fnode(s, fno, &bh))) return;
if (!fnode->dirflag) hpfs_remove_btree(s, &fnode->btree); if (!fnode_is_dir(fnode)) hpfs_remove_btree(s, &fnode->btree);
else hpfs_remove_dtree(s, le32_to_cpu(fnode->u.external[0].disk_secno)); else hpfs_remove_dtree(s, le32_to_cpu(fnode->u.external[0].disk_secno));
ea_end = fnode_end_ea(fnode); ea_end = fnode_end_ea(fnode);
for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea))
if (ea_indirect(ea)) if (ea_indirect(ea))
hpfs_ea_remove(s, ea_sec(ea), ea_in_anode(ea), ea_len(ea)); hpfs_ea_remove(s, ea_sec(ea), ea_in_anode(ea), ea_len(ea));
hpfs_ea_ext_remove(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l)); hpfs_ea_ext_remove(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l));
brelse(bh); brelse(bh);
hpfs_free_sectors(s, fno, 1); hpfs_free_sectors(s, fno, 1);
} }
...@@ -87,7 +87,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -87,7 +87,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
ret = -EIOERROR; ret = -EIOERROR;
goto out; goto out;
} }
if (!fno->dirflag) { if (!fnode_is_dir(fno)) {
e = 1; e = 1;
hpfs_error(inode->i_sb, "not a directory, fnode %08lx", hpfs_error(inode->i_sb, "not a directory, fnode %08lx",
(unsigned long)inode->i_ino); (unsigned long)inode->i_ino);
......
...@@ -1015,7 +1015,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, ...@@ -1015,7 +1015,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno,
kfree(name2); kfree(name2);
return NULL; return NULL;
} }
if (!upf->dirflag) { if (!fnode_is_dir(upf)) {
brelse(bh); brelse(bh);
hpfs_error(s, "fnode %08x has non-directory parent %08x", fno, le32_to_cpu(f->up)); hpfs_error(s, "fnode %08x has non-directory parent %08x", fno, le32_to_cpu(f->up));
kfree(name2); kfree(name2);
......
...@@ -91,7 +91,7 @@ int hpfs_read_ea(struct super_block *s, struct fnode *fnode, char *key, ...@@ -91,7 +91,7 @@ int hpfs_read_ea(struct super_block *s, struct fnode *fnode, char *key,
} }
a = le32_to_cpu(fnode->ea_secno); a = le32_to_cpu(fnode->ea_secno);
len = le32_to_cpu(fnode->ea_size_l); len = le32_to_cpu(fnode->ea_size_l);
ano = fnode->ea_anode; ano = fnode_in_anode(fnode);
pos = 0; pos = 0;
while (pos < len) { while (pos < len) {
ea = (struct extended_attribute *)ex; ea = (struct extended_attribute *)ex;
...@@ -148,7 +148,7 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si ...@@ -148,7 +148,7 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si
} }
a = le32_to_cpu(fnode->ea_secno); a = le32_to_cpu(fnode->ea_secno);
len = le32_to_cpu(fnode->ea_size_l); len = le32_to_cpu(fnode->ea_size_l);
ano = fnode->ea_anode; ano = fnode_in_anode(fnode);
pos = 0; pos = 0;
while (pos < len) { while (pos < len) {
char ex[4 + 255 + 1 + 8]; char ex[4 + 255 + 1 + 8];
...@@ -209,7 +209,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, ...@@ -209,7 +209,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
} }
a = le32_to_cpu(fnode->ea_secno); a = le32_to_cpu(fnode->ea_secno);
len = le32_to_cpu(fnode->ea_size_l); len = le32_to_cpu(fnode->ea_size_l);
ano = fnode->ea_anode; ano = fnode_in_anode(fnode);
pos = 0; pos = 0;
while (pos < len) { while (pos < len) {
char ex[4 + 255 + 1 + 8]; char ex[4 + 255 + 1 + 8];
...@@ -276,7 +276,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, ...@@ -276,7 +276,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
fnode->ea_size_l = cpu_to_le32(le16_to_cpu(fnode->ea_size_s)); fnode->ea_size_l = cpu_to_le32(le16_to_cpu(fnode->ea_size_s));
fnode->ea_size_s = cpu_to_le16(0); fnode->ea_size_s = cpu_to_le16(0);
fnode->ea_secno = cpu_to_le32(n); fnode->ea_secno = cpu_to_le32(n);
fnode->ea_anode = cpu_to_le32(0); fnode->flags &= ~FNODE_anode;
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
brelse(bh); brelse(bh);
} }
...@@ -288,9 +288,9 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, ...@@ -288,9 +288,9 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
secno q = hpfs_alloc_sector(s, fno, 1, 0); secno q = hpfs_alloc_sector(s, fno, 1, 0);
if (!q) goto bail; if (!q) goto bail;
fnode->ea_secno = cpu_to_le32(q); fnode->ea_secno = cpu_to_le32(q);
fnode->ea_anode = 0; fnode->flags &= ~FNODE_anode;
len++; len++;
} else if (!fnode->ea_anode) { } else if (!fnode_in_anode(fnode)) {
if (hpfs_alloc_if_possible(s, le32_to_cpu(fnode->ea_secno) + len)) { if (hpfs_alloc_if_possible(s, le32_to_cpu(fnode->ea_secno) + len)) {
len++; len++;
} else { } else {
...@@ -310,7 +310,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, ...@@ -310,7 +310,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
anode->u.external[0].length = cpu_to_le32(len); anode->u.external[0].length = cpu_to_le32(len);
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
brelse(bh); brelse(bh);
fnode->ea_anode = 1; fnode->flags |= FNODE_anode;
fnode->ea_secno = cpu_to_le32(a_s);*/ fnode->ea_secno = cpu_to_le32(a_s);*/
secno new_sec; secno new_sec;
int i; int i;
...@@ -338,7 +338,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, ...@@ -338,7 +338,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
len = (pos + 511) >> 9; len = (pos + 511) >> 9;
} }
} }
if (fnode->ea_anode) { if (fnode_in_anode(fnode)) {
if (hpfs_add_sector_to_btree(s, le32_to_cpu(fnode->ea_secno), if (hpfs_add_sector_to_btree(s, le32_to_cpu(fnode->ea_secno),
0, len) != -1) { 0, len) != -1) {
len++; len++;
...@@ -351,16 +351,16 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, ...@@ -351,16 +351,16 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
h[1] = strlen(key); h[1] = strlen(key);
h[2] = size & 0xff; h[2] = size & 0xff;
h[3] = size >> 8; h[3] = size >> 8;
if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l), 4, h)) goto bail; if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l), 4, h)) goto bail;
if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l) + 4, h[1] + 1, key)) goto bail; if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l) + 4, h[1] + 1, key)) goto bail;
if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l) + 5 + h[1], size, data)) goto bail; if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l) + 5 + h[1], size, data)) goto bail;
fnode->ea_size_l = cpu_to_le32(pos); fnode->ea_size_l = cpu_to_le32(pos);
ret: ret:
hpfs_i(inode)->i_ea_size += 5 + strlen(key) + size; hpfs_i(inode)->i_ea_size += 5 + strlen(key) + size;
return; return;
bail: bail:
if (le32_to_cpu(fnode->ea_secno)) if (le32_to_cpu(fnode->ea_secno))
if (fnode->ea_anode) hpfs_truncate_btree(s, le32_to_cpu(fnode->ea_secno), 1, (le32_to_cpu(fnode->ea_size_l) + 511) >> 9); if (fnode_in_anode(fnode)) hpfs_truncate_btree(s, le32_to_cpu(fnode->ea_secno), 1, (le32_to_cpu(fnode->ea_size_l) + 511) >> 9);
else hpfs_free_sectors(s, le32_to_cpu(fnode->ea_secno) + ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9), len - ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9)); else hpfs_free_sectors(s, le32_to_cpu(fnode->ea_secno) + ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9), len - ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9));
else fnode->ea_secno = fnode->ea_size_l = cpu_to_le32(0); else fnode->ea_secno = fnode->ea_size_l = cpu_to_le32(0);
} }
......
...@@ -436,6 +436,7 @@ struct bplus_header ...@@ -436,6 +436,7 @@ struct bplus_header
#define FNODE_MAGIC 0xf7e40aae #define FNODE_MAGIC 0xf7e40aae
enum {FNODE_anode = cpu_to_le16(2), FNODE_dir = cpu_to_le16(256)};
struct fnode struct fnode
{ {
u32 magic; /* f7e4 0aae */ u32 magic; /* f7e4 0aae */
...@@ -451,26 +452,9 @@ struct fnode ...@@ -451,26 +452,9 @@ struct fnode
secno ea_secno; /* first sector of disk-resident ea's*/ secno ea_secno; /* first sector of disk-resident ea's*/
u16 ea_size_s; /* length of fnode-resident ea's */ u16 ea_size_s; /* length of fnode-resident ea's */
#ifdef __LITTLE_ENDIAN __le16 flags; /* bit 1 set -> ea_secno is an anode */
u8 flag0: 1; /* bit 8 set -> directory. first & only extent
u8 ea_anode: 1; /* 1 -> ea_secno is an anode */
u8 flag234567: 6;
#else
u8 flag234567: 6;
u8 ea_anode: 1; /* 1 -> ea_secno is an anode */
u8 flag0: 1;
#endif
#ifdef __LITTLE_ENDIAN
u8 dirflag: 1; /* 1 -> directory. first & only extent
points to dnode. */
u8 flag9012345: 7;
#else
u8 flag9012345: 7;
u8 dirflag: 1; /* 1 -> directory. first & only extent
points to dnode. */ points to dnode. */
#endif
struct bplus_header btree; /* b+ tree, 8 extents or 12 subtrees */ struct bplus_header btree; /* b+ tree, 8 extents or 12 subtrees */
union { union {
struct bplus_leaf_node external[8]; struct bplus_leaf_node external[8];
...@@ -492,6 +476,16 @@ struct fnode ...@@ -492,6 +476,16 @@ struct fnode
via fnode + ea_offs. I think.) */ via fnode + ea_offs. I think.) */
}; };
static inline bool fnode_in_anode(struct fnode *p)
{
return (p->flags & FNODE_anode) != 0;
}
static inline bool fnode_is_dir(struct fnode *p)
{
return (p->flags & FNODE_dir) != 0;
}
/* anode: 99.44% pure allocation tree */ /* anode: 99.44% pure allocation tree */
......
...@@ -110,7 +110,7 @@ void hpfs_read_inode(struct inode *i) ...@@ -110,7 +110,7 @@ void hpfs_read_inode(struct inode *i)
} }
} }
} }
if (fnode->dirflag) { if (fnode_is_dir(fnode)) {
int n_dnodes, n_subdirs; int n_dnodes, n_subdirs;
i->i_mode |= S_IFDIR; i->i_mode |= S_IFDIR;
i->i_op = &hpfs_dir_iops; i->i_op = &hpfs_dir_iops;
......
...@@ -130,7 +130,7 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea ...@@ -130,7 +130,7 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea
(unsigned long)ino); (unsigned long)ino);
goto bail; goto bail;
} }
if (!fnode->dirflag) { if (!fnode_is_dir(fnode)) {
if ((unsigned)fnode->btree.n_used_nodes + (unsigned)fnode->btree.n_free_nodes != if ((unsigned)fnode->btree.n_used_nodes + (unsigned)fnode->btree.n_free_nodes !=
(fnode->btree.internal ? 12 : 8)) { (fnode->btree.internal ? 12 : 8)) {
hpfs_error(s, hpfs_error(s,
......
...@@ -70,7 +70,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -70,7 +70,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
fnode->len = len; fnode->len = len;
memcpy(fnode->name, name, len > 15 ? 15 : len); memcpy(fnode->name, name, len > 15 ? 15 : len);
fnode->up = cpu_to_le32(dir->i_ino); fnode->up = cpu_to_le32(dir->i_ino);
fnode->dirflag = 1; fnode->flags |= FNODE_dir;
fnode->btree.n_free_nodes = 7; fnode->btree.n_free_nodes = 7;
fnode->btree.n_used_nodes = 1; fnode->btree.n_used_nodes = 1;
fnode->btree.first_free = cpu_to_le16(0x14); fnode->btree.first_free = cpu_to_le16(0x14);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment