forked from Mirrors/btrfs-progs
btrfs-progs: let test_isdir return the exact error
Return any error from stat, normalize the return value in case the path is a directory. Signed-off-by: David Sterba <dsterba@suse.com>master
parent
2078848983
commit
1267c58e58
16
utils.c
16
utils.c
|
@ -2799,11 +2799,11 @@ int test_issubvolname(const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test if path is a directory
|
* Test if path is a directory
|
||||||
* this function return
|
* Returns:
|
||||||
* 0-> path exists but it is not a directory
|
* 0 - path exists but it is not a directory
|
||||||
* 1-> path exists and it is a directory
|
* 1 - path exists and it is a directory
|
||||||
* -1 -> path is unaccessible
|
* < 0 - error
|
||||||
*/
|
*/
|
||||||
int test_isdir(const char *path)
|
int test_isdir(const char *path)
|
||||||
{
|
{
|
||||||
|
@ -2811,10 +2811,10 @@ int test_isdir(const char *path)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = stat(path, &st);
|
ret = stat(path, &st);
|
||||||
if(ret < 0 )
|
if (ret < 0)
|
||||||
return -1;
|
return -errno;
|
||||||
|
|
||||||
return S_ISDIR(st.st_mode);
|
return !!S_ISDIR(st.st_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void units_set_mode(unsigned *units, unsigned mode)
|
void units_set_mode(unsigned *units, unsigned mode)
|
||||||
|
|
Loading…
Reference in New Issue