fs/adfs: clean up indirect disc addresses and fragment IDs
We use a variety of different names for the indirect disc address of the current object, use a variety of different types, and print it in a variety of different ways. Bring some consistency to this by naming it "indaddr", use u32 or __u32 as the type since it fits in 32-bits, and always print it with %06x (with no leading hex prefix.) When printing it was a directory identifer, use "dir %06x" otherwise use "object %06x". Do the same for fragment IDs and the parent indirect disc addresses. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Родитель
ceb3b10613
Коммит
5ed70bb477
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
struct adfs_inode_info {
|
||||
loff_t mmu_private;
|
||||
unsigned long parent_id; /* object id of parent */
|
||||
__u32 parent_id; /* parent indirect disc address */
|
||||
__u32 loadaddr; /* RISC OS load address */
|
||||
__u32 execaddr; /* RISC OS exec address */
|
||||
unsigned int filetype; /* RISC OS file type */
|
||||
|
@ -86,7 +86,7 @@ struct adfs_dir {
|
|||
struct buffer_head **bh_fplus;
|
||||
|
||||
unsigned int pos;
|
||||
unsigned int parent_id;
|
||||
__u32 parent_id;
|
||||
|
||||
struct adfs_dirheader dirhead;
|
||||
union adfs_dirtail dirtail;
|
||||
|
@ -98,7 +98,7 @@ struct adfs_dir {
|
|||
#define ADFS_MAX_NAME_LEN (256 + 4) /* +4 for ,xyz hex filetype suffix */
|
||||
struct object_info {
|
||||
__u32 parent_id; /* parent object id */
|
||||
__u32 file_id; /* object id */
|
||||
__u32 indaddr; /* indirect disc addr */
|
||||
__u32 loadaddr; /* load address */
|
||||
__u32 execaddr; /* execution address */
|
||||
__u32 size; /* size */
|
||||
|
@ -111,7 +111,8 @@ struct object_info {
|
|||
};
|
||||
|
||||
struct adfs_dir_ops {
|
||||
int (*read)(struct super_block *sb, unsigned int id, unsigned int sz, struct adfs_dir *dir);
|
||||
int (*read)(struct super_block *sb, unsigned int indaddr,
|
||||
unsigned int size, struct adfs_dir *dir);
|
||||
int (*setpos)(struct adfs_dir *dir, unsigned int fpos);
|
||||
int (*getnext)(struct adfs_dir *dir, struct object_info *obj);
|
||||
int (*update)(struct adfs_dir *dir, struct object_info *obj);
|
||||
|
@ -134,7 +135,7 @@ int adfs_write_inode(struct inode *inode, struct writeback_control *wbc);
|
|||
int adfs_notify_change(struct dentry *dentry, struct iattr *attr);
|
||||
|
||||
/* map.c */
|
||||
extern int adfs_map_lookup(struct super_block *sb, unsigned int frag_id, unsigned int offset);
|
||||
int adfs_map_lookup(struct super_block *sb, u32 frag_id, unsigned int offset);
|
||||
extern unsigned int adfs_map_free(struct super_block *sb);
|
||||
|
||||
/* Misc */
|
||||
|
@ -180,18 +181,17 @@ static inline __u32 signed_asl(__u32 val, signed int shift)
|
|||
*
|
||||
* The root directory ID should always be looked up in the map [3.4]
|
||||
*/
|
||||
static inline int
|
||||
__adfs_block_map(struct super_block *sb, unsigned int object_id,
|
||||
unsigned int block)
|
||||
static inline int __adfs_block_map(struct super_block *sb, u32 indaddr,
|
||||
unsigned int block)
|
||||
{
|
||||
if (object_id & 255) {
|
||||
if (indaddr & 255) {
|
||||
unsigned int off;
|
||||
|
||||
off = (object_id & 255) - 1;
|
||||
off = (indaddr & 255) - 1;
|
||||
block += off << ADFS_SB(sb)->s_log2sharesize;
|
||||
}
|
||||
|
||||
return adfs_map_lookup(sb, object_id >> 8, block);
|
||||
return adfs_map_lookup(sb, indaddr >> 8, block);
|
||||
}
|
||||
|
||||
/* Return the disc record from the map */
|
||||
|
|
|
@ -95,7 +95,7 @@ adfs_readdir(struct file *file, struct dir_context *ctx)
|
|||
goto unlock_out;
|
||||
while (ops->getnext(&dir, &obj) == 0) {
|
||||
if (!dir_emit(ctx, obj.name, obj.name_len,
|
||||
obj.file_id, DT_UNKNOWN))
|
||||
obj.indaddr, DT_UNKNOWN))
|
||||
break;
|
||||
ctx->pos++;
|
||||
}
|
||||
|
@ -116,8 +116,8 @@ adfs_dir_update(struct super_block *sb, struct object_info *obj, int wait)
|
|||
const struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir;
|
||||
struct adfs_dir dir;
|
||||
|
||||
printk(KERN_INFO "adfs_dir_update: object %06X in dir %06X\n",
|
||||
obj->file_id, obj->parent_id);
|
||||
printk(KERN_INFO "adfs_dir_update: object %06x in dir %06x\n",
|
||||
obj->indaddr, obj->parent_id);
|
||||
|
||||
if (!ops->update) {
|
||||
ret = -EINVAL;
|
||||
|
@ -181,7 +181,8 @@ static int adfs_dir_lookup_byname(struct inode *inode, const struct qstr *qstr,
|
|||
goto out;
|
||||
|
||||
if (ADFS_I(inode)->parent_id != dir.parent_id) {
|
||||
adfs_error(sb, "parent directory changed under me! (%lx but got %x)\n",
|
||||
adfs_error(sb,
|
||||
"parent directory changed under me! (%06x but got %06x)\n",
|
||||
ADFS_I(inode)->parent_id, dir.parent_id);
|
||||
ret = -EIO;
|
||||
goto free_out;
|
||||
|
|
|
@ -126,12 +126,9 @@ adfs_dir_checkbyte(const struct adfs_dir *dir)
|
|||
return (dircheck ^ (dircheck >> 8) ^ (dircheck >> 16) ^ (dircheck >> 24)) & 0xff;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read and check that a directory is valid
|
||||
*/
|
||||
static int
|
||||
adfs_dir_read(struct super_block *sb, unsigned long object_id,
|
||||
unsigned int size, struct adfs_dir *dir)
|
||||
/* Read and check that a directory is valid */
|
||||
static int adfs_dir_read(struct super_block *sb, u32 indaddr,
|
||||
unsigned int size, struct adfs_dir *dir)
|
||||
{
|
||||
const unsigned int blocksize_bits = sb->s_blocksize_bits;
|
||||
int blk = 0;
|
||||
|
@ -151,10 +148,10 @@ adfs_dir_read(struct super_block *sb, unsigned long object_id,
|
|||
for (blk = 0; blk < size; blk++) {
|
||||
int phys;
|
||||
|
||||
phys = __adfs_block_map(sb, object_id, blk);
|
||||
phys = __adfs_block_map(sb, indaddr, blk);
|
||||
if (!phys) {
|
||||
adfs_error(sb, "dir object %lX has a hole at offset %d",
|
||||
object_id, blk);
|
||||
adfs_error(sb, "dir %06x has a hole at offset %d",
|
||||
indaddr, blk);
|
||||
goto release_buffers;
|
||||
}
|
||||
|
||||
|
@ -182,8 +179,7 @@ adfs_dir_read(struct super_block *sb, unsigned long object_id,
|
|||
return 0;
|
||||
|
||||
bad_dir:
|
||||
adfs_error(sb, "corrupted directory fragment %lX",
|
||||
object_id);
|
||||
adfs_error(sb, "dir %06x is corrupted", indaddr);
|
||||
release_buffers:
|
||||
for (blk -= 1; blk >= 0; blk -= 1)
|
||||
brelse(dir->bh[blk]);
|
||||
|
@ -210,7 +206,7 @@ adfs_dir2obj(struct adfs_dir *dir, struct object_info *obj,
|
|||
}
|
||||
|
||||
obj->name_len = name_len;
|
||||
obj->file_id = adfs_readval(de->dirinddiscadd, 3);
|
||||
obj->indaddr = adfs_readval(de->dirinddiscadd, 3);
|
||||
obj->loadaddr = adfs_readval(de->dirload, 4);
|
||||
obj->execaddr = adfs_readval(de->direxec, 4);
|
||||
obj->size = adfs_readval(de->dirlen, 4);
|
||||
|
@ -225,7 +221,7 @@ adfs_dir2obj(struct adfs_dir *dir, struct object_info *obj,
|
|||
static inline void
|
||||
adfs_obj2dir(struct adfs_direntry *de, struct object_info *obj)
|
||||
{
|
||||
adfs_writeval(de->dirinddiscadd, 3, obj->file_id);
|
||||
adfs_writeval(de->dirinddiscadd, 3, obj->indaddr);
|
||||
adfs_writeval(de->dirload, 4, obj->loadaddr);
|
||||
adfs_writeval(de->direxec, 4, obj->execaddr);
|
||||
adfs_writeval(de->dirlen, 4, obj->size);
|
||||
|
@ -311,8 +307,7 @@ __adfs_dir_put(struct adfs_dir *dir, int pos, struct object_info *obj)
|
|||
* the caller is responsible for holding the necessary
|
||||
* locks.
|
||||
*/
|
||||
static int
|
||||
adfs_dir_find_entry(struct adfs_dir *dir, unsigned long object_id)
|
||||
static int adfs_dir_find_entry(struct adfs_dir *dir, u32 indaddr)
|
||||
{
|
||||
int pos, ret;
|
||||
|
||||
|
@ -324,7 +319,7 @@ adfs_dir_find_entry(struct adfs_dir *dir, unsigned long object_id)
|
|||
if (!__adfs_dir_get(dir, pos, &obj))
|
||||
break;
|
||||
|
||||
if (obj.file_id == object_id) {
|
||||
if (obj.indaddr == indaddr) {
|
||||
ret = pos;
|
||||
break;
|
||||
}
|
||||
|
@ -333,15 +328,15 @@ adfs_dir_find_entry(struct adfs_dir *dir, unsigned long object_id)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
adfs_f_read(struct super_block *sb, unsigned int id, unsigned int sz, struct adfs_dir *dir)
|
||||
static int adfs_f_read(struct super_block *sb, u32 indaddr, unsigned int size,
|
||||
struct adfs_dir *dir)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (sz != ADFS_NEWDIR_SIZE)
|
||||
if (size != ADFS_NEWDIR_SIZE)
|
||||
return -EIO;
|
||||
|
||||
ret = adfs_dir_read(sb, id, sz, dir);
|
||||
ret = adfs_dir_read(sb, indaddr, size, dir);
|
||||
if (ret)
|
||||
adfs_error(sb, "unable to read directory");
|
||||
else
|
||||
|
@ -378,7 +373,7 @@ adfs_f_update(struct adfs_dir *dir, struct object_info *obj)
|
|||
struct super_block *sb = dir->sb;
|
||||
int ret, i;
|
||||
|
||||
ret = adfs_dir_find_entry(dir, obj->file_id);
|
||||
ret = adfs_dir_find_entry(dir, obj->indaddr);
|
||||
if (ret < 0) {
|
||||
adfs_error(dir->sb, "unable to locate entry to update");
|
||||
goto out;
|
||||
|
|
|
@ -180,7 +180,7 @@ adfs_fplus_getnext(struct adfs_dir *dir, struct object_info *obj)
|
|||
obj->loadaddr = le32_to_cpu(bde.bigdirload);
|
||||
obj->execaddr = le32_to_cpu(bde.bigdirexec);
|
||||
obj->size = le32_to_cpu(bde.bigdirlen);
|
||||
obj->file_id = le32_to_cpu(bde.bigdirindaddr);
|
||||
obj->indaddr = le32_to_cpu(bde.bigdirindaddr);
|
||||
obj->attr = le32_to_cpu(bde.bigdirattr);
|
||||
obj->name_len = le32_to_cpu(bde.bigdirobnamelen);
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ adfs_iget(struct super_block *sb, struct object_info *obj)
|
|||
|
||||
inode->i_uid = ADFS_SB(sb)->s_uid;
|
||||
inode->i_gid = ADFS_SB(sb)->s_gid;
|
||||
inode->i_ino = obj->file_id;
|
||||
inode->i_ino = obj->indaddr;
|
||||
inode->i_size = obj->size;
|
||||
set_nlink(inode, 2);
|
||||
inode->i_blocks = (inode->i_size + sb->s_blocksize - 1) >>
|
||||
|
@ -358,7 +358,7 @@ int adfs_write_inode(struct inode *inode, struct writeback_control *wbc)
|
|||
struct object_info obj;
|
||||
int ret;
|
||||
|
||||
obj.file_id = inode->i_ino;
|
||||
obj.indaddr = inode->i_ino;
|
||||
obj.name_len = 0;
|
||||
obj.parent_id = ADFS_I(inode)->parent_id;
|
||||
obj.loadaddr = ADFS_I(inode)->loadaddr;
|
||||
|
|
|
@ -66,9 +66,8 @@ static DEFINE_RWLOCK(adfs_map_lock);
|
|||
* output of:
|
||||
* gcc -D__KERNEL__ -O2 -I../../include -o - -S map.c
|
||||
*/
|
||||
static int
|
||||
lookup_zone(const struct adfs_discmap *dm, const unsigned int idlen,
|
||||
const unsigned int frag_id, unsigned int *offset)
|
||||
static int lookup_zone(const struct adfs_discmap *dm, const unsigned int idlen,
|
||||
const u32 frag_id, unsigned int *offset)
|
||||
{
|
||||
const unsigned int mapsize = dm->dm_endbit;
|
||||
const u32 idmask = (1 << idlen) - 1;
|
||||
|
@ -187,9 +186,8 @@ error:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
scan_map(struct adfs_sb_info *asb, unsigned int zone,
|
||||
const unsigned int frag_id, unsigned int mapoff)
|
||||
static int scan_map(struct adfs_sb_info *asb, unsigned int zone,
|
||||
const u32 frag_id, unsigned int mapoff)
|
||||
{
|
||||
const unsigned int idlen = asb->s_idlen;
|
||||
struct adfs_discmap *dm, *dm_end;
|
||||
|
@ -243,9 +241,7 @@ adfs_map_free(struct super_block *sb)
|
|||
return signed_asl(total, asb->s_map2blk);
|
||||
}
|
||||
|
||||
int
|
||||
adfs_map_lookup(struct super_block *sb, unsigned int frag_id,
|
||||
unsigned int offset)
|
||||
int adfs_map_lookup(struct super_block *sb, u32 frag_id, unsigned int offset)
|
||||
{
|
||||
struct adfs_sb_info *asb = ADFS_SB(sb);
|
||||
unsigned int zone, mapoff;
|
||||
|
|
|
@ -462,7 +462,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
|
|||
|
||||
dr = adfs_map_discrecord(asb->s_map);
|
||||
|
||||
root_obj.parent_id = root_obj.file_id = le32_to_cpu(dr->root);
|
||||
root_obj.parent_id = root_obj.indaddr = le32_to_cpu(dr->root);
|
||||
root_obj.name_len = 0;
|
||||
/* Set root object date as 01 Jan 1987 00:00:00 */
|
||||
root_obj.loadaddr = 0xfff0003f;
|
||||
|
|
Загрузка…
Ссылка в новой задаче