fs/adfs: clean up error message printing
Overhaul our message printing: - provide a consistent way to print messages: - filesystem corruption should be reported via adfs_error() - everything else should use adfs_msg() - clean up the error message printing when mounting a filesystem - fix the messages printed by the big directory format code to only use adfs_error() when there is filesystem corruption, otherwise use adfs_msg(). 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:
parent
2e67080d87
commit
ceb3b10613
|
@ -142,6 +142,7 @@ __printf(3, 4)
|
||||||
void __adfs_error(struct super_block *sb, const char *function,
|
void __adfs_error(struct super_block *sb, const char *function,
|
||||||
const char *fmt, ...);
|
const char *fmt, ...);
|
||||||
#define adfs_error(sb, fmt...) __adfs_error(sb, __func__, fmt)
|
#define adfs_error(sb, fmt...) __adfs_error(sb, __func__, fmt)
|
||||||
|
void adfs_msg(struct super_block *sb, const char *pfx, const char *fmt, ...);
|
||||||
|
|
||||||
/* super.c */
|
/* super.c */
|
||||||
|
|
||||||
|
|
|
@ -39,17 +39,15 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
|
||||||
h = (struct adfs_bigdirheader *)dir->bh_fplus[0]->b_data;
|
h = (struct adfs_bigdirheader *)dir->bh_fplus[0]->b_data;
|
||||||
size = le32_to_cpu(h->bigdirsize);
|
size = le32_to_cpu(h->bigdirsize);
|
||||||
if (size != sz) {
|
if (size != sz) {
|
||||||
printk(KERN_WARNING "adfs: adfs_fplus_read:"
|
adfs_msg(sb, KERN_WARNING,
|
||||||
" directory header size %X\n"
|
"directory header size %X does not match directory size %X",
|
||||||
" does not match directory size %X\n",
|
size, sz);
|
||||||
size, sz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h->bigdirversion[0] != 0 || h->bigdirversion[1] != 0 ||
|
if (h->bigdirversion[0] != 0 || h->bigdirversion[1] != 0 ||
|
||||||
h->bigdirversion[2] != 0 || size & 2047 ||
|
h->bigdirversion[2] != 0 || size & 2047 ||
|
||||||
h->bigdirstartname != cpu_to_le32(BIGDIRSTARTNAME)) {
|
h->bigdirstartname != cpu_to_le32(BIGDIRSTARTNAME)) {
|
||||||
printk(KERN_WARNING "adfs: dir object %X has"
|
adfs_error(sb, "dir %06x has malformed header", id);
|
||||||
" malformed dir header\n", id);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,9 +58,10 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
|
||||||
kcalloc(size, sizeof(struct buffer_head *),
|
kcalloc(size, sizeof(struct buffer_head *),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!bh_fplus) {
|
if (!bh_fplus) {
|
||||||
|
adfs_msg(sb, KERN_ERR,
|
||||||
|
"not enough memory for dir object %X (%d blocks)",
|
||||||
|
id, size);
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
adfs_error(sb, "not enough memory for"
|
|
||||||
" dir object %X (%d blocks)", id, size);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
dir->bh_fplus = bh_fplus;
|
dir->bh_fplus = bh_fplus;
|
||||||
|
@ -93,8 +92,7 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
|
||||||
if (t->bigdirendname != cpu_to_le32(BIGDIRENDNAME) ||
|
if (t->bigdirendname != cpu_to_le32(BIGDIRENDNAME) ||
|
||||||
t->bigdirendmasseq != h->startmasseq ||
|
t->bigdirendmasseq != h->startmasseq ||
|
||||||
t->reserved[0] != 0 || t->reserved[1] != 0) {
|
t->reserved[0] != 0 || t->reserved[1] != 0) {
|
||||||
printk(KERN_WARNING "adfs: dir object %X has "
|
adfs_error(sb, "dir %06x has malformed tail", id);
|
||||||
"malformed dir end\n", id);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,18 @@ void __adfs_error(struct super_block *sb, const char *function, const char *fmt,
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void adfs_msg(struct super_block *sb, const char *pfx, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
struct va_format vaf;
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
vaf.fmt = fmt;
|
||||||
|
vaf.va = &args;
|
||||||
|
printk("%sADFS-fs (%s): %pV\n", pfx, sb->s_id, &vaf);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
static int adfs_checkdiscrecord(struct adfs_discrecord *dr)
|
static int adfs_checkdiscrecord(struct adfs_discrecord *dr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -203,8 +215,9 @@ static int parse_options(struct super_block *sb, char *options)
|
||||||
asb->s_ftsuffix = option;
|
asb->s_ftsuffix = option;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printk("ADFS-fs: unrecognised mount option \"%s\" "
|
adfs_msg(sb, KERN_ERR,
|
||||||
"or missing value\n", p);
|
"unrecognised mount option \"%s\" or missing value",
|
||||||
|
p);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,7 +390,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
|
|
||||||
sb_set_blocksize(sb, BLOCK_SIZE);
|
sb_set_blocksize(sb, BLOCK_SIZE);
|
||||||
if (!(bh = sb_bread(sb, ADFS_DISCRECORD / BLOCK_SIZE))) {
|
if (!(bh = sb_bread(sb, ADFS_DISCRECORD / BLOCK_SIZE))) {
|
||||||
adfs_error(sb, "unable to read superblock");
|
adfs_msg(sb, KERN_ERR, "error: unable to read superblock");
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -385,11 +398,8 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
b_data = bh->b_data + (ADFS_DISCRECORD % BLOCK_SIZE);
|
b_data = bh->b_data + (ADFS_DISCRECORD % BLOCK_SIZE);
|
||||||
|
|
||||||
if (adfs_checkbblk(b_data)) {
|
if (adfs_checkbblk(b_data)) {
|
||||||
if (!silent)
|
|
||||||
printk("VFS: Can't find an adfs filesystem on dev "
|
|
||||||
"%s.\n", sb->s_id);
|
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto error_free_bh;
|
goto error_badfs;
|
||||||
}
|
}
|
||||||
|
|
||||||
dr = (struct adfs_discrecord *)(b_data + ADFS_DR_OFFSET);
|
dr = (struct adfs_discrecord *)(b_data + ADFS_DR_OFFSET);
|
||||||
|
@ -398,33 +408,31 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
* Do some sanity checks on the ADFS disc record
|
* Do some sanity checks on the ADFS disc record
|
||||||
*/
|
*/
|
||||||
if (adfs_checkdiscrecord(dr)) {
|
if (adfs_checkdiscrecord(dr)) {
|
||||||
if (!silent)
|
|
||||||
printk("VPS: Can't find an adfs filesystem on dev "
|
|
||||||
"%s.\n", sb->s_id);
|
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto error_free_bh;
|
goto error_badfs;
|
||||||
}
|
}
|
||||||
|
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
if (sb_set_blocksize(sb, 1 << dr->log2secsize)) {
|
if (sb_set_blocksize(sb, 1 << dr->log2secsize)) {
|
||||||
bh = sb_bread(sb, ADFS_DISCRECORD / sb->s_blocksize);
|
bh = sb_bread(sb, ADFS_DISCRECORD / sb->s_blocksize);
|
||||||
if (!bh) {
|
if (!bh) {
|
||||||
adfs_error(sb, "couldn't read superblock on "
|
adfs_msg(sb, KERN_ERR,
|
||||||
"2nd try.");
|
"error: couldn't read superblock on 2nd try.");
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
b_data = bh->b_data + (ADFS_DISCRECORD % sb->s_blocksize);
|
b_data = bh->b_data + (ADFS_DISCRECORD % sb->s_blocksize);
|
||||||
if (adfs_checkbblk(b_data)) {
|
if (adfs_checkbblk(b_data)) {
|
||||||
adfs_error(sb, "disc record mismatch, very weird!");
|
adfs_msg(sb, KERN_ERR,
|
||||||
|
"error: disc record mismatch, very weird!");
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto error_free_bh;
|
goto error_free_bh;
|
||||||
}
|
}
|
||||||
dr = (struct adfs_discrecord *)(b_data + ADFS_DR_OFFSET);
|
dr = (struct adfs_discrecord *)(b_data + ADFS_DR_OFFSET);
|
||||||
} else {
|
} else {
|
||||||
if (!silent)
|
if (!silent)
|
||||||
printk(KERN_ERR "VFS: Unsupported blocksize on dev "
|
adfs_msg(sb, KERN_ERR,
|
||||||
"%s.\n", sb->s_id);
|
"error: unsupported blocksize");
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -497,6 +505,11 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
error_badfs:
|
||||||
|
if (!silent)
|
||||||
|
adfs_msg(sb, KERN_ERR,
|
||||||
|
"error: can't find an ADFS filesystem on dev %s.",
|
||||||
|
sb->s_id);
|
||||||
error_free_bh:
|
error_free_bh:
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
error:
|
error:
|
||||||
|
|
Loading…
Reference in New Issue