{
int rc;
+ if (!path)
+ return -EINVAL;
if (!pc) {
rc = access(path, mode);
DBG(CXT, ul_debug("access '%s' [no context, rc=%d]", path, rc));
int dir = ul_path_get_dirfd(pc);
if (dir < 0)
return dir;
- if (path && *path == '/')
+ if (*path == '/')
path++;
rc = faccessat(dir, path, mode, 0);
return !p ? -errno : ul_path_access(pc, mode, p);
}
+/*
+ * If @path is NULL, then stat() is called for the directory itself addressed by @pc.
+ */
int ul_path_stat(struct path_cxt *pc, struct stat *sb, int flags, const char *path)
{
int rc;
return rc;
}
#ifdef HAVE_STATX
+/*
+* This function follows the semantics of statx(). To call statx() for the directory
+* itself addressed by @pc, use an empty string and the AT_EMPTY_PATH @flag.
+*/
int ul_path_statx(struct path_cxt *pc, struct statx *stx, int flags, unsigned int mask,
const char *path)
{
int rc;
+ if (!path)
+ return -EINVAL;
if (!pc)
rc = path ? statx(AT_FDCWD, path, flags, mask, stx) : - EINVAL;
else {
int dir = ul_path_get_dirfd(pc);
if (dir < 0)
return dir;
- if (path && *path == '/')
+ if (*path == '/')
path++;
rc = statx(dir, path, flags, mask, stx);