aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/super.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-02-02 23:38:39 -0500
committerTheodore Ts'o <tytso@mit.edu>2013-02-02 23:38:39 -0500
commit8dc0aa8cf0f7b51e6c7c342e6f1e61520fb94222 (patch)
tree812e145409cb7f2619384f91111809c018ff3103 /fs/ext4/super.c
parente33e60eaed5353c9e6863124ad1081a38640db4b (diff)
ext4: check incompatible mount options while mounting ext2/3
Check for incompatible mount options when using the ext4 file system driver to mount ext2 or ext3 file systems. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r--fs/ext4/super.c47
1 files changed, 35 insertions, 12 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index b68f4b671bc7..2e1f94704b1f 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1406,6 +1406,9 @@ static int clear_qf_name(struct super_block *sb, int qtype)
1406#define MOPT_QFMT MOPT_NOSUPPORT 1406#define MOPT_QFMT MOPT_NOSUPPORT
1407#endif 1407#endif
1408#define MOPT_DATAJ 0x0080 1408#define MOPT_DATAJ 0x0080
1409#define MOPT_NO_EXT2 0x0100
1410#define MOPT_NO_EXT3 0x0200
1411#define MOPT_EXT4_ONLY (MOPT_NO_EXT2 | MOPT_NO_EXT3)
1409 1412
1410static const struct mount_opts { 1413static const struct mount_opts {
1411 int token; 1414 int token;
@@ -1418,21 +1421,29 @@ static const struct mount_opts {
1418 {Opt_nogrpid, EXT4_MOUNT_GRPID, MOPT_CLEAR}, 1421 {Opt_nogrpid, EXT4_MOUNT_GRPID, MOPT_CLEAR},
1419 {Opt_block_validity, EXT4_MOUNT_BLOCK_VALIDITY, MOPT_SET}, 1422 {Opt_block_validity, EXT4_MOUNT_BLOCK_VALIDITY, MOPT_SET},
1420 {Opt_noblock_validity, EXT4_MOUNT_BLOCK_VALIDITY, MOPT_CLEAR}, 1423 {Opt_noblock_validity, EXT4_MOUNT_BLOCK_VALIDITY, MOPT_CLEAR},
1421 {Opt_dioread_nolock, EXT4_MOUNT_DIOREAD_NOLOCK, MOPT_SET}, 1424 {Opt_dioread_nolock, EXT4_MOUNT_DIOREAD_NOLOCK,
1422 {Opt_dioread_lock, EXT4_MOUNT_DIOREAD_NOLOCK, MOPT_CLEAR}, 1425 MOPT_EXT4_ONLY | MOPT_SET},
1426 {Opt_dioread_lock, EXT4_MOUNT_DIOREAD_NOLOCK,
1427 MOPT_EXT4_ONLY | MOPT_CLEAR},
1423 {Opt_discard, EXT4_MOUNT_DISCARD, MOPT_SET}, 1428 {Opt_discard, EXT4_MOUNT_DISCARD, MOPT_SET},
1424 {Opt_nodiscard, EXT4_MOUNT_DISCARD, MOPT_CLEAR}, 1429 {Opt_nodiscard, EXT4_MOUNT_DISCARD, MOPT_CLEAR},
1425 {Opt_delalloc, EXT4_MOUNT_DELALLOC, MOPT_SET | MOPT_EXPLICIT}, 1430 {Opt_delalloc, EXT4_MOUNT_DELALLOC,
1426 {Opt_nodelalloc, EXT4_MOUNT_DELALLOC, MOPT_CLEAR | MOPT_EXPLICIT}, 1431 MOPT_EXT4_ONLY | MOPT_SET | MOPT_EXPLICIT},
1427 {Opt_journal_checksum, EXT4_MOUNT_JOURNAL_CHECKSUM, MOPT_SET}, 1432 {Opt_nodelalloc, EXT4_MOUNT_DELALLOC,
1433 MOPT_EXT4_ONLY | MOPT_CLEAR | MOPT_EXPLICIT},
1434 {Opt_journal_checksum, EXT4_MOUNT_JOURNAL_CHECKSUM,
1435 MOPT_EXT4_ONLY | MOPT_SET},
1428 {Opt_journal_async_commit, (EXT4_MOUNT_JOURNAL_ASYNC_COMMIT | 1436 {Opt_journal_async_commit, (EXT4_MOUNT_JOURNAL_ASYNC_COMMIT |
1429 EXT4_MOUNT_JOURNAL_CHECKSUM), MOPT_SET}, 1437 EXT4_MOUNT_JOURNAL_CHECKSUM),
1430 {Opt_noload, EXT4_MOUNT_NOLOAD, MOPT_SET}, 1438 MOPT_EXT4_ONLY | MOPT_SET},
1439 {Opt_noload, EXT4_MOUNT_NOLOAD, MOPT_NO_EXT2 | MOPT_SET},
1431 {Opt_err_panic, EXT4_MOUNT_ERRORS_PANIC, MOPT_SET | MOPT_CLEAR_ERR}, 1440 {Opt_err_panic, EXT4_MOUNT_ERRORS_PANIC, MOPT_SET | MOPT_CLEAR_ERR},
1432 {Opt_err_ro, EXT4_MOUNT_ERRORS_RO, MOPT_SET | MOPT_CLEAR_ERR}, 1441 {Opt_err_ro, EXT4_MOUNT_ERRORS_RO, MOPT_SET | MOPT_CLEAR_ERR},
1433 {Opt_err_cont, EXT4_MOUNT_ERRORS_CONT, MOPT_SET | MOPT_CLEAR_ERR}, 1442 {Opt_err_cont, EXT4_MOUNT_ERRORS_CONT, MOPT_SET | MOPT_CLEAR_ERR},
1434 {Opt_data_err_abort, EXT4_MOUNT_DATA_ERR_ABORT, MOPT_SET}, 1443 {Opt_data_err_abort, EXT4_MOUNT_DATA_ERR_ABORT,
1435 {Opt_data_err_ignore, EXT4_MOUNT_DATA_ERR_ABORT, MOPT_CLEAR}, 1444 MOPT_NO_EXT2 | MOPT_SET},
1445 {Opt_data_err_ignore, EXT4_MOUNT_DATA_ERR_ABORT,
1446 MOPT_NO_EXT2 | MOPT_CLEAR},
1436 {Opt_barrier, EXT4_MOUNT_BARRIER, MOPT_SET}, 1447 {Opt_barrier, EXT4_MOUNT_BARRIER, MOPT_SET},
1437 {Opt_nobarrier, EXT4_MOUNT_BARRIER, MOPT_CLEAR}, 1448 {Opt_nobarrier, EXT4_MOUNT_BARRIER, MOPT_CLEAR},
1438 {Opt_noauto_da_alloc, EXT4_MOUNT_NO_AUTO_DA_ALLOC, MOPT_SET}, 1449 {Opt_noauto_da_alloc, EXT4_MOUNT_NO_AUTO_DA_ALLOC, MOPT_SET},
@@ -1448,9 +1459,10 @@ static const struct mount_opts {
1448 {Opt_resgid, 0, MOPT_GTE0}, 1459 {Opt_resgid, 0, MOPT_GTE0},
1449 {Opt_journal_dev, 0, MOPT_GTE0}, 1460 {Opt_journal_dev, 0, MOPT_GTE0},
1450 {Opt_journal_ioprio, 0, MOPT_GTE0}, 1461 {Opt_journal_ioprio, 0, MOPT_GTE0},
1451 {Opt_data_journal, EXT4_MOUNT_JOURNAL_DATA, MOPT_DATAJ}, 1462 {Opt_data_journal, EXT4_MOUNT_JOURNAL_DATA, MOPT_NO_EXT2 | MOPT_DATAJ},
1452 {Opt_data_ordered, EXT4_MOUNT_ORDERED_DATA, MOPT_DATAJ}, 1463 {Opt_data_ordered, EXT4_MOUNT_ORDERED_DATA, MOPT_NO_EXT2 | MOPT_DATAJ},
1453 {Opt_data_writeback, EXT4_MOUNT_WRITEBACK_DATA, MOPT_DATAJ}, 1464 {Opt_data_writeback, EXT4_MOUNT_WRITEBACK_DATA,
1465 MOPT_NO_EXT2 | MOPT_DATAJ},
1454 {Opt_user_xattr, EXT4_MOUNT_XATTR_USER, MOPT_SET}, 1466 {Opt_user_xattr, EXT4_MOUNT_XATTR_USER, MOPT_SET},
1455 {Opt_nouser_xattr, EXT4_MOUNT_XATTR_USER, MOPT_CLEAR}, 1467 {Opt_nouser_xattr, EXT4_MOUNT_XATTR_USER, MOPT_CLEAR},
1456#ifdef CONFIG_EXT4_FS_POSIX_ACL 1468#ifdef CONFIG_EXT4_FS_POSIX_ACL
@@ -1528,6 +1540,17 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
1528 return -1; 1540 return -1;
1529 } 1541 }
1530 1542
1543 if ((m->flags & MOPT_NO_EXT2) && IS_EXT2_SB(sb)) {
1544 ext4_msg(sb, KERN_ERR,
1545 "Mount option \"%s\" incompatible with ext2", opt);
1546 return -1;
1547 }
1548 if ((m->flags & MOPT_NO_EXT3) && IS_EXT3_SB(sb)) {
1549 ext4_msg(sb, KERN_ERR,
1550 "Mount option \"%s\" incompatible with ext3", opt);
1551 return -1;
1552 }
1553
1531 if (args->from && match_int(args, &arg)) 1554 if (args->from && match_int(args, &arg))
1532 return -1; 1555 return -1;
1533 if (args->from && (m->flags & MOPT_GTE0) && (arg < 0)) 1556 if (args->from && (m->flags & MOPT_GTE0) && (arg < 0))