summaryrefslogtreecommitdiff
path: root/quotasys.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2020-10-19 17:44:46 +0200
committerJan Kara <jack@suse.cz>2020-10-19 17:44:46 +0200
commit7b89abbc983d6cf7f1baf52a9ad90211eee02103 (patch)
tree5194bff22a5111f401821fb622871a86a58f4995 /quotasys.c
parent4aac5400dfd61416ffe7ff912f32061854e57e45 (diff)
quotacheck,quotaon: Suggest using quota feature for ext4
Ext4 supports quota using internal quota files for quite some time. Suggest using this quota feature instead of external quota files if the kernel is new enough since external quota files on ext4 will be deprecated. Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'quotasys.c')
-rw-r--r--quotasys.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/quotasys.c b/quotasys.c
index d8c0e48..885fb1f 100644
--- a/quotasys.c
+++ b/quotasys.c
@@ -24,6 +24,7 @@
#include <sys/stat.h>
#include <sys/vfs.h>
#include <stdint.h>
+#include <sys/utsname.h>
#include "pot.h"
#include "bylabel.h"
@@ -1597,3 +1598,29 @@ void end_mounts_scan(void)
check_dirs = NULL;
check_dirs_cnt = 0;
}
+
+/* Parse kernel version and return 1 if ext4 supports quota feature */
+int ext4_supports_quota_feature(void)
+{
+ struct utsname stats;
+ int v;
+ char *errch;
+
+ if (uname(&stats) < 0) {
+ errstr(_("Cannot get system info: %s\n"), strerror(errno));
+ return 0;
+ }
+ if (strcmp(stats.sysname, "Linux"))
+ return 0;
+ v = strtol(stats.release, &errch, 10);
+ if (v < 4)
+ return 0;
+ if (v > 4)
+ return 1;
+ if (*errch != '.')
+ return 0;
+ v = strtol(errch + 1, &errch, 10);
+ if (*errch != '.' || v < 9)
+ return 0;
+ return 1;
+}