1
0
Fork 0

Merging upstream version 4.2+20230302.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-14 06:03:59 +01:00
parent 77490f6daf
commit b9108d544e
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
3 changed files with 377 additions and 162 deletions

45
util.c
View file

@ -2401,3 +2401,48 @@ void sleep_for(unsigned int sec, long nsec, bool wake_after_interrupt)
}
} while (!wake_after_interrupt && errno == EINTR);
}
/* is_directory() - Checks if directory provided by path is indeed a regular directory.
* @path: directory path to be checked
*
* Doesn't accept symlinks.
*
* Return: true if is a directory, false if not
*/
bool is_directory(const char *path)
{
struct stat st;
if (lstat(path, &st) != 0) {
pr_err("%s: %s\n", strerror(errno), path);
return false;
}
if (!S_ISDIR(st.st_mode))
return false;
return true;
}
/*
* is_file() - Checks if file provided by path is indeed a regular file.
* @path: file path to be checked
*
* Doesn't accept symlinks.
*
* Return: true if is a file, false if not
*/
bool is_file(const char *path)
{
struct stat st;
if (lstat(path, &st) != 0) {
pr_err("%s: %s\n", strerror(errno), path);
return false;
}
if (!S_ISREG(st.st_mode))
return false;
return true;
}