Skip to content

Commit 45b7228

Browse files
pcercueiQuzarDC
authored andcommitted
fs: Add workaround for fs_stat() on mount points
The various VFS handlers may not implement a .stat backend function. For instance, the socket VFS does not implement any. However, we still want to be able to tell that /sock is a directory and not a file. Add a workaround, so that if we're trying to fs_stat() a mount point, and the corresponding VFS does not provide a .stat backend function, we just return it as a 0777 directory. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
1 parent d02cfe3 commit 45b7228

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

kernel/fs/fs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,13 @@ int fs_stat(const char *path, struct stat *buf, int flag) {
868868
return vfs->stat(vfs, fullpath + strlen(vfs->nmmgr.pathname), buf,
869869
flag);
870870
}
871+
else if(!strcmp(path, vfs->nmmgr.pathname)) {
872+
/* no vfs->stat - handle stat() on the mount folder */
873+
*buf = (struct stat){
874+
.st_mode = S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO,
875+
};
876+
return 0;
877+
}
871878
else {
872879
errno = ENOSYS;
873880
return -1;

0 commit comments

Comments
 (0)