projects
/
project
/
fstools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
block: simplify code picking mount target directory
[project/fstools.git]
/
block.c
diff --git
a/block.c
b/block.c
index b377429c61f5ab19d88a18fc25ebe2744eba6d80..0671aca6d0f8231ba9f790859b513ffd75735929 100644
(file)
--- a/
block.c
+++ b/
block.c
@@
-711,6
+711,7
@@
static void check_filesystem(struct probe_info *pr)
const char *f2fsck = "/usr/sbin/fsck.f2fs";
const char *dosfsck = "/usr/sbin/dosfsck";
const char *btrfsck = "/usr/bin/btrfsck";
const char *f2fsck = "/usr/sbin/fsck.f2fs";
const char *dosfsck = "/usr/sbin/dosfsck";
const char *btrfsck = "/usr/bin/btrfsck";
+ const char *ntfsck = "/usr/bin/ntfsfix";
const char *ckfs;
/* UBIFS does not need stuff like fsck */
const char *ckfs;
/* UBIFS does not need stuff like fsck */
@@
-725,6
+726,8
@@
static void check_filesystem(struct probe_info *pr)
ckfs = e2fsck;
} else if (!strncmp(pr->type, "btrfs", 5)) {
ckfs = btrfsck;
ckfs = e2fsck;
} else if (!strncmp(pr->type, "btrfs", 5)) {
ckfs = btrfsck;
+ } else if (!strncmp(pr->type, "ntfs", 4)) {
+ ckfs = ntfsck;
} else {
ULOG_ERR("check_filesystem: %s is not supported\n", pr->type);
return;
} else {
ULOG_ERR("check_filesystem: %s is not supported\n", pr->type);
return;
@@
-739,20
+742,25
@@
static void check_filesystem(struct probe_info *pr)
if (!pid) {
if(!strncmp(pr->type, "f2fs", 4)) {
execl(ckfs, ckfs, "-f", pr->dev, NULL);
if (!pid) {
if(!strncmp(pr->type, "f2fs", 4)) {
execl(ckfs, ckfs, "-f", pr->dev, NULL);
- exit(
-1
);
+ exit(
EXIT_FAILURE
);
} else if(!strncmp(pr->type, "btrfs", 5)) {
execl(ckfs, ckfs, "--repair", pr->dev, NULL);
} else if(!strncmp(pr->type, "btrfs", 5)) {
execl(ckfs, ckfs, "--repair", pr->dev, NULL);
- exit(-1);
+ exit(EXIT_FAILURE);
+ } else if(!strncmp(pr->type, "ntfs", 4)) {
+ execl(ckfs, ckfs, "-b", pr->dev, NULL);
+ exit(EXIT_FAILURE);
} else {
execl(ckfs, ckfs, "-p", pr->dev, NULL);
} else {
execl(ckfs, ckfs, "-p", pr->dev, NULL);
- exit(
-1
);
+ exit(
EXIT_FAILURE
);
}
} else if (pid > 0) {
int status;
waitpid(pid, &status, 0);
}
} else if (pid > 0) {
int status;
waitpid(pid, &status, 0);
- if (WEXITSTATUS(status))
+ if (W
IFEXITED(status) && W
EXITSTATUS(status))
ULOG_ERR("check_filesystem: %s returned %d\n", ckfs, WEXITSTATUS(status));
ULOG_ERR("check_filesystem: %s returned %d\n", ckfs, WEXITSTATUS(status));
+ if (WIFSIGNALED(status))
+ ULOG_ERR("check_filesystem: %s terminated by %s\n", ckfs, strsignal(WTERMSIG(status)));
}
}
}
}
@@
-1013,36
+1021,37
@@
static int mount_device(struct probe_info *pr, int type)
if (m && m->extroot)
return -1;
if (m && m->extroot)
return -1;
- if (m) switch (type) {
- case TYPE_HOTPLUG:
+ if (type == TYPE_HOTPLUG)
blockd_notify(device, m, pr);
blockd_notify(device, m, pr);
- if (m->autofs)
- return 0;
- if (!auto_mount)
- return -1;
- break;
- case TYPE_AUTOFS:
- if (!m->autofs)
- return -1;
- break;
- case TYPE_DEV:
- if (m->autofs)
- return -1;
- break;
- } else if (type == TYPE_HOTPLUG) {
- blockd_notify(device, NULL, pr);
- }
if (m) {
if (m) {
- char *target = m->target;
char _target[32];
char _target[32];
+ char *target;
int err = 0;
int err = 0;
+ switch (type) {
+ case TYPE_HOTPLUG:
+ if (m->autofs)
+ return 0;
+ if (!auto_mount)
+ return -1;
+ break;
+ case TYPE_AUTOFS:
+ if (!m->autofs)
+ return -1;
+ break;
+ case TYPE_DEV:
+ if (m->autofs)
+ return -1;
+ break;
+ }
+
if (m->autofs) {
snprintf(_target, sizeof(_target), "/tmp/run/blockd/%s", device);
target = _target;
if (m->autofs) {
snprintf(_target, sizeof(_target), "/tmp/run/blockd/%s", device);
target = _target;
- }
- if (!target) {
+ } else if (m->target) {
+ target = m->target;
+ } else {
snprintf(_target, sizeof(_target), "/mnt/%s", device);
target = _target;
}
snprintf(_target, sizeof(_target), "/mnt/%s", device);
target = _target;
}
@@
-1437,8
+1446,9
@@
static int mount_extroot(char *cfg)
if (strncmp(pr->type, "ext", 3) &&
strncmp(pr->type, "f2fs", 4) &&
strncmp(pr->type, "btrfs", 5) &&
if (strncmp(pr->type, "ext", 3) &&
strncmp(pr->type, "f2fs", 4) &&
strncmp(pr->type, "btrfs", 5) &&
+ strncmp(pr->type, "ntfs", 4) &&
strncmp(pr->type, "ubifs", 5)) {
strncmp(pr->type, "ubifs", 5)) {
- ULOG_ERR("extroot: unsupported filesystem %s, try ext4, f2fs, btrfs or ubifs\n", pr->type);
+ ULOG_ERR("extroot: unsupported filesystem %s, try ext4, f2fs, btrfs
, ntfs
or ubifs\n", pr->type);
return -1;
}
return -1;
}