And let's also ask the kernel explicitly for support.
"xfs");
}
+bool fstype_can_norecovery(const char *fstype) {
+ int r;
+
+ assert(fstype);
+
+ /* On new kernels we can just ask the kernel */
+ r = mount_option_supported(fstype, "norecovery", NULL);
+ if (r >= 0)
+ return r;
+
+ return STR_IN_SET(fstype,
+ "ext3",
+ "ext4",
+ "xfs",
+ "btrfs");
+}
+
bool fstype_can_uid_gid(const char *fstype) {
/* All file systems that have a uid=/gid= mount option that fixates the owners of all files and directories,
bool fstype_is_ro(const char *fsype);
bool fstype_can_discard(const char *fstype);
bool fstype_can_uid_gid(const char *fstype);
+bool fstype_can_norecovery(const char *fstype);
int dev_is_devtmpfs(void);
* access that actually modifies stuff work on such image files. Or to say this differently: if
* people want their file systems to be fixed up they should just open them in writable mode, where
* all these problems don't exist. */
- if (!rw && STRPTR_IN_SET(fstype, "ext3", "ext4", "xfs", "btrfs"))
+ if (!rw && fstype && fstype_can_norecovery(fstype))
if (!strextend_with_separator(&options, ",", "norecovery"))
return -ENOMEM;
assert_se(!fstype_can_discard("iso9660"));
}
+TEST(fstype_can_norecovery) {
+ assert_se(fstype_can_norecovery("ext4"));
+ assert_se(!fstype_can_norecovery("vfat"));
+ assert_se(!fstype_can_norecovery("tmpfs"));
+}
+
static int intro(void) {
/* let's move into our own mount namespace with all propagation from the host turned off, so
* that /proc/self/mountinfo is static and constant for the whole time our test runs. */