lib/loopdev: Set errno in is_loopdev on error
The function is_loopdev does not set errno if the supplied string does not reference a valid loop device. Fix this to avoid an error message like this one: losetup: /: failed to use device: Success I prefer this one: losetup: /: failed to use device: No such device Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
This commit is contained in:
parent
2480b52743
commit
cb129d9cc4
|
@ -633,12 +633,13 @@ int is_loopdev(const char *device)
|
|||
{
|
||||
struct stat st;
|
||||
|
||||
if (!device)
|
||||
return 0;
|
||||
|
||||
return (stat(device, &st) == 0 &&
|
||||
if (device && stat(device, &st) == 0 &&
|
||||
S_ISBLK(st.st_mode) &&
|
||||
major(st.st_rdev) == LOOPDEV_MAJOR);
|
||||
major(st.st_rdev) == LOOPDEV_MAJOR)
|
||||
return 1;
|
||||
|
||||
errno = ENODEV;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue