summaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'common.c')
-rw-r--r--common.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/common.c b/common.c
index 754c7ac..96f1747 100644
--- a/common.c
+++ b/common.c
@@ -11,6 +11,7 @@
#include <string.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include "pot.h"
#include "common.h"
@@ -59,6 +60,34 @@ char *sstrdup(const char *s)
return r;
}
+int devcmp(const char *mtab_dev, char *user_dev)
+{
+ struct stat mtab_stat, user_stat;
+
+ if (stat(mtab_dev, &mtab_stat) < 0 || stat(user_dev, &user_stat) < 0)
+ return (strcmp(mtab_dev, user_dev) == 0);
+ if (!S_ISBLK(mtab_stat.st_mode) || !S_ISBLK(user_stat.st_mode))
+ return 0;
+ if (mtab_stat.st_rdev != user_stat.st_rdev)
+ return 0;
+ return 1;
+}
+
+int dircmp(char *mtab_dir, char *user_dir)
+{
+ struct stat mtab_stat, user_stat;
+
+ if (stat(mtab_dir, &mtab_stat) < 0 || stat(user_dir, &user_stat) < 0)
+ return (strcmp(mtab_dir, user_dir) == 0);
+ if (!S_ISDIR(mtab_stat.st_mode) || !S_ISDIR(user_stat.st_mode))
+ return 0;
+ if (mtab_stat.st_dev != user_stat.st_dev)
+ return 0;
+ if (mtab_stat.st_ino != user_stat.st_ino)
+ return 0;
+ return 1;
+}
+
void version(void)
{
printf(_("Quota utilities version %s.\n"), QUOTA_VERSION);