Commit 40f51070 authored by Brian Gerst's avatar Brian Gerst Committed by Russell King

[PATCH] struct super_block cleanup - hpfs

Remove hpfs_sb from struct super_block.
parent 9709ae9f
...@@ -24,8 +24,8 @@ static int chk_if_allocated(struct super_block *s, secno sec, char *msg) ...@@ -24,8 +24,8 @@ static int chk_if_allocated(struct super_block *s, secno sec, char *msg)
goto fail1; goto fail1;
} }
hpfs_brelse4(&qbh); hpfs_brelse4(&qbh);
if (sec >= s->s_hpfs_dirband_start && sec < s->s_hpfs_dirband_start + s->s_hpfs_dirband_size) { if (sec >= hpfs_sb(s)->sb_dirband_start && sec < hpfs_sb(s)->sb_dirband_start + hpfs_sb(s)->sb_dirband_size) {
unsigned ssec = (sec - s->s_hpfs_dirband_start) / 4; unsigned ssec = (sec - hpfs_sb(s)->sb_dirband_start) / 4;
if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) goto fail; if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) goto fail;
if ((bmp[ssec >> 5] >> (ssec & 0x1f)) & 1) { if ((bmp[ssec >> 5] >> (ssec & 0x1f)) & 1) {
hpfs_error(s, "sector '%s' - %08x not allocated in directory bitmap", msg, sec); hpfs_error(s, "sector '%s' - %08x not allocated in directory bitmap", msg, sec);
...@@ -48,11 +48,11 @@ static int chk_if_allocated(struct super_block *s, secno sec, char *msg) ...@@ -48,11 +48,11 @@ static int chk_if_allocated(struct super_block *s, secno sec, char *msg)
int hpfs_chk_sectors(struct super_block *s, secno start, int len, char *msg) int hpfs_chk_sectors(struct super_block *s, secno start, int len, char *msg)
{ {
if (start + len < start || start < 0x12 || if (start + len < start || start < 0x12 ||
start + len > s->s_hpfs_fs_size) { start + len > hpfs_sb(s)->sb_fs_size) {
hpfs_error(s, "sector(s) '%s' badly placed at %08x", msg, start); hpfs_error(s, "sector(s) '%s' badly placed at %08x", msg, start);
return 1; return 1;
} }
if (s->s_hpfs_chk>=2) { if (hpfs_sb(s)->sb_chk>=2) {
int i; int i;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
if (chk_if_allocated(s, start + i, msg)) return 1; if (chk_if_allocated(s, start + i, msg)) return 1;
...@@ -127,7 +127,7 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne ...@@ -127,7 +127,7 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne
} }
rt: rt:
if (ret) { if (ret) {
if (s->s_hpfs_chk && ((ret >> 14) != (bs >> 14) || (bmp[(ret & 0x3fff) >> 5] | ~(((1 << n) - 1) << (ret & 0x1f))) != 0xffffffff)) { if (hpfs_sb(s)->sb_chk && ((ret >> 14) != (bs >> 14) || (bmp[(ret & 0x3fff) >> 5] | ~(((1 << n) - 1) << (ret & 0x1f))) != 0xffffffff)) {
hpfs_error(s, "Allocation doesn't work! Wanted %d, allocated at %08x", n, ret); hpfs_error(s, "Allocation doesn't work! Wanted %d, allocated at %08x", n, ret);
ret = 0; ret = 0;
goto b; goto b;
...@@ -155,14 +155,15 @@ secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forwa ...@@ -155,14 +155,15 @@ secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forwa
secno sec; secno sec;
unsigned i; unsigned i;
unsigned n_bmps; unsigned n_bmps;
int b = s->s_hpfs_c_bitmap; struct hpfs_sb_info *sbi = hpfs_sb(s);
int b = sbi->sb_c_bitmap;
int f_p = 0; int f_p = 0;
if (forward < 0) { if (forward < 0) {
forward = -forward; forward = -forward;
f_p = 1; f_p = 1;
} }
if (lock) hpfs_lock_creation(s); if (lock) hpfs_lock_creation(s);
if (near && near < s->s_hpfs_fs_size) if (near && near < sbi->sb_fs_size)
if ((sec = alloc_in_bmp(s, near, n, f_p ? forward : forward/4))) goto ret; if ((sec = alloc_in_bmp(s, near, n, f_p ? forward : forward/4))) goto ret;
if (b != -1) { if (b != -1) {
if ((sec = alloc_in_bmp(s, b<<14, n, f_p ? forward : forward/2))) { if ((sec = alloc_in_bmp(s, b<<14, n, f_p ? forward : forward/2))) {
...@@ -171,25 +172,25 @@ secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forwa ...@@ -171,25 +172,25 @@ secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forwa
} }
if (b > 0x10000000) if ((sec = alloc_in_bmp(s, (b&0xfffffff)<<14, n, f_p ? forward : 0))) goto ret; if (b > 0x10000000) if ((sec = alloc_in_bmp(s, (b&0xfffffff)<<14, n, f_p ? forward : 0))) goto ret;
} }
n_bmps = (s->s_hpfs_fs_size + 0x4000 - 1) >> 14; n_bmps = (sbi->sb_fs_size + 0x4000 - 1) >> 14;
for (i = 0; i < n_bmps / 2; i++) { for (i = 0; i < n_bmps / 2; i++) {
if ((sec = alloc_in_bmp(s, (n_bmps/2+i) << 14, n, forward))) { if ((sec = alloc_in_bmp(s, (n_bmps/2+i) << 14, n, forward))) {
s->s_hpfs_c_bitmap = n_bmps/2+i; sbi->sb_c_bitmap = n_bmps/2+i;
goto ret; goto ret;
} }
if ((sec = alloc_in_bmp(s, (n_bmps/2-i-1) << 14, n, forward))) { if ((sec = alloc_in_bmp(s, (n_bmps/2-i-1) << 14, n, forward))) {
s->s_hpfs_c_bitmap = n_bmps/2-i-1; sbi->sb_c_bitmap = n_bmps/2-i-1;
goto ret; goto ret;
} }
} }
if ((sec = alloc_in_bmp(s, (n_bmps-1) << 14, n, forward))) { if ((sec = alloc_in_bmp(s, (n_bmps-1) << 14, n, forward))) {
s->s_hpfs_c_bitmap = n_bmps-1; sbi->sb_c_bitmap = n_bmps-1;
goto ret; goto ret;
} }
if (!f_p) { if (!f_p) {
for (i = 0; i < n_bmps; i++) for (i = 0; i < n_bmps; i++)
if ((sec = alloc_in_bmp(s, i << 14, n, 0))) { if ((sec = alloc_in_bmp(s, i << 14, n, 0))) {
s->s_hpfs_c_bitmap = 0x10000000 + i; sbi->sb_c_bitmap = 0x10000000 + i;
goto ret; goto ret;
} }
} }
...@@ -212,17 +213,18 @@ static secno alloc_in_dirband(struct super_block *s, secno near, int lock) ...@@ -212,17 +213,18 @@ static secno alloc_in_dirband(struct super_block *s, secno near, int lock)
{ {
unsigned nr = near; unsigned nr = near;
secno sec; secno sec;
if (nr < s->s_hpfs_dirband_start) struct hpfs_sb_info *sbi = hpfs_sb(s);
nr = s->s_hpfs_dirband_start; if (nr < sbi->sb_dirband_start)
if (nr >= s->s_hpfs_dirband_start + s->s_hpfs_dirband_size) nr = sbi->sb_dirband_start;
nr = s->s_hpfs_dirband_start + s->s_hpfs_dirband_size - 4; if (nr >= sbi->sb_dirband_start + sbi->sb_dirband_size)
nr -= s->s_hpfs_dirband_start; nr = sbi->sb_dirband_start + sbi->sb_dirband_size - 4;
nr -= sbi->sb_dirband_start;
nr >>= 2; nr >>= 2;
if (lock) hpfs_lock_creation(s); if (lock) hpfs_lock_creation(s);
sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0); sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0);
if (lock) hpfs_unlock_creation(s); if (lock) hpfs_unlock_creation(s);
if (!sec) return 0; if (!sec) return 0;
return ((sec & 0x3fff) << 2) + s->s_hpfs_dirband_start; return ((sec & 0x3fff) << 2) + sbi->sb_dirband_start;
} }
/* Alloc sector if it's free */ /* Alloc sector if it's free */
...@@ -303,8 +305,8 @@ void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) ...@@ -303,8 +305,8 @@ void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n)
int hpfs_check_free_dnodes(struct super_block *s, int n) int hpfs_check_free_dnodes(struct super_block *s, int n)
{ {
int n_bmps = (s->s_hpfs_fs_size + 0x4000 - 1) >> 14; int n_bmps = (hpfs_sb(s)->sb_fs_size + 0x4000 - 1) >> 14;
int b = s->s_hpfs_c_bitmap & 0x0fffffff; int b = hpfs_sb(s)->sb_c_bitmap & 0x0fffffff;
int i, j; int i, j;
unsigned *bmp; unsigned *bmp;
struct quad_buffer_head qbh; struct quad_buffer_head qbh;
...@@ -320,7 +322,7 @@ int hpfs_check_free_dnodes(struct super_block *s, int n) ...@@ -320,7 +322,7 @@ int hpfs_check_free_dnodes(struct super_block *s, int n)
} }
hpfs_brelse4(&qbh); hpfs_brelse4(&qbh);
i = 0; i = 0;
if (s->s_hpfs_c_bitmap != -1 ) { if (hpfs_sb(s)->sb_c_bitmap != -1 ) {
bmp = hpfs_map_bitmap(s, b, &qbh, "chkdn1"); bmp = hpfs_map_bitmap(s, b, &qbh, "chkdn1");
goto chk_bmp; goto chk_bmp;
} }
...@@ -349,17 +351,17 @@ int hpfs_check_free_dnodes(struct super_block *s, int n) ...@@ -349,17 +351,17 @@ int hpfs_check_free_dnodes(struct super_block *s, int n)
void hpfs_free_dnode(struct super_block *s, dnode_secno dno) void hpfs_free_dnode(struct super_block *s, dnode_secno dno)
{ {
if (s->s_hpfs_chk) if (dno & 3) { if (hpfs_sb(s)->sb_chk) if (dno & 3) {
hpfs_error(s, "hpfs_free_dnode: dnode %08x not aligned", dno); hpfs_error(s, "hpfs_free_dnode: dnode %08x not aligned", dno);
return; return;
} }
if (dno < s->s_hpfs_dirband_start || if (dno < hpfs_sb(s)->sb_dirband_start ||
dno >= s->s_hpfs_dirband_start + s->s_hpfs_dirband_size) { dno >= hpfs_sb(s)->sb_dirband_start + hpfs_sb(s)->sb_dirband_size) {
hpfs_free_sectors(s, dno, 4); hpfs_free_sectors(s, dno, 4);
} else { } else {
struct quad_buffer_head qbh; struct quad_buffer_head qbh;
unsigned *bmp; unsigned *bmp;
unsigned ssec = (dno - s->s_hpfs_dirband_start) / 4; unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4;
lock_super(s); lock_super(s);
if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) {
unlock_super(s); unlock_super(s);
...@@ -377,7 +379,7 @@ struct dnode *hpfs_alloc_dnode(struct super_block *s, secno near, ...@@ -377,7 +379,7 @@ struct dnode *hpfs_alloc_dnode(struct super_block *s, secno near,
int lock) int lock)
{ {
struct dnode *d; struct dnode *d;
if (hpfs_count_one_bitmap(s, s->s_hpfs_dmap) > FREE_DNODES_ADD) { if (hpfs_count_one_bitmap(s, hpfs_sb(s)->sb_dmap) > FREE_DNODES_ADD) {
if (!(*dno = alloc_in_dirband(s, near, lock))) if (!(*dno = alloc_in_dirband(s, near, lock)))
if (!(*dno = hpfs_alloc_sector(s, near, 4, 0, lock))) return NULL; if (!(*dno = hpfs_alloc_sector(s, near, 4, 0, lock))) return NULL;
} else { } else {
......
...@@ -20,7 +20,7 @@ secno hpfs_bplus_lookup(struct super_block *s, struct inode *inode, ...@@ -20,7 +20,7 @@ secno hpfs_bplus_lookup(struct super_block *s, struct inode *inode,
int i; int i;
int c1, c2 = 0; int c1, c2 = 0;
go_down: go_down:
if (s->s_hpfs_chk) if (hpfs_stop_cycles(s, a, &c1, &c2, "hpfs_bplus_lookup")) return -1; if (hpfs_sb(s)->sb_chk) if (hpfs_stop_cycles(s, a, &c1, &c2, "hpfs_bplus_lookup")) return -1;
if (btree->internal) { if (btree->internal) {
for (i = 0; i < btree->n_used_nodes; i++) for (i = 0; i < btree->n_used_nodes; i++)
if (btree->u.internal[i].file_secno > sec) { if (btree->u.internal[i].file_secno > sec) {
...@@ -38,7 +38,7 @@ secno hpfs_bplus_lookup(struct super_block *s, struct inode *inode, ...@@ -38,7 +38,7 @@ secno hpfs_bplus_lookup(struct super_block *s, struct inode *inode,
if (btree->u.external[i].file_secno <= sec && if (btree->u.external[i].file_secno <= sec &&
btree->u.external[i].file_secno + btree->u.external[i].length > sec) { btree->u.external[i].file_secno + btree->u.external[i].length > sec) {
a = btree->u.external[i].disk_secno + sec - btree->u.external[i].file_secno; a = btree->u.external[i].disk_secno + sec - btree->u.external[i].file_secno;
if (s->s_hpfs_chk) if (hpfs_chk_sectors(s, a, 1, "data")) { if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, a, 1, "data")) {
brelse(bh); brelse(bh);
return -1; return -1;
} }
...@@ -88,7 +88,7 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi ...@@ -88,7 +88,7 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
btree->u.internal[n].file_secno = -1; btree->u.internal[n].file_secno = -1;
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
brelse(bh); brelse(bh);
if (s->s_hpfs_chk) if (hpfs_sb(s)->sb_chk)
if (hpfs_stop_cycles(s, a, &c1, &c2, "hpfs_add_sector_to_btree #1")) return -1; if (hpfs_stop_cycles(s, a, &c1, &c2, "hpfs_add_sector_to_btree #1")) return -1;
if (!(anode = hpfs_map_anode(s, a, &bh))) return -1; if (!(anode = hpfs_map_anode(s, a, &bh))) return -1;
btree = &anode->btree; btree = &anode->btree;
...@@ -164,7 +164,7 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi ...@@ -164,7 +164,7 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
c2 = 0; c2 = 0;
while (up != -1) { while (up != -1) {
struct anode *new_anode; struct anode *new_anode;
if (s->s_hpfs_chk) if (hpfs_sb(s)->sb_chk)
if (hpfs_stop_cycles(s, up, &c1, &c2, "hpfs_add_sector_to_btree #2")) return -1; if (hpfs_stop_cycles(s, up, &c1, &c2, "hpfs_add_sector_to_btree #2")) return -1;
if (up != node || !fnod) { if (up != node || !fnod) {
if (!(anode = hpfs_map_anode(s, up, &bh))) return -1; if (!(anode = hpfs_map_anode(s, up, &bh))) return -1;
...@@ -283,7 +283,7 @@ void hpfs_remove_btree(struct super_block *s, struct bplus_header *btree) ...@@ -283,7 +283,7 @@ void hpfs_remove_btree(struct super_block *s, struct bplus_header *btree)
while (btree1->internal) { while (btree1->internal) {
ano = btree1->u.internal[pos].down; ano = btree1->u.internal[pos].down;
if (level) brelse(bh); if (level) brelse(bh);
if (s->s_hpfs_chk) if (hpfs_sb(s)->sb_chk)
if (hpfs_stop_cycles(s, ano, &d1, &d2, "hpfs_remove_btree #1")) if (hpfs_stop_cycles(s, ano, &d1, &d2, "hpfs_remove_btree #1"))
return; return;
if (!(anode = hpfs_map_anode(s, ano, &bh))) return; if (!(anode = hpfs_map_anode(s, ano, &bh))) return;
...@@ -296,7 +296,7 @@ void hpfs_remove_btree(struct super_block *s, struct bplus_header *btree) ...@@ -296,7 +296,7 @@ void hpfs_remove_btree(struct super_block *s, struct bplus_header *btree)
go_up: go_up:
if (!level) return; if (!level) return;
brelse(bh); brelse(bh);
if (s->s_hpfs_chk) if (hpfs_sb(s)->sb_chk)
if (hpfs_stop_cycles(s, ano, &c1, &c2, "hpfs_remove_btree #2")) return; if (hpfs_stop_cycles(s, ano, &c1, &c2, "hpfs_remove_btree #2")) return;
hpfs_free_sectors(s, ano, 1); hpfs_free_sectors(s, ano, 1);
oano = ano; oano = ano;
...@@ -343,7 +343,7 @@ int hpfs_ea_read(struct super_block *s, secno a, int ano, unsigned pos, ...@@ -343,7 +343,7 @@ int hpfs_ea_read(struct super_block *s, secno a, int ano, unsigned pos,
if ((sec = anode_lookup(s, a, pos >> 9)) == -1) if ((sec = anode_lookup(s, a, pos >> 9)) == -1)
return -1; return -1;
} else sec = a + (pos >> 9); } else sec = a + (pos >> 9);
if (s->s_hpfs_chk) if (hpfs_chk_sectors(s, sec, 1, "ea #1")) return -1; if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, sec, 1, "ea #1")) return -1;
if (!(data = hpfs_map_sector(s, sec, &bh, (len - 1) >> 9))) if (!(data = hpfs_map_sector(s, sec, &bh, (len - 1) >> 9)))
return -1; return -1;
l = 0x200 - (pos & 0x1ff); if (l > len) l = len; l = 0x200 - (pos & 0x1ff); if (l > len) l = len;
...@@ -366,7 +366,7 @@ int hpfs_ea_write(struct super_block *s, secno a, int ano, unsigned pos, ...@@ -366,7 +366,7 @@ int hpfs_ea_write(struct super_block *s, secno a, int ano, unsigned pos,
if ((sec = anode_lookup(s, a, pos >> 9)) == -1) if ((sec = anode_lookup(s, a, pos >> 9)) == -1)
return -1; return -1;
} else sec = a + (pos >> 9); } else sec = a + (pos >> 9);
if (s->s_hpfs_chk) if (hpfs_chk_sectors(s, sec, 1, "ea #2")) return -1; if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, sec, 1, "ea #2")) return -1;
if (!(data = hpfs_map_sector(s, sec, &bh, (len - 1) >> 9))) if (!(data = hpfs_map_sector(s, sec, &bh, (len - 1) >> 9)))
return -1; return -1;
l = 0x200 - (pos & 0x1ff); if (l > len) l = len; l = 0x200 - (pos & 0x1ff); if (l > len) l = len;
...@@ -440,7 +440,7 @@ void hpfs_truncate_btree(struct super_block *s, secno f, int fno, unsigned secs) ...@@ -440,7 +440,7 @@ void hpfs_truncate_btree(struct super_block *s, secno f, int fno, unsigned secs)
} }
node = btree->u.internal[i].down; node = btree->u.internal[i].down;
brelse(bh); brelse(bh);
if (s->s_hpfs_chk) if (hpfs_sb(s)->sb_chk)
if (hpfs_stop_cycles(s, node, &c1, &c2, "hpfs_truncate_btree")) if (hpfs_stop_cycles(s, node, &c1, &c2, "hpfs_truncate_btree"))
return; return;
if (!(anode = hpfs_map_anode(s, node, &bh))) return; if (!(anode = hpfs_map_anode(s, node, &bh))) return;
......
...@@ -15,7 +15,7 @@ void hpfs_lock_creation(struct super_block *s) ...@@ -15,7 +15,7 @@ void hpfs_lock_creation(struct super_block *s)
#ifdef DEBUG_LOCKS #ifdef DEBUG_LOCKS
printk("lock creation\n"); printk("lock creation\n");
#endif #endif
down(&s->u.hpfs_sb.hpfs_creation_de); down(&hpfs_sb(s)->hpfs_creation_de);
} }
void hpfs_unlock_creation(struct super_block *s) void hpfs_unlock_creation(struct super_block *s)
...@@ -23,7 +23,7 @@ void hpfs_unlock_creation(struct super_block *s) ...@@ -23,7 +23,7 @@ void hpfs_unlock_creation(struct super_block *s)
#ifdef DEBUG_LOCKS #ifdef DEBUG_LOCKS
printk("unlock creation\n"); printk("unlock creation\n");
#endif #endif
up(&s->u.hpfs_sb.hpfs_creation_de); up(&hpfs_sb(s)->hpfs_creation_de);
} }
void hpfs_lock_iget(struct super_block *s, int mode) void hpfs_lock_iget(struct super_block *s, int mode)
...@@ -31,8 +31,8 @@ void hpfs_lock_iget(struct super_block *s, int mode) ...@@ -31,8 +31,8 @@ void hpfs_lock_iget(struct super_block *s, int mode)
#ifdef DEBUG_LOCKS #ifdef DEBUG_LOCKS
printk("lock iget\n"); printk("lock iget\n");
#endif #endif
while (s->s_hpfs_rd_inode) sleep_on(&s->s_hpfs_iget_q); while (hpfs_sb(s)->sb_rd_inode) sleep_on(&hpfs_sb(s)->sb_iget_q);
s->s_hpfs_rd_inode = mode; hpfs_sb(s)->sb_rd_inode = mode;
} }
void hpfs_unlock_iget(struct super_block *s) void hpfs_unlock_iget(struct super_block *s)
...@@ -40,8 +40,8 @@ void hpfs_unlock_iget(struct super_block *s) ...@@ -40,8 +40,8 @@ void hpfs_unlock_iget(struct super_block *s)
#ifdef DEBUG_LOCKS #ifdef DEBUG_LOCKS
printk("unlock iget\n"); printk("unlock iget\n");
#endif #endif
s->s_hpfs_rd_inode = 0; hpfs_sb(s)->sb_rd_inode = 0;
wake_up(&s->s_hpfs_iget_q); wake_up(&hpfs_sb(s)->sb_iget_q);
} }
void hpfs_lock_inode(struct inode *i) void hpfs_lock_inode(struct inode *i)
......
...@@ -28,7 +28,7 @@ int hpfs_hash_dentry(struct dentry *dentry, struct qstr *qstr) ...@@ -28,7 +28,7 @@ int hpfs_hash_dentry(struct dentry *dentry, struct qstr *qstr)
hash = init_name_hash(); hash = init_name_hash();
for (i = 0; i < l; i++) for (i = 0; i < l; i++)
hash = partial_name_hash(hpfs_upcase(dentry->d_sb->s_hpfs_cp_table,qstr->name[i]), hash); hash = partial_name_hash(hpfs_upcase(hpfs_sb(dentry->d_sb)->sb_cp_table,qstr->name[i]), hash);
qstr->hash = end_name_hash(hash); qstr->hash = end_name_hash(hash);
return 0; return 0;
......
...@@ -65,7 +65,7 @@ int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -65,7 +65,7 @@ int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
int c1, c2 = 0; int c1, c2 = 0;
int ret = 0; int ret = 0;
if (inode->i_sb->s_hpfs_chk) { if (hpfs_sb(inode->i_sb)->sb_chk) {
if (hpfs_chk_sectors(inode->i_sb, inode->i_ino, 1, "dir_fnode")) { if (hpfs_chk_sectors(inode->i_sb, inode->i_ino, 1, "dir_fnode")) {
ret = -EFSERROR; ret = -EFSERROR;
goto out; goto out;
...@@ -75,7 +75,7 @@ int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -75,7 +75,7 @@ int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
goto out; goto out;
} }
} }
if (inode->i_sb->s_hpfs_chk >= 2) { if (hpfs_sb(inode->i_sb)->sb_chk >= 2) {
struct buffer_head *bh; struct buffer_head *bh;
struct fnode *fno; struct fnode *fno;
int e = 0; int e = 0;
...@@ -97,7 +97,7 @@ int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -97,7 +97,7 @@ int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
goto out; goto out;
} }
} }
lc = inode->i_sb->s_hpfs_lowercase; lc = hpfs_sb(inode->i_sb)->sb_lowercase;
if (filp->f_pos == 12) { /* diff -r requires this (note, that diff -r */ if (filp->f_pos == 12) { /* diff -r requires this (note, that diff -r */
filp->f_pos = 13; /* also fails on msdos filesystem in 2.0) */ filp->f_pos = 13; /* also fails on msdos filesystem in 2.0) */
goto out; goto out;
...@@ -114,7 +114,7 @@ int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -114,7 +114,7 @@ int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
/* This won't work when cycle is longer than number of dirents /* This won't work when cycle is longer than number of dirents
accepted by filldir, but what can I do? accepted by filldir, but what can I do?
maybe killall -9 ls helps */ maybe killall -9 ls helps */
if (inode->i_sb->s_hpfs_chk) if (hpfs_sb(inode->i_sb)->sb_chk)
if (hpfs_stop_cycles(inode->i_sb, filp->f_pos, &c1, &c2, "hpfs_readdir")) { if (hpfs_stop_cycles(inode->i_sb, filp->f_pos, &c1, &c2, "hpfs_readdir")) {
hpfs_unlock_inode(inode); hpfs_unlock_inode(inode);
ret = -EFSERROR; ret = -EFSERROR;
...@@ -160,7 +160,7 @@ int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -160,7 +160,7 @@ int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
goto out; goto out;
} }
if (de->first || de->last) { if (de->first || de->last) {
if (inode->i_sb->s_hpfs_chk) { if (hpfs_sb(inode->i_sb)->sb_chk) {
if (de->first && !de->last && (de->namelen != 2 || de ->name[0] != 1 || de->name[1] != 1)) hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08x", old_pos); if (de->first && !de->last && (de->namelen != 2 || de ->name[0] != 1 || de->name[1] != 1)) hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08x", old_pos);
if (de->last && (de->namelen != 1 || de ->name[0] != 255)) hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08x", old_pos); if (de->last && (de->namelen != 1 || de ->name[0] != 255)) hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08x", old_pos);
} }
...@@ -241,7 +241,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry) ...@@ -241,7 +241,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry)
* Go find or make an inode. * Go find or make an inode.
*/ */
hpfs_lock_iget(dir->i_sb, de->directory || (de->ea_size && dir->i_sb->s_hpfs_eas) ? 1 : 2); hpfs_lock_iget(dir->i_sb, de->directory || (de->ea_size && hpfs_sb(dir->i_sb)->sb_eas) ? 1 : 2);
if (!(result = iget(dir->i_sb, ino))) { if (!(result = iget(dir->i_sb, ino))) {
hpfs_unlock_iget(dir->i_sb); hpfs_unlock_iget(dir->i_sb);
hpfs_error(dir->i_sb, "hpfs_lookup: can't get inode"); hpfs_error(dir->i_sb, "hpfs_lookup: can't get inode");
......
...@@ -134,7 +134,7 @@ static void set_last_pointer(struct super_block *s, struct dnode *d, dnode_secno ...@@ -134,7 +134,7 @@ static void set_last_pointer(struct super_block *s, struct dnode *d, dnode_secno
hpfs_error(s, "set_last_pointer: empty dnode %08x", d->self); hpfs_error(s, "set_last_pointer: empty dnode %08x", d->self);
return; return;
} }
if (s->s_hpfs_chk) { if (hpfs_sb(s)->sb_chk) {
if (de->down) { if (de->down) {
hpfs_error(s, "set_last_pointer: dnode %08x has already last pointer %08x", hpfs_error(s, "set_last_pointer: dnode %08x has already last pointer %08x",
d->self, de_down_pointer(de)); d->self, de_down_pointer(de));
...@@ -253,7 +253,7 @@ int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, unsigned char *name, uns ...@@ -253,7 +253,7 @@ int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, unsigned char *name, uns
return 1; return 1;
} }
go_up_a: go_up_a:
if (i->i_sb->s_hpfs_chk) if (hpfs_sb(i->i_sb)->sb_chk)
if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "hpfs_add_to_dnode")) { if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "hpfs_add_to_dnode")) {
hpfs_brelse4(&qbh); hpfs_brelse4(&qbh);
if (nd) kfree(nd); if (nd) kfree(nd);
...@@ -379,7 +379,7 @@ int hpfs_add_dirent(struct inode *i, unsigned char *name, unsigned namelen, ...@@ -379,7 +379,7 @@ int hpfs_add_dirent(struct inode *i, unsigned char *name, unsigned namelen,
int c1, c2 = 0; int c1, c2 = 0;
dno = hpfs_inode->i_dno; dno = hpfs_inode->i_dno;
down: down:
if (i->i_sb->s_hpfs_chk) if (hpfs_sb(i->i_sb)->sb_chk)
if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "hpfs_add_dirent")) return 1; if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "hpfs_add_dirent")) return 1;
if (!(d = hpfs_map_dnode(i->i_sb, dno, &qbh))) return 1; if (!(d = hpfs_map_dnode(i->i_sb, dno, &qbh))) return 1;
de_end = dnode_end_de(d); de_end = dnode_end_de(d);
...@@ -427,11 +427,11 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to) ...@@ -427,11 +427,11 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to)
int c1, c2 = 0; int c1, c2 = 0;
dno = from; dno = from;
while (1) { while (1) {
if (i->i_sb->s_hpfs_chk) if (hpfs_sb(i->i_sb)->sb_chk)
if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "move_to_top")) if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "move_to_top"))
return 0; return 0;
if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return 0; if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return 0;
if (i->i_sb->s_hpfs_chk) { if (hpfs_sb(i->i_sb)->sb_chk) {
if (dnode->up != chk_up) { if (dnode->up != chk_up) {
hpfs_error(i->i_sb, "move_to_top: up pointer from %08x should be %08x, is %08x", hpfs_error(i->i_sb, "move_to_top: up pointer from %08x should be %08x, is %08x",
dno, chk_up, dnode->up); dno, chk_up, dnode->up);
...@@ -519,7 +519,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) ...@@ -519,7 +519,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
up = dnode->up; up = dnode->up;
de = dnode_first_de(dnode); de = dnode_first_de(dnode);
down = de->down ? de_down_pointer(de) : 0; down = de->down ? de_down_pointer(de) : 0;
if (i->i_sb->s_hpfs_chk) if (root && !down) { if (hpfs_sb(i->i_sb)->sb_chk) if (root && !down) {
hpfs_error(i->i_sb, "delete_empty_dnode: root dnode %08x is empty", dno); hpfs_error(i->i_sb, "delete_empty_dnode: root dnode %08x is empty", dno);
goto end; goto end;
} }
...@@ -532,7 +532,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) ...@@ -532,7 +532,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
struct buffer_head *bh; struct buffer_head *bh;
struct dnode *d1; struct dnode *d1;
struct quad_buffer_head qbh1; struct quad_buffer_head qbh1;
if (i->i_sb->s_hpfs_chk) if (up != i->i_ino) { if (hpfs_sb(i->i_sb)->sb_chk) if (up != i->i_ino) {
hpfs_error(i->i_sb, "bad pointer to fnode, dnode %08x, pointing to %08x, should be %08x", dno, up, i->i_ino); hpfs_error(i->i_sb, "bad pointer to fnode, dnode %08x, pointing to %08x, should be %08x", dno, up, i->i_ino);
return; return;
} }
...@@ -628,14 +628,14 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) ...@@ -628,14 +628,14 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
dlp = del->down ? de_down_pointer(del) : 0; dlp = del->down ? de_down_pointer(del) : 0;
if (!dlp && down) { if (!dlp && down) {
if (d1->first_free > 2044) { if (d1->first_free > 2044) {
if (i->i_sb->s_hpfs_chk >= 2) { if (hpfs_sb(i->i_sb)->sb_chk >= 2) {
printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n");
printk("HPFS: warning: terminating balancing operation\n"); printk("HPFS: warning: terminating balancing operation\n");
} }
hpfs_brelse4(&qbh1); hpfs_brelse4(&qbh1);
goto endm; goto endm;
} }
if (i->i_sb->s_hpfs_chk >= 2) { if (hpfs_sb(i->i_sb)->sb_chk >= 2) {
printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n");
printk("HPFS: warning: goin'on\n"); printk("HPFS: warning: goin'on\n");
} }
...@@ -738,12 +738,12 @@ void hpfs_count_dnodes(struct super_block *s, dnode_secno dno, int *n_dnodes, ...@@ -738,12 +738,12 @@ void hpfs_count_dnodes(struct super_block *s, dnode_secno dno, int *n_dnodes,
int d1, d2 = 0; int d1, d2 = 0;
go_down: go_down:
if (n_dnodes) (*n_dnodes)++; if (n_dnodes) (*n_dnodes)++;
if (s->s_hpfs_chk) if (hpfs_sb(s)->sb_chk)
if (hpfs_stop_cycles(s, dno, &c1, &c2, "hpfs_count_dnodes #1")) return; if (hpfs_stop_cycles(s, dno, &c1, &c2, "hpfs_count_dnodes #1")) return;
ptr = 0; ptr = 0;
go_up: go_up:
if (!(dnode = hpfs_map_dnode(s, dno, &qbh))) return; if (!(dnode = hpfs_map_dnode(s, dno, &qbh))) return;
if (s->s_hpfs_chk) if (odno && odno != -1 && dnode->up != odno) if (hpfs_sb(s)->sb_chk) if (odno && odno != -1 && dnode->up != odno)
hpfs_error(s, "hpfs_count_dnodes: bad up pointer; dnode %08x, down %08x points to %08x", odno, dno, dnode->up); hpfs_error(s, "hpfs_count_dnodes: bad up pointer; dnode %08x, down %08x points to %08x", odno, dno, dnode->up);
de = dnode_first_de(dnode); de = dnode_first_de(dnode);
if (ptr) while(1) { if (ptr) while(1) {
...@@ -774,7 +774,7 @@ void hpfs_count_dnodes(struct super_block *s, dnode_secno dno, int *n_dnodes, ...@@ -774,7 +774,7 @@ void hpfs_count_dnodes(struct super_block *s, dnode_secno dno, int *n_dnodes,
return; return;
} }
hpfs_brelse4(&qbh); hpfs_brelse4(&qbh);
if (s->s_hpfs_chk) if (hpfs_sb(s)->sb_chk)
if (hpfs_stop_cycles(s, ptr, &d1, &d2, "hpfs_count_dnodes #2")) return; if (hpfs_stop_cycles(s, ptr, &d1, &d2, "hpfs_count_dnodes #2")) return;
odno = -1; odno = -1;
goto go_up; goto go_up;
...@@ -811,11 +811,11 @@ dnode_secno hpfs_de_as_down_as_possible(struct super_block *s, dnode_secno dno) ...@@ -811,11 +811,11 @@ dnode_secno hpfs_de_as_down_as_possible(struct super_block *s, dnode_secno dno)
int c1, c2 = 0; int c1, c2 = 0;
again: again:
if (s->s_hpfs_chk) if (hpfs_sb(s)->sb_chk)
if (hpfs_stop_cycles(s, d, &c1, &c2, "hpfs_de_as_down_as_possible")) if (hpfs_stop_cycles(s, d, &c1, &c2, "hpfs_de_as_down_as_possible"))
return d; return d;
if (!(de = map_nth_dirent(s, d, 1, &qbh, NULL))) return dno; if (!(de = map_nth_dirent(s, d, 1, &qbh, NULL))) return dno;
if (s->s_hpfs_chk) if (hpfs_sb(s)->sb_chk)
if (up && ((struct dnode *)qbh.data)->up != up) if (up && ((struct dnode *)qbh.data)->up != up)
hpfs_error(s, "hpfs_de_as_down_as_possible: bad up pointer; dnode %08x, down %08x points to %08x", up, d, ((struct dnode *)qbh.data)->up); hpfs_error(s, "hpfs_de_as_down_as_possible: bad up pointer; dnode %08x, down %08x points to %08x", up, d, ((struct dnode *)qbh.data)->up);
if (!de->down) { if (!de->down) {
...@@ -901,7 +901,7 @@ struct hpfs_dirent *map_dirent(struct inode *inode, dnode_secno dno, char *name, ...@@ -901,7 +901,7 @@ struct hpfs_dirent *map_dirent(struct inode *inode, dnode_secno dno, char *name,
if (!S_ISDIR(inode->i_mode)) hpfs_error(inode->i_sb, "map_dirent: not a directory\n"); if (!S_ISDIR(inode->i_mode)) hpfs_error(inode->i_sb, "map_dirent: not a directory\n");
again: again:
if (inode->i_sb->s_hpfs_chk) if (hpfs_sb(inode->i_sb)->sb_chk)
if (hpfs_stop_cycles(inode->i_sb, dno, &c1, &c2, "map_dirent")) return NULL; if (hpfs_stop_cycles(inode->i_sb, dno, &c1, &c2, "map_dirent")) return NULL;
if (!(dnode = hpfs_map_dnode(inode->i_sb, dno, qbh))) return NULL; if (!(dnode = hpfs_map_dnode(inode->i_sb, dno, qbh))) return NULL;
...@@ -1046,7 +1046,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, ...@@ -1046,7 +1046,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno,
if (c < 0 && de->down) { if (c < 0 && de->down) {
dno = de_down_pointer(de); dno = de_down_pointer(de);
hpfs_brelse4(qbh); hpfs_brelse4(qbh);
if (s->s_hpfs_chk) if (hpfs_sb(s)->sb_chk)
if (hpfs_stop_cycles(s, dno, &c1, &c2, "map_fnode_dirent #1")) { if (hpfs_stop_cycles(s, dno, &c1, &c2, "map_fnode_dirent #1")) {
kfree(name2); kfree(name2);
return NULL; return NULL;
...@@ -1065,7 +1065,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, ...@@ -1065,7 +1065,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno,
downd = dno; downd = dno;
dno = d->up; dno = d->up;
hpfs_brelse4(qbh); hpfs_brelse4(qbh);
if (s->s_hpfs_chk) if (hpfs_sb(s)->sb_chk)
if (hpfs_stop_cycles(s, downd, &d1, &d2, "map_fnode_dirent #2")) { if (hpfs_stop_cycles(s, downd, &d1, &d2, "map_fnode_dirent #2")) {
kfree(name2); kfree(name2);
return NULL; return NULL;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/hpfs_fs.h> #include <linux/hpfs_fs.h>
#include <linux/hpfs_fs_i.h> #include <linux/hpfs_fs_i.h>
#include <linux/hpfs_fs_sb.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -57,22 +58,6 @@ ...@@ -57,22 +58,6 @@
typedef void nonconst; /* What this is for ? */ typedef void nonconst; /* What this is for ? */
/*
* local time (HPFS) to GMT (Unix)
*/
extern inline time_t local_to_gmt(struct super_block *s, time_t t)
{
extern struct timezone sys_tz;
return t + sys_tz.tz_minuteswest * 60 + s->s_hpfs_timeshift;
}
extern inline time_t gmt_to_local(struct super_block *s, time_t t)
{
extern struct timezone sys_tz;
return t - sys_tz.tz_minuteswest * 60 - s->s_hpfs_timeshift;
}
/* /*
* conv= options * conv= options
*/ */
...@@ -309,6 +294,11 @@ static inline struct hpfs_inode_info *hpfs_i(struct inode *inode) ...@@ -309,6 +294,11 @@ static inline struct hpfs_inode_info *hpfs_i(struct inode *inode)
return list_entry(inode, struct hpfs_inode_info, vfs_inode); return list_entry(inode, struct hpfs_inode_info, vfs_inode);
} }
static inline struct hpfs_sb_info *hpfs_sb(struct super_block *sb)
{
return sb->u.generic_sbp;
}
/* super.c */ /* super.c */
void hpfs_error(struct super_block *, char *, ...); void hpfs_error(struct super_block *, char *, ...);
...@@ -319,3 +309,20 @@ unsigned hpfs_count_one_bitmap(struct super_block *, secno); ...@@ -319,3 +309,20 @@ unsigned hpfs_count_one_bitmap(struct super_block *, secno);
int hpfs_statfs(struct super_block *, struct statfs *); int hpfs_statfs(struct super_block *, struct statfs *);
extern struct address_space_operations hpfs_aops; extern struct address_space_operations hpfs_aops;
/*
* local time (HPFS) to GMT (Unix)
*/
extern inline time_t local_to_gmt(struct super_block *s, time_t t)
{
extern struct timezone sys_tz;
return t + sys_tz.tz_minuteswest * 60 + hpfs_sb(s)->sb_timeshift;
}
extern inline time_t gmt_to_local(struct super_block *s, time_t t)
{
extern struct timezone sys_tz;
return t - sys_tz.tz_minuteswest * 60 - hpfs_sb(s)->sb_timeshift;
}
...@@ -66,10 +66,10 @@ void hpfs_read_inode(struct inode *i) ...@@ -66,10 +66,10 @@ void hpfs_read_inode(struct inode *i)
unsigned char *ea; unsigned char *ea;
int ea_size; int ea_size;
i->i_uid = sb->s_hpfs_uid; i->i_uid = hpfs_sb(sb)->sb_uid;
i->i_gid = sb->s_hpfs_gid; i->i_gid = hpfs_sb(sb)->sb_gid;
i->i_mode = sb->s_hpfs_mode; i->i_mode = hpfs_sb(sb)->sb_mode;
hpfs_inode->i_conv = sb->s_hpfs_conv; hpfs_inode->i_conv = hpfs_sb(sb)->sb_conv;
i->i_blksize = 512; i->i_blksize = 512;
i->i_size = -1; i->i_size = -1;
i->i_blocks = -1; i->i_blocks = -1;
...@@ -93,9 +93,9 @@ void hpfs_read_inode(struct inode *i) ...@@ -93,9 +93,9 @@ void hpfs_read_inode(struct inode *i)
i->i_mtime = 0; i->i_mtime = 0;
i->i_ctime = 0; i->i_ctime = 0;
if (!i->i_sb->s_hpfs_rd_inode) if (!hpfs_sb(i->i_sb)->sb_rd_inode)
hpfs_error(i->i_sb, "read_inode: s_hpfs_rd_inode == 0"); hpfs_error(i->i_sb, "read_inode: sb_rd_inode == 0");
if (i->i_sb->s_hpfs_rd_inode == 2) { if (hpfs_sb(i->i_sb)->sb_rd_inode == 2) {
i->i_mode |= S_IFREG; i->i_mode |= S_IFREG;
i->i_mode &= ~0111; i->i_mode &= ~0111;
i->i_op = &hpfs_file_iops; i->i_op = &hpfs_file_iops;
...@@ -112,7 +112,7 @@ void hpfs_read_inode(struct inode *i) ...@@ -112,7 +112,7 @@ void hpfs_read_inode(struct inode *i)
make_bad_inode(i); make_bad_inode(i);
return; return;
} }
if (i->i_sb->s_hpfs_eas) { if (hpfs_sb(i->i_sb)->sb_eas) {
if ((ea = hpfs_get_ea(i->i_sb, fnode, "UID", &ea_size))) { if ((ea = hpfs_get_ea(i->i_sb, fnode, "UID", &ea_size))) {
if (ea_size == 2) { if (ea_size == 2) {
i->i_uid = ea[0] + (ea[1] << 8); i->i_uid = ea[0] + (ea[1] << 8);
...@@ -140,7 +140,7 @@ void hpfs_read_inode(struct inode *i) ...@@ -140,7 +140,7 @@ void hpfs_read_inode(struct inode *i)
} }
if ((ea = hpfs_get_ea(i->i_sb, fnode, "MODE", &ea_size))) { if ((ea = hpfs_get_ea(i->i_sb, fnode, "MODE", &ea_size))) {
int rdev = 0; int rdev = 0;
umode_t mode = sb->s_hpfs_mode; umode_t mode = hpfs_sb(sb)->sb_mode;
if (ea_size == 2) { if (ea_size == 2) {
mode = ea[0] + (ea[1] << 8); mode = ea[0] + (ea[1] << 8);
hpfs_inode->i_ea_mode = 1; hpfs_inode->i_ea_mode = 1;
...@@ -171,7 +171,7 @@ void hpfs_read_inode(struct inode *i) ...@@ -171,7 +171,7 @@ void hpfs_read_inode(struct inode *i)
i->i_fop = &hpfs_dir_ops; i->i_fop = &hpfs_dir_ops;
hpfs_inode->i_parent_dir = fnode->up; hpfs_inode->i_parent_dir = fnode->up;
hpfs_inode->i_dno = fnode->u.external[0].disk_secno; hpfs_inode->i_dno = fnode->u.external[0].disk_secno;
if (sb->s_hpfs_chk >= 2) { if (hpfs_sb(sb)->sb_chk >= 2) {
struct buffer_head *bh0; struct buffer_head *bh0;
if (hpfs_map_fnode(sb, hpfs_inode->i_parent_dir, &bh0)) brelse(bh0); if (hpfs_map_fnode(sb, hpfs_inode->i_parent_dir, &bh0)) brelse(bh0);
} }
...@@ -201,24 +201,24 @@ void hpfs_write_inode_ea(struct inode *i, struct fnode *fnode) ...@@ -201,24 +201,24 @@ void hpfs_write_inode_ea(struct inode *i, struct fnode *fnode)
/* Some unknown structures like ACL may be in fnode, /* Some unknown structures like ACL may be in fnode,
we'd better not overwrite them */ we'd better not overwrite them */
hpfs_error(i->i_sb, "fnode %08x has some unknown HPFS386 stuctures", i->i_ino); hpfs_error(i->i_sb, "fnode %08x has some unknown HPFS386 stuctures", i->i_ino);
} else if (i->i_sb->s_hpfs_eas >= 2) { } else if (hpfs_sb(i->i_sb)->sb_eas >= 2) {
unsigned char ea[4]; unsigned char ea[4];
if ((i->i_uid != i->i_sb->s_hpfs_uid) || hpfs_inode->i_ea_uid) { if ((i->i_uid != hpfs_sb(i->i_sb)->sb_uid) || hpfs_inode->i_ea_uid) {
ea[0] = i->i_uid & 0xff; ea[0] = i->i_uid & 0xff;
ea[1] = i->i_uid >> 8; ea[1] = i->i_uid >> 8;
hpfs_set_ea(i, fnode, "UID", ea, 2); hpfs_set_ea(i, fnode, "UID", ea, 2);
hpfs_inode->i_ea_uid = 1; hpfs_inode->i_ea_uid = 1;
} }
if ((i->i_gid != i->i_sb->s_hpfs_gid) || hpfs_inode->i_ea_gid) { if ((i->i_gid != hpfs_sb(i->i_sb)->sb_gid) || hpfs_inode->i_ea_gid) {
ea[0] = i->i_gid & 0xff; ea[0] = i->i_gid & 0xff;
ea[1] = i->i_gid >> 8; ea[1] = i->i_gid >> 8;
hpfs_set_ea(i, fnode, "GID", ea, 2); hpfs_set_ea(i, fnode, "GID", ea, 2);
hpfs_inode->i_ea_gid = 1; hpfs_inode->i_ea_gid = 1;
} }
if (!S_ISLNK(i->i_mode)) if (!S_ISLNK(i->i_mode))
if ((i->i_mode != ((i->i_sb->s_hpfs_mode & ~(S_ISDIR(i->i_mode) ? 0 : 0111)) if ((i->i_mode != ((hpfs_sb(i->i_sb)->sb_mode & ~(S_ISDIR(i->i_mode) ? 0 : 0111))
| (S_ISDIR(i->i_mode) ? S_IFDIR : S_IFREG)) | (S_ISDIR(i->i_mode) ? S_IFDIR : S_IFREG))
&& i->i_mode != ((i->i_sb->s_hpfs_mode & ~(S_ISDIR(i->i_mode) ? 0222 : 0333)) && i->i_mode != ((hpfs_sb(i->i_sb)->sb_mode & ~(S_ISDIR(i->i_mode) ? 0222 : 0333))
| (S_ISDIR(i->i_mode) ? S_IFDIR : S_IFREG))) || hpfs_inode->i_ea_mode) { | (S_ISDIR(i->i_mode) ? S_IFDIR : S_IFREG))) || hpfs_inode->i_ea_mode) {
ea[0] = i->i_mode & 0xff; ea[0] = i->i_mode & 0xff;
ea[1] = i->i_mode >> 8; ea[1] = i->i_mode >> 8;
...@@ -241,7 +241,7 @@ void hpfs_write_inode(struct inode *i) ...@@ -241,7 +241,7 @@ void hpfs_write_inode(struct inode *i)
struct hpfs_inode_info *hpfs_inode = hpfs_i(i); struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
struct inode *parent; struct inode *parent;
if (!i->i_nlink) return; if (!i->i_nlink) return;
if (i->i_ino == i->i_sb->s_hpfs_root) return; if (i->i_ino == hpfs_sb(i->i_sb)->sb_root) return;
if (hpfs_inode->i_rddir_off && !atomic_read(&i->i_count)) { if (hpfs_inode->i_rddir_off && !atomic_read(&i->i_count)) {
if (*hpfs_inode->i_rddir_off) printk("HPFS: write_inode: some position still there\n"); if (*hpfs_inode->i_rddir_off) printk("HPFS: write_inode: some position still there\n");
kfree(hpfs_inode->i_rddir_off); kfree(hpfs_inode->i_rddir_off);
...@@ -264,9 +264,9 @@ void hpfs_write_inode_nolock(struct inode *i) ...@@ -264,9 +264,9 @@ void hpfs_write_inode_nolock(struct inode *i)
struct fnode *fnode; struct fnode *fnode;
struct quad_buffer_head qbh; struct quad_buffer_head qbh;
struct hpfs_dirent *de; struct hpfs_dirent *de;
if (i->i_ino == i->i_sb->s_hpfs_root) return; if (i->i_ino == hpfs_sb(i->i_sb)->sb_root) return;
if (!(fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) return; if (!(fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) return;
if (i->i_ino != i->i_sb->s_hpfs_root) { if (i->i_ino != hpfs_sb(i->i_sb)->sb_root) {
if (!(de = map_fnode_dirent(i->i_sb, i->i_ino, fnode, &qbh))) { if (!(de = map_fnode_dirent(i->i_sb, i->i_ino, fnode, &qbh))) {
brelse(bh); brelse(bh);
return; return;
...@@ -309,7 +309,7 @@ int hpfs_notify_change(struct dentry *dentry, struct iattr *attr) ...@@ -309,7 +309,7 @@ int hpfs_notify_change(struct dentry *dentry, struct iattr *attr)
int error=0; int error=0;
lock_kernel(); lock_kernel();
if ( ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) || if ( ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) ||
(inode->i_sb->s_hpfs_root == inode->i_ino) ) { (hpfs_sb(inode->i_sb)->sb_root == inode->i_ino) ) {
error = -EINVAL; error = -EINVAL;
} else if ((error = inode_change_ok(inode, attr))) { } else if ((error = inode_change_ok(inode, attr))) {
} else if ((error = inode_setattr(inode, attr))) { } else if ((error = inode_setattr(inode, attr))) {
......
...@@ -11,19 +11,19 @@ ...@@ -11,19 +11,19 @@
unsigned *hpfs_map_dnode_bitmap(struct super_block *s, struct quad_buffer_head *qbh) unsigned *hpfs_map_dnode_bitmap(struct super_block *s, struct quad_buffer_head *qbh)
{ {
return hpfs_map_4sectors(s, s->s_hpfs_dmap, qbh, 0); return hpfs_map_4sectors(s, hpfs_sb(s)->sb_dmap, qbh, 0);
} }
unsigned int *hpfs_map_bitmap(struct super_block *s, unsigned bmp_block, unsigned int *hpfs_map_bitmap(struct super_block *s, unsigned bmp_block,
struct quad_buffer_head *qbh, char *id) struct quad_buffer_head *qbh, char *id)
{ {
secno sec; secno sec;
if (s->s_hpfs_chk) if (bmp_block * 16384 > s->s_hpfs_fs_size) { if (hpfs_sb(s)->sb_chk) if (bmp_block * 16384 > hpfs_sb(s)->sb_fs_size) {
hpfs_error(s, "hpfs_map_bitmap called with bad parameter: %08x at %s", bmp_block, id); hpfs_error(s, "hpfs_map_bitmap called with bad parameter: %08x at %s", bmp_block, id);
return NULL; return NULL;
} }
sec = s->s_hpfs_bmp_dir[bmp_block]; sec = hpfs_sb(s)->sb_bmp_dir[bmp_block];
if (!sec || sec > s->s_hpfs_fs_size-4) { if (!sec || sec > hpfs_sb(s)->sb_fs_size-4) {
hpfs_error(s, "invalid bitmap block pointer %08x -> %08x at %s", bmp_block, sec, id); hpfs_error(s, "invalid bitmap block pointer %08x -> %08x at %s", bmp_block, sec, id);
return NULL; return NULL;
} }
...@@ -93,7 +93,7 @@ char *hpfs_load_code_page(struct super_block *s, secno cps) ...@@ -93,7 +93,7 @@ char *hpfs_load_code_page(struct super_block *s, secno cps)
secno *hpfs_load_bitmap_directory(struct super_block *s, secno bmp) secno *hpfs_load_bitmap_directory(struct super_block *s, secno bmp)
{ {
struct buffer_head *bh; struct buffer_head *bh;
int n = (s->s_hpfs_fs_size + 0x200000 - 1) >> 21; int n = (hpfs_sb(s)->sb_fs_size + 0x200000 - 1) >> 21;
int i; int i;
secno *b; secno *b;
if (!(b = kmalloc(n * 512, GFP_KERNEL))) { if (!(b = kmalloc(n * 512, GFP_KERNEL))) {
...@@ -119,11 +119,11 @@ secno *hpfs_load_bitmap_directory(struct super_block *s, secno bmp) ...@@ -119,11 +119,11 @@ secno *hpfs_load_bitmap_directory(struct super_block *s, secno bmp)
struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_head **bhp) struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_head **bhp)
{ {
struct fnode *fnode; struct fnode *fnode;
if (s->s_hpfs_chk) if (hpfs_chk_sectors(s, ino, 1, "fnode")) { if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, ino, 1, "fnode")) {
return NULL; return NULL;
} }
if ((fnode = hpfs_map_sector(s, ino, bhp, FNODE_RD_AHEAD))) { if ((fnode = hpfs_map_sector(s, ino, bhp, FNODE_RD_AHEAD))) {
if (s->s_hpfs_chk) { if (hpfs_sb(s)->sb_chk) {
struct extended_attribute *ea; struct extended_attribute *ea;
struct extended_attribute *ea_end; struct extended_attribute *ea_end;
if (fnode->magic != FNODE_MAGIC) { if (fnode->magic != FNODE_MAGIC) {
...@@ -168,9 +168,9 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea ...@@ -168,9 +168,9 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea
struct anode *hpfs_map_anode(struct super_block *s, anode_secno ano, struct buffer_head **bhp) struct anode *hpfs_map_anode(struct super_block *s, anode_secno ano, struct buffer_head **bhp)
{ {
struct anode *anode; struct anode *anode;
if (s->s_hpfs_chk) if (hpfs_chk_sectors(s, ano, 1, "anode")) return NULL; if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, ano, 1, "anode")) return NULL;
if ((anode = hpfs_map_sector(s, ano, bhp, ANODE_RD_AHEAD))) if ((anode = hpfs_map_sector(s, ano, bhp, ANODE_RD_AHEAD)))
if (s->s_hpfs_chk) { if (hpfs_sb(s)->sb_chk) {
if (anode->magic != ANODE_MAGIC || anode->self != ano) { if (anode->magic != ANODE_MAGIC || anode->self != ano) {
hpfs_error(s, "bad magic on anode %08x", ano); hpfs_error(s, "bad magic on anode %08x", ano);
goto bail; goto bail;
...@@ -200,7 +200,7 @@ struct dnode *hpfs_map_dnode(struct super_block *s, unsigned secno, ...@@ -200,7 +200,7 @@ struct dnode *hpfs_map_dnode(struct super_block *s, unsigned secno,
struct quad_buffer_head *qbh) struct quad_buffer_head *qbh)
{ {
struct dnode *dnode; struct dnode *dnode;
if (s->s_hpfs_chk) { if (hpfs_sb(s)->sb_chk) {
if (hpfs_chk_sectors(s, secno, 4, "dnode")) return NULL; if (hpfs_chk_sectors(s, secno, 4, "dnode")) return NULL;
if (secno & 3) { if (secno & 3) {
hpfs_error(s, "dnode %08x not byte-aligned", secno); hpfs_error(s, "dnode %08x not byte-aligned", secno);
...@@ -208,7 +208,7 @@ struct dnode *hpfs_map_dnode(struct super_block *s, unsigned secno, ...@@ -208,7 +208,7 @@ struct dnode *hpfs_map_dnode(struct super_block *s, unsigned secno,
} }
} }
if ((dnode = hpfs_map_4sectors(s, secno, qbh, DNODE_RD_AHEAD))) if ((dnode = hpfs_map_4sectors(s, secno, qbh, DNODE_RD_AHEAD)))
if (s->s_hpfs_chk) { if (hpfs_sb(s)->sb_chk) {
unsigned p, pp = 0; unsigned p, pp = 0;
unsigned char *d = (char *)dnode; unsigned char *d = (char *)dnode;
int b = 0; int b = 0;
...@@ -234,7 +234,7 @@ struct dnode *hpfs_map_dnode(struct super_block *s, unsigned secno, ...@@ -234,7 +234,7 @@ struct dnode *hpfs_map_dnode(struct super_block *s, unsigned secno,
hpfs_error(s, "namelen does not match dirent size in dnode %08x, dirent %03x, last %03x", secno, p, pp); hpfs_error(s, "namelen does not match dirent size in dnode %08x, dirent %03x, last %03x", secno, p, pp);
goto bail; goto bail;
} }
if (s->s_hpfs_chk >= 2) b |= 1 << de->down; if (hpfs_sb(s)->sb_chk >= 2) b |= 1 << de->down;
if (de->down) if (de_down_pointer(de) < 0x10) { if (de->down) if (de_down_pointer(de) < 0x10) {
hpfs_error(s, "bad down pointer in dnode %08x, dirent %03x, last %03x", secno, p, pp); hpfs_error(s, "bad down pointer in dnode %08x, dirent %03x, last %03x", secno, p, pp);
goto bail; goto bail;
......
...@@ -89,7 +89,7 @@ char *hpfs_translate_name(struct super_block *s, unsigned char *from, ...@@ -89,7 +89,7 @@ char *hpfs_translate_name(struct super_block *s, unsigned char *from,
{ {
char *to; char *to;
int i; int i;
if (s->s_hpfs_chk >= 2) if (hpfs_is_name_long(from, len) != lng) { if (hpfs_sb(s)->sb_chk >= 2) if (hpfs_is_name_long(from, len) != lng) {
printk("HPFS: Long name flag mismatch - name "); printk("HPFS: Long name flag mismatch - name ");
for (i=0; i<len; i++) printk("%c", from[i]); for (i=0; i<len; i++) printk("%c", from[i]);
printk(" misidentified as %s.\n", lng ? "short" : "long"); printk(" misidentified as %s.\n", lng ? "short" : "long");
...@@ -100,7 +100,7 @@ char *hpfs_translate_name(struct super_block *s, unsigned char *from, ...@@ -100,7 +100,7 @@ char *hpfs_translate_name(struct super_block *s, unsigned char *from,
printk("HPFS: can't allocate memory for name conversion buffer\n"); printk("HPFS: can't allocate memory for name conversion buffer\n");
return from; return from;
} }
for (i = 0; i < len; i++) to[i] = locase(s->s_hpfs_cp_table,from[i]); for (i = 0; i < len; i++) to[i] = locase(hpfs_sb(s)->sb_cp_table,from[i]);
return to; return to;
} }
...@@ -111,8 +111,8 @@ int hpfs_compare_names(struct super_block *s, unsigned char *n1, unsigned l1, ...@@ -111,8 +111,8 @@ int hpfs_compare_names(struct super_block *s, unsigned char *n1, unsigned l1,
unsigned i; unsigned i;
if (last) return -1; if (last) return -1;
for (i = 0; i < l; i++) { for (i = 0; i < l; i++) {
unsigned char c1 = upcase(s->s_hpfs_cp_table,n1[i]); unsigned char c1 = upcase(hpfs_sb(s)->sb_cp_table,n1[i]);
unsigned char c2 = upcase(s->s_hpfs_cp_table,n2[i]); unsigned char c2 = upcase(hpfs_sb(s)->sb_cp_table,n2[i]);
if (c1 < c2) return -1; if (c1 < c2) return -1;
if (c1 > c2) return 1; if (c1 > c2) return 1;
} }
......
...@@ -187,7 +187,7 @@ int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev) ...@@ -187,7 +187,7 @@ int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev)
struct inode *result = NULL; struct inode *result = NULL;
int err; int err;
if ((err = hpfs_chk_name((char *)name, &len))) return err==-ENOENT ? -EINVAL : err; if ((err = hpfs_chk_name((char *)name, &len))) return err==-ENOENT ? -EINVAL : err;
if (dir->i_sb->s_hpfs_eas < 2) return -EPERM; if (hpfs_sb(dir->i_sb)->sb_eas < 2) return -EPERM;
lock_kernel(); lock_kernel();
if (!(fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh))) goto bail; if (!(fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh))) goto bail;
memset(&dee, 0, sizeof dee); memset(&dee, 0, sizeof dee);
...@@ -255,7 +255,7 @@ int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *symlink) ...@@ -255,7 +255,7 @@ int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *symlink)
int err; int err;
if ((err = hpfs_chk_name((char *)name, &len))) return err==-ENOENT ? -EINVAL : err; if ((err = hpfs_chk_name((char *)name, &len))) return err==-ENOENT ? -EINVAL : err;
lock_kernel(); lock_kernel();
if (dir->i_sb->s_hpfs_eas < 2) { if (hpfs_sb(dir->i_sb)->sb_eas < 2) {
unlock_kernel(); unlock_kernel();
return -EPERM; return -EPERM;
} }
...@@ -559,7 +559,7 @@ int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -559,7 +559,7 @@ int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
brelse(bh); brelse(bh);
} }
hpfs_i(i)->i_conv = i->i_sb->s_hpfs_conv; hpfs_i(i)->i_conv = hpfs_sb(i->i_sb)->sb_conv;
hpfs_decide_conv(i, (char *)new_name, new_len); hpfs_decide_conv(i, (char *)new_name, new_len);
end1: end1:
hpfs_unlock_3inodes(old_dir, new_dir, i); hpfs_unlock_3inodes(old_dir, new_dir, i);
......
This diff is collapsed.
...@@ -628,7 +628,6 @@ extern int send_sigurg(struct fown_struct *fown); ...@@ -628,7 +628,6 @@ extern int send_sigurg(struct fown_struct *fown);
#define MNT_DETACH 0x00000002 /* Just detach from the tree */ #define MNT_DETACH 0x00000002 /* Just detach from the tree */
#include <linux/ext3_fs_sb.h> #include <linux/ext3_fs_sb.h>
#include <linux/hpfs_fs_sb.h>
extern struct list_head super_blocks; extern struct list_head super_blocks;
extern spinlock_t sb_lock; extern spinlock_t sb_lock;
...@@ -671,7 +670,6 @@ struct super_block { ...@@ -671,7 +670,6 @@ struct super_block {
union { union {
struct ext3_sb_info ext3_sb; struct ext3_sb_info ext3_sb;
struct hpfs_sb_info hpfs_sb;
void *generic_sbp; void *generic_sbp;
} u; } u;
/* /*
......
...@@ -36,31 +36,4 @@ struct hpfs_sb_info { ...@@ -36,31 +36,4 @@ struct hpfs_sb_info {
int sb_timeshift; int sb_timeshift;
}; };
#define s_hpfs_root u.hpfs_sb.sb_root
#define s_hpfs_fs_size u.hpfs_sb.sb_fs_size
#define s_hpfs_bitmaps u.hpfs_sb.sb_bitmaps
#define s_hpfs_dirband_start u.hpfs_sb.sb_dirband_start
#define s_hpfs_dirband_size u.hpfs_sb.sb_dirband_size
#define s_hpfs_dmap u.hpfs_sb.sb_dmap
#define s_hpfs_uid u.hpfs_sb.sb_uid
#define s_hpfs_gid u.hpfs_sb.sb_gid
#define s_hpfs_mode u.hpfs_sb.sb_mode
#define s_hpfs_n_free u.hpfs_sb.sb_n_free
#define s_hpfs_n_free_dnodes u.hpfs_sb.sb_n_free_dnodes
#define s_hpfs_lowercase u.hpfs_sb.sb_lowercase
#define s_hpfs_conv u.hpfs_sb.sb_conv
#define s_hpfs_eas u.hpfs_sb.sb_eas
#define s_hpfs_err u.hpfs_sb.sb_err
#define s_hpfs_chk u.hpfs_sb.sb_chk
#define s_hpfs_was_error u.hpfs_sb.sb_was_error
#define s_hpfs_chkdsk u.hpfs_sb.sb_chkdsk
/*#define s_hpfs_rd_fnode u.hpfs_sb.sb_rd_fnode*/
#define s_hpfs_rd_inode u.hpfs_sb.sb_rd_inode
#define s_hpfs_cp_table u.hpfs_sb.sb_cp_table
#define s_hpfs_bmp_dir u.hpfs_sb.sb_bmp_dir
#define s_hpfs_c_bitmap u.hpfs_sb.sb_c_bitmap
#define s_hpfs_iget_q u.hpfs_sb.sb_iget_q
/*#define s_hpfs_mounting u.hpfs_sb.sb_mounting*/
#define s_hpfs_timeshift u.hpfs_sb.sb_timeshift
#endif #endif
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