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
24
tools-util.c
24
tools-util.c
@ -122,7 +122,7 @@ struct stat xstat(const char *path)
|
||||
{
|
||||
struct stat statbuf;
|
||||
if (stat(path, &statbuf))
|
||||
die("stat error: %m");
|
||||
die("stat error statting %s: %m", path);
|
||||
return statbuf;
|
||||
}
|
||||
|
||||
@ -619,6 +619,8 @@ char *dev_to_mount(char *dev)
|
||||
if (!f)
|
||||
die("error opening /proc/mounts: %m");
|
||||
|
||||
struct stat d1 = xstat(dev);
|
||||
|
||||
while (getline(&line, &n, f) != -1) {
|
||||
char *d, *p = line;
|
||||
char *devs = strsep(&p, " ");
|
||||
@ -628,8 +630,24 @@ char *dev_to_mount(char *dev)
|
||||
continue;
|
||||
|
||||
p = devs;
|
||||
while ((d = strsep(&p, ":")))
|
||||
if (!strcmp(d, dev)) {
|
||||
while ((d = strsep(&p, ":"))) {
|
||||
struct stat d2;
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user