Skip to content

Commit

Permalink
VFS: Performance improvement and build fixes
Browse files Browse the repository at this point in the history
- Purge all potential build errors, including switch statements
with system macros, struct member names that are potential macros,
and void* arithmetic.
- Fix a performance issue in VFS where every traverse would take
O(n^2) instead of O(n).
- Take advantage of the PATH_MAX and NAME_MAX constants to use static
buffers and improve string performance.
  • Loading branch information
trungnt2910 committed Mar 9, 2023
1 parent 30250cc commit cf3992b
Show file tree
Hide file tree
Showing 6 changed files with 927 additions and 792 deletions.
156 changes: 78 additions & 78 deletions blink/devfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,90 +37,90 @@ static int DevfsInit(const char *source, u64 flags, const void *data,

struct VfsSystem g_devfs = {.name = "devfs",
.ops = {
.init = DevfsInit,
.freeinfo = HostfsFreeInfo,
.freedevice = HostfsFreeDevice,
.finddir = HostfsFinddir,
.readlink = HostfsReadlink,
.mkdir = HostfsMkdir,
.mkfifo = HostfsMkfifo,
.open = HostfsOpen,
.access = HostfsAccess,
.stat = HostfsStat,
.fstat = HostfsFstat,
.chmod = HostfsChmod,
.fchmod = HostfsFchmod,
.chown = HostfsChown,
.fchown = HostfsFchown,
.ftruncate = HostfsFtruncate,
.link = HostfsLink,
.unlink = HostfsUnlink,
.read = HostfsRead,
.write = HostfsWrite,
.pread = HostfsPread,
.pwrite = HostfsPwrite,
.readv = HostfsReadv,
.writev = HostfsWritev,
.preadv = HostfsPreadv,
.pwritev = HostfsPwritev,
.seek = HostfsSeek,
.fsync = HostfsFsync,
.fdatasync = HostfsFdatasync,
.flock = HostfsFlock,
.fcntl = HostfsFcntl,
.ioctl = HostfsIoctl,
.dup = HostfsDup,
.Init = DevfsInit,
.Freeinfo = HostfsFreeInfo,
.Freedevice = HostfsFreeDevice,
.Finddir = HostfsFinddir,
.Readlink = HostfsReadlink,
.Mkdir = HostfsMkdir,
.Mkfifo = HostfsMkfifo,
.Open = HostfsOpen,
.Access = HostfsAccess,
.Stat = HostfsStat,
.Fstat = HostfsFstat,
.Chmod = HostfsChmod,
.Fchmod = HostfsFchmod,
.Chown = HostfsChown,
.Fchown = HostfsFchown,
.Ftruncate = HostfsFtruncate,
.Link = HostfsLink,
.Unlink = HostfsUnlink,
.Read = HostfsRead,
.Write = HostfsWrite,
.Pread = HostfsPread,
.Pwrite = HostfsPwrite,
.Readv = HostfsReadv,
.Writev = HostfsWritev,
.Preadv = HostfsPreadv,
.Pwritev = HostfsPwritev,
.Seek = HostfsSeek,
.Fsync = HostfsFsync,
.Fdatasync = HostfsFdatasync,
.Flock = HostfsFlock,
.Fcntl = HostfsFcntl,
.Ioctl = HostfsIoctl,
.Dup = HostfsDup,
#ifdef HAVE_DUP3
.dup3 = HostfsDup3,
.Dup3 = HostfsDup3,
#endif
.poll = HostfsPoll,
.opendir = HostfsOpendir,
.Poll = HostfsPoll,
.Opendir = HostfsOpendir,
#ifdef HAVE_SEEKDIR
.seekdir = HostfsSeekdir,
.telldir = HostfsTelldir,
.Seekdir = HostfsSeekdir,
.Telldir = HostfsTelldir,
#endif
.readdir = HostfsReaddir,
.rewinddir = HostfsRewinddir,
.closedir = HostfsClosedir,
.bind = HostfsBind,
.connect = HostfsConnect,
.connectunix = HostfsConnectUnix,
.accept = HostfsAccept,
.listen = HostfsListen,
.shutdown = HostfsShutdown,
.recvmsg = HostfsRecvmsg,
.sendmsg = HostfsSendmsg,
.recvmsgunix = HostfsRecvmsgUnix,
.sendmsgunix = HostfsSendmsgUnix,
.getsockopt = HostfsGetsockopt,
.setsockopt = HostfsSetsockopt,
.getsockname = HostfsGetsockname,
.getpeername = HostfsGetpeername,
.rename = HostfsRename,
.utime = HostfsUtime,
.futime = HostfsFutime,
.symlink = HostfsSymlink,
.mmap = HostfsMmap,
.munmap = HostfsMunmap,
.mprotect = HostfsMprotect,
.msync = HostfsMsync,
.pipe = NULL,
.Readdir = HostfsReaddir,
.Rewinddir = HostfsRewinddir,
.Closedir = HostfsClosedir,
.Bind = HostfsBind,
.Connect = HostfsConnect,
.Connectunix = HostfsConnectUnix,
.Accept = HostfsAccept,
.Listen = HostfsListen,
.Shutdown = HostfsShutdown,
.Recvmsg = HostfsRecvmsg,
.Sendmsg = HostfsSendmsg,
.Recvmsgunix = HostfsRecvmsgUnix,
.Sendmsgunix = HostfsSendmsgUnix,
.Getsockopt = HostfsGetsockopt,
.Setsockopt = HostfsSetsockopt,
.Getsockname = HostfsGetsockname,
.Getpeername = HostfsGetpeername,
.Rename = HostfsRename,
.Utime = HostfsUtime,
.Futime = HostfsFutime,
.Symlink = HostfsSymlink,
.Mmap = HostfsMmap,
.Munmap = HostfsMunmap,
.Mprotect = HostfsMprotect,
.Msync = HostfsMsync,
.Pipe = NULL,
#ifdef HAVE_PIPE2
.pipe2 = NULL,
.Pipe2 = NULL,
#endif
.socket = NULL,
.socketpair = NULL,
.tcgetattr = NULL,
.tcsetattr = NULL,
.tcflush = NULL,
.tcdrain = NULL,
.tcsendbreak = NULL,
.tcflow = NULL,
.tcgetsid = NULL,
.tcgetpgrp = NULL,
.tcsetpgrp = NULL,
.sockatmark = NULL,
.fexecve = NULL,
.Socket = NULL,
.Socketpair = NULL,
.Tcgetattr = NULL,
.Tcsetattr = NULL,
.Tcflush = NULL,
.Tcdrain = NULL,
.Tcsendbreak = NULL,
.Tcflow = NULL,
.Tcgetsid = NULL,
.Tcgetpgrp = NULL,
.Tcsetpgrp = NULL,
.Sockatmark = NULL,
.Fexecve = NULL,
}};

#endif /* DISABLE_VFS */
Loading

0 comments on commit cf3992b

Please sign in to comment.