From 1f7d2991e18050d8230aa7b563d61216918bd865 Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Sat, 8 Oct 2011 23:32:03 +0900 Subject: [PATCH v4] udf : enable error print in udf_read_tagged(). While reading metadata, if a problem occurs, Print out only one of the five case.(It also does not show a checksum properly.) Because currently it have been disable by undef udf_debug. If there is a problem with scratched disc or loader, the user needs to know which error happened. And I use pr_fmt instead of printk by joe's suggestion. I try to modify totally it to pr_fmt also. Signed-off-by: Namjae Jeon --- fs/udf/balloc.c | 15 ++-- fs/udf/directory.c | 24 +++--- fs/udf/inode.c | 44 +++++----- fs/udf/lowlevel.c | 2 +- fs/udf/misc.c | 27 ++++-- fs/udf/namei.c | 8 +- fs/udf/partition.c | 8 +- fs/udf/super.c | 237 ++++++++++++++++++++++++++++------------------------ fs/udf/truncate.c | 25 +++--- fs/udf/udfdecl.h | 40 +++++---- fs/udf/udftime.c | 2 +- fs/udf/unicode.c | 36 ++++---- 12 files changed, 255 insertions(+), 213 deletions(-) diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c index 95518a9..e9443ba 100644 --- a/fs/udf/balloc.c +++ b/fs/udf/balloc.c @@ -59,8 +59,8 @@ static int __load_block_bitmap(struct super_block *sb, int nr_groups = bitmap->s_nr_groups; if (block_group >= nr_groups) { - udf_debug("block_group (%d) > nr_groups (%d)\n", block_group, - nr_groups); + udf_debug("block_group (%d) > nr_groups (%d)\n", + block_group, nr_groups); } if (bitmap->s_block_bitmap[block_group]) { @@ -126,8 +126,9 @@ static void udf_bitmap_free_blocks(struct super_block *sb, if (bloc->logicalBlockNum + count < count || (bloc->logicalBlockNum + count) > partmap->s_partition_len) { udf_debug("%d < %d || %d + %d > %d\n", - bloc->logicalBlockNum, 0, bloc->logicalBlockNum, - count, partmap->s_partition_len); + bloc->logicalBlockNum, 0, + bloc->logicalBlockNum, count, + partmap->s_partition_len); goto error_return; } @@ -369,8 +370,8 @@ static void udf_table_free_blocks(struct super_block *sb, if (bloc->logicalBlockNum + count < count || (bloc->logicalBlockNum + count) > partmap->s_partition_len) { udf_debug("%d < %d || %d + %d > %d\n", - bloc->logicalBlockNum, 0, bloc->logicalBlockNum, count, - partmap->s_partition_len); + bloc->logicalBlockNum, 0, bloc->logicalBlockNum, count, + partmap->s_partition_len); goto error_return; } @@ -611,7 +612,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb, while (first_block != eloc.logicalBlockNum && (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { udf_debug("eloc=%d, elen=%d, first_block=%d\n", - eloc.logicalBlockNum, elen, first_block); + eloc.logicalBlockNum, elen, first_block); ; /* empty loop body */ } diff --git a/fs/udf/directory.c b/fs/udf/directory.c index 2ffdb67..5aa0059 100644 --- a/fs/udf/directory.c +++ b/fs/udf/directory.c @@ -162,8 +162,8 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset) int padlen; if ((!buffer) || (!offset)) { - udf_debug("invalidparms\n, buffer=%p, offset=%p\n", buffer, - offset); + udf_debug("invalidparms, buffer=%p, offset=%p\n", + buffer, offset); return NULL; } @@ -174,10 +174,9 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset) fi = (struct fileIdentDesc *)ptr; if (fi->descTag.tagIdent != cpu_to_le16(TAG_IDENT_FID)) { udf_debug("0x%x != TAG_IDENT_FID\n", - le16_to_cpu(fi->descTag.tagIdent)); - udf_debug("offset: %u sizeof: %lu bufsize: %u\n", - *offset, (unsigned long)sizeof(struct fileIdentDesc), - bufsize); + le16_to_cpu(fi->descTag.tagIdent)); + udf_debug("offset: %u sizeof: %zu bufsize: %u\n", + *offset, sizeof(struct fileIdentDesc), bufsize); return NULL; } if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) @@ -195,13 +194,14 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset) return fi; } -struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offset, - int inc) +struct short_ad *udf_get_fileshortad(struct inode *inode, uint8_t *ptr, + int maxoffset, uint32_t *offset, int inc) { struct short_ad *sa; if ((!ptr) || (!offset)) { - printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n"); + udf_err(inode->i_sb, __func__, "udf_get_fileshortad() " + "invalidparms\n"); return NULL; } @@ -218,12 +218,14 @@ struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offs return sa; } -struct long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, uint32_t *offset, int inc) +struct long_ad *udf_get_filelongad(struct inode *inode, uint8_t *ptr, + int maxoffset, uint32_t *offset, int inc) { struct long_ad *la; if ((!ptr) || (!offset)) { - printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n"); + udf_err(inode->i_sb, __func__, "udf_get_filelongad() " + "invalidparms\n"); return NULL; } diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 1d1358e..ddf3002 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -83,10 +83,10 @@ void udf_evict_inode(struct inode *inode) end_writeback(inode); if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB && inode->i_size != iinfo->i_lenExtents) { - printk(KERN_WARNING "UDF-fs (%s): Inode %lu (mode %o) has " + udf_warn(inode->i_sb, __func__, "Inode %lu (mode %o) has " "inode size %llu different from extent length %llu. " "Filesystem need not be standards compliant.\n", - inode->i_sb->s_id, inode->i_ino, inode->i_mode, + inode->i_ino, inode->i_mode, (unsigned long long)inode->i_size, (unsigned long long)iinfo->i_lenExtents); } @@ -1169,16 +1169,18 @@ static void __udf_read_inode(struct inode *inode) */ bh = udf_read_ptagged(inode->i_sb, &iinfo->i_location, 0, &ident); if (!bh) { - printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n", - inode->i_ino); + udf_err(inode->i_sb, __func__, "udf_read_inode(ino %ld) " + "failed !bh\n", + inode->i_ino); make_bad_inode(inode); return; } if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && ident != TAG_IDENT_USE) { - printk(KERN_ERR "udf: udf_read_inode(ino %ld) " - "failed ident=%d\n", inode->i_ino, ident); + udf_err(inode->i_sb, __func__, "udf_read_inode(ino %ld) " + "failed ident=%d\n", + inode->i_ino, ident); brelse(bh); make_bad_inode(inode); return; @@ -1218,8 +1220,9 @@ static void __udf_read_inode(struct inode *inode) } brelse(ibh); } else if (fe->icbTag.strategyType != cpu_to_le16(4)) { - printk(KERN_ERR "udf: unsupported strategy type: %d\n", - le16_to_cpu(fe->icbTag.strategyType)); + udf_err(inode->i_sb, __func__, "unsupported strategy " + "type: %d\n", + le16_to_cpu(fe->icbTag.strategyType)); brelse(bh); make_bad_inode(inode); return; @@ -1413,9 +1416,9 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) udf_debug("METADATA BITMAP FILE-----\n"); break; default: - printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown " - "file type=%d\n", inode->i_ino, - fe->icbTag.fileType); + udf_err(inode->i_sb, __func__, "udf_fill_inode(ino %ld) " + "failed unknown file type=%d\n", + inode->i_ino, fe->icbTag.fileType); make_bad_inode(inode); return; } @@ -1438,8 +1441,9 @@ static int udf_alloc_i_data(struct inode *inode, size_t size) iinfo->i_ext.i_data = kmalloc(size, GFP_KERNEL); if (!iinfo->i_ext.i_data) { - printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) " - "no free memory\n", inode->i_ino); + udf_err(inode->i_sb, __func__, "udf_alloc_i_data (ino %ld) " + "no free memory\n", + inode->i_ino); return -ENOMEM; } @@ -1689,9 +1693,9 @@ out: if (do_sync) { sync_dirty_buffer(bh); if (buffer_write_io_error(bh)) { - printk(KERN_WARNING "IO error syncing udf inode " - "[%s:%08lx]\n", inode->i_sb->s_id, - inode->i_ino); + udf_warn(inode->i_sb, __func__, "IO error syncing udf " + "inode [%s:%08lx]\n", + inode->i_sb->s_id, inode->i_ino); err = -EIO; } } @@ -1720,7 +1724,7 @@ struct inode *udf_iget(struct super_block *sb, struct kernel_lb_addr *ino) if (ino->logicalBlockNum >= UDF_SB(sb)-> s_partmaps[ino->partitionReferenceNum].s_partition_len) { udf_debug("block=%d, partition=%d out of range\n", - ino->logicalBlockNum, ino->partitionReferenceNum); + ino->logicalBlockNum, ino->partitionReferenceNum); make_bad_inode(inode); goto out_iput; } @@ -1964,7 +1968,7 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos, switch (iinfo->i_alloc_type) { case ICBTAG_FLAG_AD_SHORT: - sad = udf_get_fileshortad(ptr, alen, &epos->offset, inc); + sad = udf_get_fileshortad(inode, ptr, alen, &epos->offset, inc); if (!sad) return -1; etype = le32_to_cpu(sad->extLength) >> 30; @@ -1974,7 +1978,7 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos, *elen = le32_to_cpu(sad->extLength) & UDF_EXTENT_LENGTH_MASK; break; case ICBTAG_FLAG_AD_LONG: - lad = udf_get_filelongad(ptr, alen, &epos->offset, inc); + lad = udf_get_filelongad(inode, ptr, alen, &epos->offset, inc); if (!lad) return -1; etype = le32_to_cpu(lad->extLength) >> 30; @@ -1983,7 +1987,7 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos, break; default: udf_debug("alloc_type = %d unsupported\n", - iinfo->i_alloc_type); + iinfo->i_alloc_type); return -1; } diff --git a/fs/udf/lowlevel.c b/fs/udf/lowlevel.c index 43e24a3..df102a9 100644 --- a/fs/udf/lowlevel.c +++ b/fs/udf/lowlevel.c @@ -38,7 +38,7 @@ unsigned int udf_get_last_session(struct super_block *sb) if (i == 0) { udf_debug("XA disk: %s, vol_desc_start=%d\n", - (ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba); + (ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba); if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */ vol_desc_start = ms_info.addr.lba; } else { diff --git a/fs/udf/misc.c b/fs/udf/misc.c index 9215700..c713eac 100644 --- a/fs/udf/misc.c +++ b/fs/udf/misc.c @@ -204,6 +204,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, { struct tag *tag_p; struct buffer_head *bh = NULL; + u8 checksum; /* Read the block */ if (block == 0xFFFFFFFF) @@ -211,8 +212,8 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, bh = udf_tread(sb, block); if (!bh) { - udf_debug("block=%d, location=%d: read failed\n", - block, location); + udf_err(sb, __func__, "block=%d, location=%d: read failed\n", + block, location); return NULL; } @@ -221,22 +222,27 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, *ident = le16_to_cpu(tag_p->tagIdent); if (location != le32_to_cpu(tag_p->tagLocation)) { - udf_debug("location mismatch block %u, tag %u != %u\n", - block, le32_to_cpu(tag_p->tagLocation), location); + udf_err(sb, __func__, "location mismatch block %u, " + "tag %u != %u\n", + block, le32_to_cpu(tag_p->tagLocation), location); goto error_out; } /* Verify the tag checksum */ - if (udf_tag_checksum(tag_p) != tag_p->tagChecksum) { - printk(KERN_ERR "udf: tag checksum failed block %d\n", block); + checksum = udf_tag_checksum(tag_p); + if (checksum != tag_p->tagChecksum) { + udf_err(sb, __func__, "tag checksum failed block %d, " + "checksum 0x%02x != 0x%02x\n", + block, checksum, tag_p->tagChecksum); goto error_out; } /* Verify the tag version */ if (tag_p->descVersion != cpu_to_le16(0x0002U) && tag_p->descVersion != cpu_to_le16(0x0003U)) { - udf_debug("tag version 0x%04x != 0x0002 || 0x0003 block %d\n", - le16_to_cpu(tag_p->descVersion), block); + udf_err(sb, __func__, "tag version 0x%04x != 0x0002 || " + "0x0003 block %d\n", + le16_to_cpu(tag_p->descVersion), block); goto error_out; } @@ -247,8 +253,9 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, le16_to_cpu(tag_p->descCRCLength))) return bh; - udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", block, - le16_to_cpu(tag_p->descCRC), le16_to_cpu(tag_p->descCRCLength)); + udf_err(sb, __func__, "Crc failure block %d: crc = %d, crclen = %d\n", + block, le16_to_cpu(tag_p->descCRC), + le16_to_cpu(tag_p->descCRCLength)); error_out: brelse(bh); diff --git a/fs/udf/namei.c b/fs/udf/namei.c index f1dce84..53ea8d1 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -799,9 +799,9 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry) if (retval) goto end_rmdir; if (inode->i_nlink != 2) - udf_warning(inode->i_sb, "udf_rmdir", - "empty directory has nlink != 2 (%d)", - inode->i_nlink); + udf_warn(inode->i_sb, __func__, "udf_rmdir" + "empty directory has nlink != 2 (%d)\n", + inode->i_nlink); clear_nlink(inode); inode->i_size = 0; inode_dec_link_count(dir); @@ -839,7 +839,7 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry) if (!inode->i_nlink) { udf_debug("Deleting nonexistent file (%lu), %d\n", - inode->i_ino, inode->i_nlink); + inode->i_ino, inode->i_nlink); inode->i_nlink = 1; } retval = udf_delete_entry(dir, fi, &fibh, &cfi); diff --git a/fs/udf/partition.c b/fs/udf/partition.c index a71090e..95d6127 100644 --- a/fs/udf/partition.c +++ b/fs/udf/partition.c @@ -34,7 +34,8 @@ uint32_t udf_get_pblock(struct super_block *sb, uint32_t block, struct udf_part_map *map; if (partition >= sbi->s_partitions) { udf_debug("block=%d, partition=%d, offset=%d: " - "invalid partition\n", block, partition, offset); + "invalid partition\n", + block, partition, offset); return 0xFFFFFFFF; } map = &sbi->s_partmaps[partition]; @@ -61,7 +62,8 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block, if (block > vdata->s_num_entries) { udf_debug("Trying to access block beyond end of VAT " - "(%d max %d)\n", block, vdata->s_num_entries); + "(%d max %d)\n", + block, vdata->s_num_entries); return 0xFFFFFFFF; } @@ -322,7 +324,7 @@ uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block, BUG_ON(!inode); retblk = udf_try_read_meta(inode, block, partition, offset); if (retblk == 0xFFFFFFFF) { - udf_warning(sb, __func__, "error reading from METADATA, " + udf_warn(sb, __func__, "error reading from METADATA, " "trying to read from MIRROR"); inode = mdata->s_mirror_fe; if (!inode) diff --git a/fs/udf/super.c b/fs/udf/super.c index 7b27b06..eafb06b 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -75,8 +75,6 @@ #define UDF_DEFAULT_BLOCKSIZE 2048 -static char error_buf[1024]; - /* These are the "meat" - everything else is stuffing */ static int udf_fill_super(struct super_block *, void *, int); static void udf_put_super(struct super_block *); @@ -92,8 +90,6 @@ static void udf_close_lvid(struct super_block *); static unsigned int udf_count_free(struct super_block *); static int udf_statfs(struct dentry *, struct kstatfs *); static int udf_show_options(struct seq_file *, struct vfsmount *); -static void udf_error(struct super_block *sb, const char *function, - const char *fmt, ...); struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi) { @@ -244,9 +240,9 @@ static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count) sbi->s_partmaps = kcalloc(count, sizeof(struct udf_part_map), GFP_KERNEL); if (!sbi->s_partmaps) { - udf_error(sb, __func__, - "Unable to allocate space for %d partition maps", - count); + udf_err(sb, __func__, + "Unable to allocate space for %d partition maps", + count); sbi->s_partitions = 0; return -ENOMEM; } @@ -405,8 +401,8 @@ static const match_table_t tokens = { {Opt_err, NULL} }; -static int udf_parse_options(char *options, struct udf_options *uopt, - bool remount) +static int udf_parse_options(struct super_block *sb, char *options, + struct udf_options *uopt, bool remount) { char *p; int option; @@ -550,8 +546,8 @@ static int udf_parse_options(char *options, struct udf_options *uopt, uopt->dmode = option & 0777; break; default: - printk(KERN_ERR "udf: bad mount option \"%s\" " - "or missing value\n", p); + udf_err(sb, __func__, "bad mount option \"%s\" " + "or missing value\n", p); return 0; } } @@ -571,7 +567,7 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options) uopt.fmode = sbi->s_fmode; uopt.dmode = sbi->s_dmode; - if (!udf_parse_options(options, &uopt, true)) + if (!udf_parse_options(sb, options, &uopt, true)) return -EINVAL; write_lock(&sbi->s_cred_lock); @@ -622,8 +618,8 @@ static loff_t udf_check_vsd(struct super_block *sb) sector += (sbi->s_session << sb->s_blocksize_bits); udf_debug("Starting at sector %u (%ld byte sectors)\n", - (unsigned int)(sector >> sb->s_blocksize_bits), - sb->s_blocksize); + (unsigned int)(sector >> sb->s_blocksize_bits), + sb->s_blocksize); /* Process the sequence (if applicable) */ for (; !nsr02 && !nsr03; sector += sectorsize) { /* Read a block */ @@ -770,8 +766,8 @@ static int udf_find_fileset(struct super_block *sb, if ((fileset->logicalBlockNum != 0xFFFFFFFF || fileset->partitionReferenceNum != 0xFFFF) && bh) { udf_debug("Fileset at block=%d, partition=%d\n", - fileset->logicalBlockNum, - fileset->partitionReferenceNum); + fileset->logicalBlockNum, + fileset->partitionReferenceNum); sbi->s_partition = fileset->partitionReferenceNum; udf_load_fileset(sb, bh, root); @@ -809,23 +805,22 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block) pvoldesc->recordingDateAndTime)) { #ifdef UDFFS_DEBUG struct timestamp *ts = &pvoldesc->recordingDateAndTime; - udf_debug("recording time %04u/%02u/%02u" - " %02u:%02u (%x)\n", - le16_to_cpu(ts->year), ts->month, ts->day, ts->hour, - ts->minute, le16_to_cpu(ts->typeAndTimezone)); + udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n", + le16_to_cpu(ts->year), ts->month, ts->day, ts->hour, + ts->minute, le16_to_cpu(ts->typeAndTimezone)); #endif } if (!udf_build_ustr(instr, pvoldesc->volIdent, 32)) - if (udf_CS0toUTF8(outstr, instr)) { + if (udf_CS0toUTF8(sb, outstr, instr)) { strncpy(UDF_SB(sb)->s_volume_ident, outstr->u_name, outstr->u_len > 31 ? 31 : outstr->u_len); udf_debug("volIdent[] = '%s'\n", - UDF_SB(sb)->s_volume_ident); + UDF_SB(sb)->s_volume_ident); } if (!udf_build_ustr(instr, pvoldesc->volSetIdent, 128)) - if (udf_CS0toUTF8(outstr, instr)) + if (udf_CS0toUTF8(sb, outstr, instr)) udf_debug("volSetIdent[] = '%s'\n", outstr->u_name); brelse(bh); @@ -853,17 +848,17 @@ static int udf_load_metadata_files(struct super_block *sb, int partition) addr.partitionReferenceNum = map->s_partition_num; udf_debug("Metadata file location: block = %d part = %d\n", - addr.logicalBlockNum, addr.partitionReferenceNum); + addr.logicalBlockNum, addr.partitionReferenceNum); mdata->s_metadata_fe = udf_iget(sb, &addr); if (mdata->s_metadata_fe == NULL) { - udf_warning(sb, __func__, "metadata inode efe not found, " - "will try mirror inode."); + udf_warn(sb, __func__, "metadata inode efe not found, " + "will try mirror inode."); fe_error = 1; } else if (UDF_I(mdata->s_metadata_fe)->i_alloc_type != ICBTAG_FLAG_AD_SHORT) { - udf_warning(sb, __func__, "metadata inode efe does not have " + udf_warn(sb, __func__, "metadata inode efe does not have " "short allocation descriptors!"); fe_error = 1; iput(mdata->s_metadata_fe); @@ -875,21 +870,21 @@ static int udf_load_metadata_files(struct super_block *sb, int partition) addr.partitionReferenceNum = map->s_partition_num; udf_debug("Mirror metadata file location: block = %d part = %d\n", - addr.logicalBlockNum, addr.partitionReferenceNum); + addr.logicalBlockNum, addr.partitionReferenceNum); mdata->s_mirror_fe = udf_iget(sb, &addr); if (mdata->s_mirror_fe == NULL) { if (fe_error) { - udf_error(sb, __func__, "mirror inode efe not found " - "and metadata inode is missing too, exiting..."); + udf_err(sb, __func__, "mirror inode efe not found and " + "metadata inode is missing too, exiting..."); goto error_exit; } else - udf_warning(sb, __func__, "mirror inode efe not found," - " but metadata inode is OK"); + udf_warn(sb, __func__, "mirror inode efe not found," + " but metadata inode is OK"); } else if (UDF_I(mdata->s_mirror_fe)->i_alloc_type != ICBTAG_FLAG_AD_SHORT) { - udf_warning(sb, __func__, "mirror inode efe does not have " + udf_warn(sb, __func__, "mirror inode efe does not have " "short allocation descriptors!"); iput(mdata->s_mirror_fe); mdata->s_mirror_fe = NULL; @@ -913,11 +908,11 @@ static int udf_load_metadata_files(struct super_block *sb, int partition) if (mdata->s_bitmap_fe == NULL) { if (sb->s_flags & MS_RDONLY) - udf_warning(sb, __func__, "bitmap inode efe " + udf_warn(sb, __func__, "bitmap inode efe " "not found but it's ok since the disc" " is mounted read-only"); else { - udf_error(sb, __func__, "bitmap inode efe not " + udf_err(sb, __func__, "bitmap inode efe not " "found and attempted read-write mount"); goto error_exit; } @@ -944,7 +939,7 @@ static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh, UDF_SB(sb)->s_serial_number = le16_to_cpu(fset->descTag.tagSerialNum); udf_debug("Rootdir at block=%d, partition=%d\n", - root->logicalBlockNum, root->partitionReferenceNum); + root->logicalBlockNum, root->partitionReferenceNum); } int udf_compute_nr_groups(struct super_block *sb, u32 partition) @@ -971,9 +966,10 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index) bitmap = vzalloc(size); /* TODO: get rid of vzalloc */ if (bitmap == NULL) { - udf_error(sb, __func__, - "Unable to allocate space for bitmap " - "and %d buffer_head pointers", nr_groups); + udf_err(sb, __func__, + "Unable to allocate space for bitmap " + "and %d buffer_head pointers\n", + nr_groups); return NULL; } @@ -1004,9 +1000,9 @@ static int udf_fill_partdesc_info(struct super_block *sb, map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE; udf_debug("Partition (%d type %x) starts at physical %d, " - "block length %d\n", p_index, - map->s_partition_type, map->s_partition_root, - map->s_partition_len); + "block length %d\n", + p_index, map->s_partition_type, + map->s_partition_root, map->s_partition_len); if (strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) && strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03)) @@ -1023,12 +1019,12 @@ static int udf_fill_partdesc_info(struct super_block *sb, map->s_uspace.s_table = udf_iget(sb, &loc); if (!map->s_uspace.s_table) { udf_debug("cannot load unallocSpaceTable (part %d)\n", - p_index); + p_index); return 1; } map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE; udf_debug("unallocSpaceTable (part %d) @ %ld\n", - p_index, map->s_uspace.s_table->i_ino); + p_index, map->s_uspace.s_table->i_ino); } if (phd->unallocSpaceBitmap.extLength) { @@ -1041,8 +1037,8 @@ static int udf_fill_partdesc_info(struct super_block *sb, bitmap->s_extPosition = le32_to_cpu( phd->unallocSpaceBitmap.extPosition); map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP; - udf_debug("unallocSpaceBitmap (part %d) @ %d\n", p_index, - bitmap->s_extPosition); + udf_debug("unallocSpaceBitmap (part %d) @ %d\n", + p_index, bitmap->s_extPosition); } if (phd->partitionIntegrityTable.extLength) @@ -1064,7 +1060,7 @@ static int udf_fill_partdesc_info(struct super_block *sb, map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE; udf_debug("freedSpaceTable (part %d) @ %ld\n", - p_index, map->s_fspace.s_table->i_ino); + p_index, map->s_fspace.s_table->i_ino); } if (phd->freedSpaceBitmap.extLength) { @@ -1077,8 +1073,8 @@ static int udf_fill_partdesc_info(struct super_block *sb, bitmap->s_extPosition = le32_to_cpu( phd->freedSpaceBitmap.extPosition); map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP; - udf_debug("freedSpaceBitmap (part %d) @ %d\n", p_index, - bitmap->s_extPosition); + udf_debug("freedSpaceBitmap (part %d) @ %d\n", + p_index, bitmap->s_extPosition); } return 0; } @@ -1118,11 +1114,11 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index) udf_find_vat_block(sb, p_index, type1_index, sbi->s_last_block); if (!sbi->s_vat_inode && sbi->s_last_block != blocks - 1) { - printk(KERN_NOTICE "UDF-fs: Failed to read VAT inode from the" - " last recorded block (%lu), retrying with the last " - "block of the device (%lu).\n", - (unsigned long)sbi->s_last_block, - (unsigned long)blocks - 1); + udf_info(sb, "Failed to read VAT inode from the" + " last recorded block (%lu), retrying with the last " + "block of the device (%lu).\n", + (unsigned long)sbi->s_last_block, + (unsigned long)blocks - 1); udf_find_vat_block(sb, p_index, type1_index, blocks - 1); } if (!sbi->s_vat_inode) @@ -1180,7 +1176,7 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block) for (i = 0; i < sbi->s_partitions; i++) { map = &sbi->s_partmaps[i]; udf_debug("Searching map: (%d == %d)\n", - map->s_partition_num, partitionNumber); + map->s_partition_num, partitionNumber); if (map->s_partition_num == partitionNumber && (map->s_partition_type == UDF_TYPE1_MAP15 || map->s_partition_type == UDF_SPARABLE_MAP15)) @@ -1189,7 +1185,7 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block) if (i >= sbi->s_partitions) { udf_debug("Partition (%d) not found in partition map\n", - partitionNumber); + partitionNumber); goto out_bh; } @@ -1220,8 +1216,9 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block) if (map->s_partition_type == UDF_METADATA_MAP25) { ret = udf_load_metadata_files(sb, i); if (ret) { - printk(KERN_ERR "UDF-fs: error loading MetaData " - "partition map %d\n", i); + udf_err(sb, __func__, "loading MetaData " + "partition map %d\n", + i); goto out_bh; } } else { @@ -1234,7 +1231,7 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block) * overwrite blocks instead of relocating them). */ sb->s_flags |= MS_RDONLY; - printk(KERN_NOTICE "UDF-fs: Filesystem marked read-only " + udf_info(sb, "Filesystem marked read-only " "because writing to pseudooverwrite partition is " "not implemented.\n"); } @@ -1345,8 +1342,8 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, (struct metadataPartitionMap *) &(lvd->partitionMaps[offset]); udf_debug("Parsing Logical vol part %d " - "type %d id=%s\n", i, type, - UDF_ID_METADATA); + "type %d id=%s\n", + i, type, UDF_ID_METADATA); map->s_partition_type = UDF_METADATA_MAP25; map->s_partition_func = udf_get_pblock_meta25; @@ -1365,9 +1362,8 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, mdm->flags & 0x01; udf_debug("Metadata Ident suffix=0x%x\n", - (le16_to_cpu( - ((__le16 *) - mdm->partIdent.identSuffix)[0]))); + (le16_to_cpu(((__le16 *) + mdm->partIdent.identSuffix)[0]))); udf_debug("Metadata part num=%d\n", le16_to_cpu(mdm->partitionNum)); udf_debug("Metadata part alloc unit size=%d\n", @@ -1382,15 +1378,14 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, mdata->s_dup_md_flag, mdm->flags); } else { udf_debug("Unknown ident: %s\n", - upm2->partIdent.ident); + upm2->partIdent.ident); continue; } map->s_volumeseqnum = le16_to_cpu(upm2->volSeqNum); map->s_partition_num = le16_to_cpu(upm2->partitionNum); } udf_debug("Partition (%d:%d) type %d on volume %d\n", - i, map->s_partition_num, type, - map->s_volumeseqnum); + i, map->s_partition_num, type, map->s_volumeseqnum); } if (fileset) { @@ -1398,8 +1393,9 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, *fileset = lelb_to_cpu(la->extLocation); udf_debug("FileSet found in LogicalVolDesc at block=%d, " - "partition=%d\n", fileset->logicalBlockNum, - fileset->partitionReferenceNum); + "partition=%d\n", + fileset->logicalBlockNum, + fileset->partitionReferenceNum); } if (lvd->integritySeqExt.extLength) udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt)); @@ -1478,9 +1474,9 @@ static noinline int udf_process_sequence(struct super_block *sb, long block, bh = udf_read_tagged(sb, block, block, &ident); if (!bh) { - printk(KERN_ERR "udf: Block %Lu of volume descriptor " - "sequence is corrupted or we could not read " - "it.\n", (unsigned long long)block); + udf_err(sb, __func__, "Block %Lu of volume descriptor " + "sequence is corrupted or we could not read " + "it.\n", (unsigned long long)block); return 1; } @@ -1553,7 +1549,7 @@ static noinline int udf_process_sequence(struct super_block *sb, long block, * in a suitable order */ if (!vds[VDS_POS_PRIMARY_VOL_DESC].block) { - printk(KERN_ERR "udf: Primary Volume Descriptor not found!\n"); + udf_err(sb, __func__, "Primary Volume Descriptor not found!\n"); return 1; } if (udf_load_pvoldesc(sb, vds[VDS_POS_PRIMARY_VOL_DESC].block)) @@ -1740,7 +1736,7 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt, if (!sb_set_blocksize(sb, uopt->blocksize)) { if (!silent) - printk(KERN_WARNING "UDF-fs: Bad block size\n"); + udf_warn(sb, __func__, "Bad block size\n"); return 0; } sbi->s_last_block = uopt->lastblock; @@ -1749,12 +1745,12 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt, nsr_off = udf_check_vsd(sb); if (!nsr_off) { if (!silent) - printk(KERN_WARNING "UDF-fs: No VRS found\n"); + udf_warn(sb, __func__, "No VRS found\n"); return 0; } if (nsr_off == -1) udf_debug("Failed to read byte 32768. Assuming open " - "disc. Skipping validity check\n"); + "disc. Skipping validity check\n"); if (!sbi->s_last_block) sbi->s_last_block = udf_get_last_block(sb); } else { @@ -1765,7 +1761,7 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt, sbi->s_anchor = uopt->anchor; if (!udf_find_anchor(sb, fileset)) { if (!silent) - printk(KERN_WARNING "UDF-fs: No anchor found\n"); + udf_warn(sb, __func__, "No anchor found\n"); return 0; } return 1; @@ -1932,13 +1928,13 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) mutex_init(&sbi->s_alloc_mutex); - if (!udf_parse_options((char *)options, &uopt, false)) + if (!udf_parse_options(sb, (char *)options, &uopt, false)) goto error_out; if (uopt.flags & (1 << UDF_FLAG_UTF8) && uopt.flags & (1 << UDF_FLAG_NLS_MAP)) { - udf_error(sb, "udf_read_super", - "utf8 cannot be combined with iocharset\n"); + udf_err(sb, __func__, "udf_read_super" + "utf8 cannot be combined with iocharset\n"); goto error_out; } #ifdef CONFIG_UDF_NLS @@ -1987,15 +1983,14 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) ret = udf_load_vrs(sb, &uopt, silent, &fileset); if (!ret && uopt.blocksize != UDF_DEFAULT_BLOCKSIZE) { if (!silent) - printk(KERN_NOTICE - "UDF-fs: Rescanning with blocksize " - "%d\n", UDF_DEFAULT_BLOCKSIZE); + udf_info(sb, "Rescanning with blocksize %d\n", + UDF_DEFAULT_BLOCKSIZE); uopt.blocksize = UDF_DEFAULT_BLOCKSIZE; ret = udf_load_vrs(sb, &uopt, silent, &fileset); } } if (!ret) { - printk(KERN_WARNING "UDF-fs: No partition found (1)\n"); + udf_warn(sb, __func__, "No partition found (1)\n"); goto error_out; } @@ -2010,10 +2005,9 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) le16_to_cpu(lvidiu->maxUDFWriteRev); */ if (minUDFReadRev > UDF_MAX_READ_VERSION) { - printk(KERN_ERR "UDF-fs: minUDFReadRev=%x " - "(max is %x)\n", - le16_to_cpu(lvidiu->minUDFReadRev), - UDF_MAX_READ_VERSION); + udf_err(sb, __func__, "minUDFReadRev=%x (max is %x)\n", + le16_to_cpu(lvidiu->minUDFReadRev), + UDF_MAX_READ_VERSION); goto error_out; } else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION) sb->s_flags |= MS_RDONLY; @@ -2027,29 +2021,30 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) } if (!sbi->s_partitions) { - printk(KERN_WARNING "UDF-fs: No partition found (2)\n"); + udf_warn(sb, __func__, "No partition found (2)\n"); goto error_out; } if (sbi->s_partmaps[sbi->s_partition].s_partition_flags & UDF_PART_FLAG_READ_ONLY) { - printk(KERN_NOTICE "UDF-fs: Partition marked readonly; " - "forcing readonly mount\n"); + udf_info(sb, "Partition marked readonly; " + "forcing readonly mount\n"); sb->s_flags |= MS_RDONLY; } if (udf_find_fileset(sb, &fileset, &rootdir)) { - printk(KERN_WARNING "UDF-fs: No fileset found\n"); + udf_warn(sb, __func__, "No fileset found\n"); goto error_out; } if (!silent) { struct timestamp ts; udf_time_to_disk_stamp(&ts, sbi->s_record_time); - udf_info("UDF: Mounting volume '%s', " - "timestamp %04u/%02u/%02u %02u:%02u (%x)\n", - sbi->s_volume_ident, le16_to_cpu(ts.year), ts.month, ts.day, - ts.hour, ts.minute, le16_to_cpu(ts.typeAndTimezone)); + udf_info(sb, "Mounting volume '%s', " + "timestamp %04u/%02u/%02u %02u:%02u (%x)\n", + sbi->s_volume_ident, le16_to_cpu(ts.year), ts.month, + ts.day, ts.hour, ts.minute, + le16_to_cpu(ts.typeAndTimezone)); } if (!(sb->s_flags & MS_RDONLY)) udf_open_lvid(sb); @@ -2059,16 +2054,16 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) /* perhaps it's not extensible enough, but for now ... */ inode = udf_iget(sb, &rootdir); if (!inode) { - printk(KERN_ERR "UDF-fs: Error in udf_iget, block=%d, " - "partition=%d\n", - rootdir.logicalBlockNum, rootdir.partitionReferenceNum); + udf_err(sb, __func__, "Error in udf_iget, block=%d, " + "partition=%d\n", + rootdir.logicalBlockNum, rootdir.partitionReferenceNum); goto error_out; } /* Allocate a dentry for the root inode */ sb->s_root = d_alloc_root(inode); if (!sb->s_root) { - printk(KERN_ERR "UDF-fs: Couldn't allocate root dentry\n"); + udf_err(sb, __func__, "Couldn't allocate root dentry\n"); iput(inode); goto error_out; } @@ -2096,32 +2091,52 @@ error_out: return -EINVAL; } -static void udf_error(struct super_block *sb, const char *function, +void udf_err(struct super_block *sb, const char *function, const char *fmt, ...) { + struct va_format vaf; va_list args; + va_start(args, fmt); + vaf.fmt = fmt; + vaf.va = &args; + if (!(sb->s_flags & MS_RDONLY)) { /* mark sb error */ sb->s_dirt = 1; } + + pr_crit("error (device %s): %s: %pV", sb->s_id, function, &vaf); + va_end(args); +} + +void udf_warn(struct super_block *sb, const char *function, + const char *fmt, ...) +{ + struct va_format vaf; + va_list args; + va_start(args, fmt); - vsnprintf(error_buf, sizeof(error_buf), fmt, args); + + vaf.fmt = fmt; + vaf.va = &args; + + pr_warn("warning (device %s): %s: %pV", sb->s_id, function, &vaf); va_end(args); - printk(KERN_CRIT "UDF-fs error (device %s): %s: %s\n", - sb->s_id, function, error_buf); } -void udf_warning(struct super_block *sb, const char *function, - const char *fmt, ...) +void udf_info(struct super_block *sb, const char *fmt, ...) { + struct va_format vaf; va_list args; va_start(args, fmt); - vsnprintf(error_buf, sizeof(error_buf), fmt, args); + + vaf.fmt = fmt; + vaf.va = &args; + + pr_info("info (device %s): %pV", sb->s_id, &vaf); va_end(args); - printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s\n", - sb->s_id, function, error_buf); } static void udf_put_super(struct super_block *sb) @@ -2213,11 +2228,11 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb, bh = udf_read_ptagged(sb, &loc, 0, &ident); if (!bh) { - printk(KERN_ERR "udf: udf_count_free failed\n"); + udf_err(sb, __func__, "udf_count_free failed\n"); goto out; } else if (ident != TAG_IDENT_SBD) { brelse(bh); - printk(KERN_ERR "udf: udf_count_free failed\n"); + udf_err(sb, __func__, "udf_count_free failed\n"); goto out; } diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c index 8424308..f07ef23 100644 --- a/fs/udf/truncate.c +++ b/fs/udf/truncate.c @@ -95,23 +95,24 @@ void udf_truncate_tail_extent(struct inode *inode) lbcount += elen; if (lbcount > inode->i_size) { if (lbcount - inode->i_size >= inode->i_sb->s_blocksize) - printk(KERN_WARNING - "udf_truncate_tail_extent(): Too long " - "extent after EOF in inode %u: i_size: " - "%Ld lbcount: %Ld extent %u+%u\n", - (unsigned)inode->i_ino, - (long long)inode->i_size, - (long long)lbcount, - (unsigned)eloc.logicalBlockNum, - (unsigned)elen); + udf_warn(inode->i_sb, __func__, + "udf_truncate_tail_extent(): Too long " + "extent after EOF in inode %u: i_size: " + "%Ld lbcount: %Ld extent %u+%u\n", + (unsigned)inode->i_ino, + (long long)inode->i_size, + (long long)lbcount, + (unsigned)eloc.logicalBlockNum, + (unsigned)elen); nelen = elen - (lbcount - inode->i_size); epos.offset -= adsize; extent_trunc(inode, &epos, &eloc, etype, elen, nelen); epos.offset += adsize; if (udf_next_aext(inode, &epos, &eloc, &elen, 1) != -1) - printk(KERN_ERR "udf_truncate_tail_extent(): " - "Extent after EOF in inode %u.\n", - (unsigned)inode->i_ino); + udf_warn(inode->i_sb, __func__, + "udf_truncate_tail_extent(): " + "Extent after EOF in inode %u.\n", + (unsigned)inode->i_ino); break; } } diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index dbd52d4b..abd6e69 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h @@ -1,6 +1,8 @@ #ifndef __UDF_DECL_H #define __UDF_DECL_H +#define pr_fmt(fmt) "UDF-fs " fmt + #include "ecma_167.h" #include "osta_udf.h" @@ -16,23 +18,28 @@ #define UDF_PREALLOCATE #define UDF_DEFAULT_PREALLOC_BLOCKS 8 +__attribute__((format(printf, 3, 4))) +void udf_err(struct super_block *sb, const char *function, + const char *fmt, ...); + +__attribute__((format(printf, 3, 4))) +void udf_warn(struct super_block *sb, const char *function, + const char *fmt, ...); + +__attribute__((format(printf, 2, 3))) +void udf_info(struct super_block *sb, const char *fmt, ...); + #undef UDFFS_DEBUG #ifdef UDFFS_DEBUG -#define udf_debug(f, a...) \ -do { \ - printk(KERN_DEBUG "UDF-fs DEBUG %s:%d:%s: ", \ - __FILE__, __LINE__, __func__); \ - printk(f, ##a); \ -} while (0) +#define udf_debug(fmt, ...) \ + pr_debug("debug %s:%d:%s: " fmt, \ + __FILE__, __LINE__, __func__, ##__VA_ARGS__) #else -#define udf_debug(f, a...) /**/ +#define udf_debug(fmt, ...) \ + no_printk(KERN_DEBUG fmt, ##__VA_ARGS__) #endif -#define udf_info(f, a...) \ - printk(KERN_INFO "UDF-fs INFO " f, ##a); - - #define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) ) #define udf_variable_to_fixed(x) ( ( ( (x) / 39 ) << 5 ) + ( (x) % 39 ) ) @@ -112,8 +119,6 @@ struct extent_position { /* super.c */ -__attribute__((format(printf, 3, 4))) -extern void udf_warning(struct super_block *, const char *, const char *, ...); static inline void udf_updated_lvid(struct super_block *sb) { struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh; @@ -202,7 +207,8 @@ extern int udf_get_filename(struct super_block *, uint8_t *, uint8_t *, int); extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *, int); extern int udf_build_ustr(struct ustr *, dstring *, int); -extern int udf_CS0toUTF8(struct ustr *, const struct ustr *); +extern int udf_CS0toUTF8(struct super_block *, struct ustr *, + const struct ustr *); /* ialloc.c */ extern void udf_free_inode(struct inode *); @@ -230,8 +236,10 @@ extern struct fileIdentDesc *udf_fileident_read(struct inode *, loff_t *, sector_t *); extern struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset); -extern struct long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int); -extern struct short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int); +extern struct long_ad *udf_get_filelongad(struct inode *, uint8_t *, int, + uint32_t *, int); +extern struct short_ad *udf_get_fileshortad(struct inode *, uint8_t *, int, + uint32_t *, int); /* udftime.c */ extern struct timespec *udf_disk_stamp_to_time(struct timespec *dest, diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c index b8c828c..927c931 100644 --- a/fs/udf/udftime.c +++ b/fs/udf/udftime.c @@ -34,9 +34,9 @@ * http://www.boulder.nist.gov/timefreq/pubs/bulletin/leapsecond.htm */ +#include "udfdecl.h" #include #include -#include "udfdecl.h" #define EPOCH_YEAR 1970 diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c index d03a90b..426f8f3 100644 --- a/fs/udf/unicode.c +++ b/fs/udf/unicode.c @@ -99,7 +99,8 @@ static int udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize) * November 12, 1997 - Andrew E. Mileski * Written, tested, and released. */ -int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i) +int udf_CS0toUTF8(struct super_block *sb, struct ustr *utf_o, + const struct ustr *ocu_i) { const uint8_t *ocu; uint8_t cmp_id, ocu_len; @@ -114,8 +115,8 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i) cmp_id = ocu_i->u_cmpID; if (cmp_id != 8 && cmp_id != 16) { memset(utf_o, 0, sizeof(struct ustr)); - printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n", - cmp_id, ocu_i->u_name); + udf_err(sb, __func__, "unknown compression code (%d) stri=%s\n", + cmp_id, ocu_i->u_name); return 0; } @@ -174,7 +175,8 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i) * November 12, 1997 - Andrew E. Mileski * Written, tested, and released. */ -static int udf_UTF8toCS0(dstring *ocu, struct ustr *utf, int length) +static int udf_UTF8toCS0(struct super_block *sb, dstring *ocu, struct ustr *utf, + int length) { unsigned c, i, max_val, utf_char; int utf_cnt, u_len; @@ -242,7 +244,7 @@ try_again: if (utf_cnt) { error_out: ocu[++u_len] = '?'; - printk(KERN_DEBUG "udf: bad UTF-8 character\n"); + udf_debug("bad UTF-8 character\n"); } ocu[length - 1] = (uint8_t)u_len + 1; @@ -250,8 +252,8 @@ error_out: return u_len + 1; } -static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, - const struct ustr *ocu_i) +static int udf_CS0toNLS(struct super_block *sb, struct nls_table *nls, + struct ustr *utf_o, const struct ustr *ocu_i) { const uint8_t *ocu; uint8_t cmp_id, ocu_len; @@ -267,8 +269,8 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, cmp_id = ocu_i->u_cmpID; if (cmp_id != 8 && cmp_id != 16) { memset(utf_o, 0, sizeof(struct ustr)); - printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n", - cmp_id, ocu_i->u_name); + udf_err(sb, __func__, "unknown compression code (%d) stri=%s\n", + cmp_id, ocu_i->u_name); return 0; } @@ -293,8 +295,8 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, return utf_o->u_len; } -static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni, - int length) +static int udf_NLStoCS0(struct super_block *sb, struct nls_table *nls, + dstring *ocu, struct ustr *uni, int length) { int len; unsigned i, max_val; @@ -351,16 +353,16 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname, goto out2; if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { - if (!udf_CS0toUTF8(filename, unifilename)) { + if (!udf_CS0toUTF8(sb, filename, unifilename)) { udf_debug("Failed in udf_get_filename: sname = %s\n", - sname); + sname); goto out2; } } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { - if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, filename, + if (!udf_CS0toNLS(sb, UDF_SB(sb)->s_nls_map, filename, unifilename)) { udf_debug("Failed in udf_get_filename: sname = %s\n", - sname); + sname); goto out2; } } else @@ -385,11 +387,11 @@ int udf_put_filename(struct super_block *sb, const uint8_t *sname, return 0; if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { - namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN); + namelen = udf_UTF8toCS0(sb, dname, &unifilename, UDF_NAME_LEN); if (!namelen) return 0; } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { - namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, + namelen = udf_NLStoCS0(sb, UDF_SB(sb)->s_nls_map, dname, &unifilename, UDF_NAME_LEN); if (!namelen) return 0; -- 1.7.4.4