XR_INO_PQUOTA, /* project quota inode */
XR_INO_RTRMAP, /* realtime rmap */
XR_INO_RTREFC, /* realtime refcount */
+ XR_INO_MAX
};
+static const char *xr_ino_type_name[] = {
+ [XR_INO_UNKNOWN] = N_("unknown"),
+ [XR_INO_DIR] = N_("directory"),
+ [XR_INO_RTDATA] = N_("realtime file"),
+ [XR_INO_RTBITMAP] = N_("realtime bitmap"),
+ [XR_INO_RTSUM] = N_("realtime summary"),
+ [XR_INO_DATA] = N_("regular file"),
+ [XR_INO_SYMLINK] = N_("symlink"),
+ [XR_INO_CHRDEV] = N_("character device"),
+ [XR_INO_BLKDEV] = N_("block device"),
+ [XR_INO_SOCK] = N_("socket"),
+ [XR_INO_FIFO] = N_("fifo"),
+ [XR_INO_UQUOTA] = N_("user quota"),
+ [XR_INO_GQUOTA] = N_("group quota"),
+ [XR_INO_PQUOTA] = N_("project quota"),
+ [XR_INO_RTRMAP] = N_("realtime rmap"),
+ [XR_INO_RTREFC] = N_("realtime refcount"),
+};
+static_assert(ARRAY_SIZE(xr_ino_type_name) == XR_INO_MAX);
+
/*
* gettext lookups for translations of strings use mutexes internally to
* the library. Hence when we come through here doing parallel scans in
return(0);
}
-/*
- * called to process the set of misc inode special inode types
- * that have no associated data storage (fifos, pipes, devices, etc.).
- */
-static int
-process_misc_ino_types(
- xfs_mount_t *mp,
- struct xfs_dinode *dino,
- xfs_ino_t lino,
- enum xr_ino_type type)
-{
- /*
- * must also have a zero size
- */
- if (be64_to_cpu(dino->di_size) != 0) {
- switch (type) {
- case XR_INO_CHRDEV:
- do_warn(
-_("size of character device inode %" PRIu64 " != 0 (%" PRId64 " bytes)\n"), lino,
- (int64_t)be64_to_cpu(dino->di_size));
- break;
- case XR_INO_BLKDEV:
- do_warn(
-_("size of block device inode %" PRIu64 " != 0 (%" PRId64 " bytes)\n"), lino,
- (int64_t)be64_to_cpu(dino->di_size));
- break;
- case XR_INO_SOCK:
- do_warn(
-_("size of socket inode %" PRIu64 " != 0 (%" PRId64 " bytes)\n"), lino,
- (int64_t)be64_to_cpu(dino->di_size));
- break;
- case XR_INO_FIFO:
- do_warn(
-_("size of fifo inode %" PRIu64 " != 0 (%" PRId64 " bytes)\n"), lino,
- (int64_t)be64_to_cpu(dino->di_size));
- break;
- case XR_INO_UQUOTA:
- case XR_INO_GQUOTA:
- case XR_INO_PQUOTA:
- do_warn(
-_("size of quota inode %" PRIu64 " != 0 (%" PRId64 " bytes)\n"), lino,
- (int64_t)be64_to_cpu(dino->di_size));
- break;
- default:
- do_warn(_("Internal error - process_misc_ino_types, "
- "illegal type %d\n"), type);
- abort();
- }
-
- return(1);
- }
-
- return(0);
-}
-
-static int
-process_misc_ino_types_blocks(
- xfs_rfsblock_t totblocks,
- xfs_ino_t lino,
- enum xr_ino_type type)
-{
- /*
- * you can not enforce all misc types have zero data fork blocks
- * by checking dino->di_nblocks because atotblocks (attribute
- * blocks) are part of nblocks. We must check this later when atotblocks
- * has been calculated or by doing a simple check that anExtents == 0.
- * We must also guarantee that totblocks is 0. Thus nblocks checking
- * will be done later in process_dinode_int for misc types.
- */
-
- if (totblocks != 0) {
- switch (type) {
- case XR_INO_CHRDEV:
- do_warn(
-_("size of character device inode %" PRIu64 " != 0 (%" PRIu64 " blocks)\n"),
- lino, totblocks);
- break;
- case XR_INO_BLKDEV:
- do_warn(
-_("size of block device inode %" PRIu64 " != 0 (%" PRIu64 " blocks)\n"),
- lino, totblocks);
- break;
- case XR_INO_SOCK:
- do_warn(
-_("size of socket inode %" PRIu64 " != 0 (%" PRIu64 " blocks)\n"),
- lino, totblocks);
- break;
- case XR_INO_FIFO:
- do_warn(
-_("size of fifo inode %" PRIu64 " != 0 (%" PRIu64 " blocks)\n"),
- lino, totblocks);
- break;
- default:
- return(0);
- }
- return(1);
- }
- return (0);
-}
-
static inline int
dinode_fmt(
struct xfs_dinode *dino)
case XR_INO_BLKDEV:
case XR_INO_SOCK:
case XR_INO_FIFO:
- if (process_misc_ino_types(mp, dino, lino, type))
- return 1;
- break;
-
case XR_INO_UQUOTA:
case XR_INO_GQUOTA:
case XR_INO_PQUOTA:
- /* Quota inodes have same restrictions as above types */
- if (process_misc_ino_types(mp, dino, lino, type))
+ /*
+ * Misc inode types that have no associated data storage (fifos,
+ * pipes, devices, etc.) and thus must also have a zero size.
+ */
+ if (dino->di_size != 0) {
+ do_warn(
+_("size of %s inode %" PRIu64 " != 0 (%" PRId64 " bytes)\n"),
+ _(xr_ino_type_name[type]), lino,
+ (int64_t)be64_to_cpu(dino->di_size));
return 1;
+ }
break;
case XR_INO_RTDATA:
dino = *dinop;
/*
- * enforce totblocks is 0 for misc types
+ * Enforce totblocks is 0 for misc types.
+ *
+ * Note that di_nblocks includes attribute fork blocks, so we can only
+ * do this here instead of when reading the inode.
*/
- if (process_misc_ino_types_blocks(totblocks, lino, type))
- goto clear_bad_out;
+ switch (type) {
+ case XR_INO_CHRDEV:
+ case XR_INO_BLKDEV:
+ case XR_INO_SOCK:
+ case XR_INO_FIFO:
+ if (totblocks != 0) {
+ do_warn(
+_("size of %s inode %" PRIu64 " != 0 (%" PRIu64 " blocks)\n"),
+ _(xr_ino_type_name[type]), lino, totblocks);
+ goto clear_bad_out;
+ }
+ break;
+ default:
+ break;
+ }
/*
* correct space counters if required