Skip to content

Commit

Permalink
lib/vfscore: No-op mkmp on /
Browse files Browse the repository at this point in the history
Issuing `mkdir` on `/` will result in `ENOTDIR` and it is also
unnecessary. Therefore, add a check for this case so that we can
ignore.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: unikraft#1376
  • Loading branch information
mogasergiu authored and SerbanSo committed Apr 22, 2024
1 parent 678f6c6 commit 8f165ae
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/vfscore/automount.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,11 @@ static int vfscore_ukopt_mkmp(char *path)
UK_ASSERT(path);
UK_ASSERT(path[0] == '/');

if (path[1] == '\0') {
uk_pr_debug(" mkmp: Called on '/', nothing to pre-create\n");
return 0;
}

uk_pr_debug(" mkmp: Ensure mount path \"%s\" exists\n", path);
pos = path;
do {
Expand Down Expand Up @@ -620,6 +625,7 @@ static int vfscore_ukopt_mkmp(char *path)
*/
static inline int vfscore_mount_volume(const struct vfscore_volume *vv)
{
const char *path;
int rc;

UK_ASSERT(vv);
Expand All @@ -637,6 +643,11 @@ static inline int vfscore_mount_volume(const struct vfscore_volume *vv)
vv->path);
return -EINVAL;
}

path = vv->path;
while (path[1] == '/')
path++;

/* Drv are mandatory */
if (unlikely(!vv->drv || vv->drv[0] == '\0')) {
uk_pr_err("fstab: Entry without filesystem driver\n");
Expand Down Expand Up @@ -669,7 +680,7 @@ static inline int vfscore_mount_volume(const struct vfscore_volume *vv)
vv->ukopts);

if (vv->ukopts & LIBVFSCORE_UKOPT_MKMP) {
rc = vfscore_ukopt_mkmp(vv->path);
rc = vfscore_ukopt_mkmp(path);
if (unlikely(rc < 0))
return rc;
}
Expand All @@ -681,7 +692,7 @@ static inline int vfscore_mount_volume(const struct vfscore_volume *vv)
#endif /* CONFIG_LIBUKCPIO */
{
rc = mount(vv->sdev == NULL ? "" : vv->sdev,
vv->path, vv->drv, vv->flags, vv->opts);
path, vv->drv, vv->flags, vv->opts);
}
if (rc >= 0)
return 1; /* Indicate that we mounted 1 volume */
Expand Down

0 comments on commit 8f165ae

Please sign in to comment.