mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
improve dev_to_mount()
should fix a bug where resize does an offline resize when the fs was mounted because it thought it wasn't mounted
This commit is contained in:
parent
55fbb25501
commit
67fb317a07
28
tools-util.c
28
tools-util.c
@ -122,7 +122,7 @@ struct stat xstat(const char *path)
|
|||||||
{
|
{
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
if (stat(path, &statbuf))
|
if (stat(path, &statbuf))
|
||||||
die("stat error: %m");
|
die("stat error statting %s: %m", path);
|
||||||
return statbuf;
|
return statbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,6 +619,8 @@ char *dev_to_mount(char *dev)
|
|||||||
if (!f)
|
if (!f)
|
||||||
die("error opening /proc/mounts: %m");
|
die("error opening /proc/mounts: %m");
|
||||||
|
|
||||||
|
struct stat d1 = xstat(dev);
|
||||||
|
|
||||||
while (getline(&line, &n, f) != -1) {
|
while (getline(&line, &n, f) != -1) {
|
||||||
char *d, *p = line;
|
char *d, *p = line;
|
||||||
char *devs = strsep(&p, " ");
|
char *devs = strsep(&p, " ");
|
||||||
@ -628,11 +630,27 @@ char *dev_to_mount(char *dev)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
p = devs;
|
p = devs;
|
||||||
while ((d = strsep(&p, ":")))
|
while ((d = strsep(&p, ":"))) {
|
||||||
if (!strcmp(d, dev)) {
|
struct stat d2;
|
||||||
ret = strdup(mount);
|
|
||||||
goto found;
|
if (stat(d, &d2))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (S_ISBLK(d1.st_mode) != S_ISBLK(d2.st_mode))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (S_ISBLK(d1.st_mode)) {
|
||||||
|
if (d1.st_rdev != d2.st_rdev)
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
if (d1.st_dev != d2.st_dev ||
|
||||||
|
d1.st_ino != d2.st_ino)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = strdup(mount);
|
||||||
|
goto found;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
found:
|
found:
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
Loading…
Reference in New Issue
Block a user