[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH v2 10/23] lib/vfscore: add utility funcs&defs to support imported



Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
---
 lib/vfscore/include/vfscore/file.h  |  2 ++
 lib/vfscore/include/vfscore/fs.h    | 28 ++++++++++++++++++++++++
 lib/vfscore/include/vfscore/vnode.h | 21 ++++++++++++++++++
 lib/vfscore/main.c                  | 33 +++++++++++++++++++++++++++++
 lib/vfscore/mount.c                 | 17 +++++++++++++++
 lib/vfscore/vfs.h                   |  9 ++++++++
 lib/vfscore/vnode.c                 |  2 ++
 7 files changed, 112 insertions(+)
 create mode 100644 lib/vfscore/include/vfscore/fs.h

diff --git a/lib/vfscore/include/vfscore/file.h 
b/lib/vfscore/include/vfscore/file.h
index 7387265d..68bbf92c 100644
--- a/lib/vfscore/include/vfscore/file.h
+++ b/lib/vfscore/include/vfscore/file.h
@@ -62,6 +62,8 @@ void vfscore_put_fd(int fd);
 void vfscore_install_fd(int fd, struct vfscore_file *file);
 struct vfscore_file *vfscore_get_file(int fd);
 
+#define FOF_OFFSET  0x0800    /* Use the offset in uio argument */
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/vfscore/include/vfscore/fs.h b/lib/vfscore/include/vfscore/fs.h
new file mode 100644
index 00000000..1bb4e24d
--- /dev/null
+++ b/lib/vfscore/include/vfscore/fs.h
@@ -0,0 +1,28 @@
+#ifndef _VFSCORE_FS_H_
+#define _VFSCORE_FS_H_
+
+#include <fcntl.h>
+/*
+ * Kernel encoding of open mode; separate read and write bits that are
+ * independently testable: 1 greater than the above.
+ */
+#define FREAD           0x00000001
+#define FWRITE          0x00000002
+
+#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
+
+static inline int vfscore_fflags(int oflags)
+{
+    int rw = oflags & O_ACCMODE;
+    oflags &= ~O_ACCMODE;
+    return (rw + 1) | oflags;
+}
+
+static inline int vfscore_oflags(int fflags)
+{
+    int rw = fflags & (FREAD|FWRITE);
+    fflags &= ~(FREAD|FWRITE);
+    return (rw - 1) | fflags;
+}
+
+#endif /* _VFSCORE_FS_H_ */
diff --git a/lib/vfscore/include/vfscore/vnode.h 
b/lib/vfscore/include/vfscore/vnode.h
index a4db9c13..4155a7db 100644
--- a/lib/vfscore/include/vfscore/vnode.h
+++ b/lib/vfscore/include/vfscore/vnode.h
@@ -108,6 +108,27 @@ struct vattr {
        off_t           va_size;
 };
 
+/* struct vattr is used to consolidate multiple types of file
+ * attributes for passing them as function parameters. Macros bellow
+ * are selectors, of what types of attributes are valid in particular
+ * struct vattr*/
+#define        AT_TYPE         0x00001
+#define        AT_MODE         0x00002
+#define        AT_UID          0x00004
+#define        AT_GID          0x00008
+#define        AT_FSID         0x00010
+#define        AT_NODEID       0x00020
+#define        AT_NLINK        0x00040
+#define        AT_SIZE         0x00080
+#define        AT_ATIME        0x00100
+#define        AT_MTIME        0x00200
+#define        AT_CTIME        0x00400
+#define        AT_RDEV         0x00800
+#define        AT_BLKSIZE      0x01000
+#define        AT_NBLOCKS      0x02000
+#define        AT_SEQ          0x08000
+#define        AT_XVATTR       0x10000
+
 /*
  *  Modes.
  */
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 82e45917..1164b30b 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -52,8 +52,41 @@
 int    vfs_debug = VFSDB_FLAGS;
 #endif
 
+/* This macro is for defining an alias of the 64bit version of a
+ * syscall to the regular one. It seams we can make the logic which is
+ * choosing the right call simpler then in common libc.
+ *
+ * Let's keep LFS64 calls just in case in future we will find out that
+ * these aliases are need.
+ */
+#define LFS64(x)
+
 static mode_t global_umask = S_IWGRP | S_IWOTH;
 
+/* TODO: these macro does not belong here
+ * NOTE: borrowed from OSv
+ */
+#define DO_ONCE(thing) do {                            \
+       static int _x;                                  \
+       if (!_x) {                                      \
+           _x = 1;                                     \
+           thing ;                                     \
+       }                                               \
+} while (0)
+#define WARN_STUBBED() DO_ONCE(uk_pr_warn("%s() stubbed\n", __func__))
+
+#define NO_SYS(decl) decl {                            \
+    DO_ONCE(uk_pr_warn("%s not implemented\n", __func__));     \
+    errno = ENOSYS;                                    \
+    return -1;                                         \
+}
+
+static inline int libc_error(int err)
+{
+    errno = err;
+    return -1;
+}
+
 static inline mode_t apply_umask(mode_t mode)
 {
        return mode & ~ukarch_load_n(&global_umask);
diff --git a/lib/vfscore/mount.c b/lib/vfscore/mount.c
index 7d083d6f..e12c0033 100644
--- a/lib/vfscore/mount.c
+++ b/lib/vfscore/mount.c
@@ -79,6 +79,23 @@ fs_getfs(const char *name)
        return fs;
 }
 
+int device_open(const char *name, int mode, struct device **devp)
+{
+       (void) name;
+       (void) mode;
+       (void) devp;
+
+       uk_pr_err("device open is not implemented (%s)\n", name);
+       return 0;
+}
+
+int device_close(struct device *dev)
+{
+       (void) dev;
+       UK_CRASH("not implemented");
+       return 0;
+}
+
 int
 sys_mount(const char *dev, const char *dir, const char *fsname, int flags, 
const void *data)
 {
diff --git a/lib/vfscore/vfs.h b/lib/vfscore/vfs.h
index 19f8ac87..609dc1f5 100644
--- a/lib/vfscore/vfs.h
+++ b/lib/vfscore/vfs.h
@@ -151,4 +151,13 @@ void        vnode_dump(void);
 void    mount_dump(void);
 #endif
 
+static void __attribute__((unused)) uk_vfscore_trace(int foo __unused, ...)
+{
+}
+
+#define TRACEPOINT(trace_name, fmt, ...)                       \
+       static void trace_name(__VA_ARGS__ ) __attribute__((unused, 
alias("uk_vfscore_trace")))
+
+
+
 #endif /* !_VFS_H */
diff --git a/lib/vfscore/vnode.c b/lib/vfscore/vnode.c
index a2f45596..86e6d9c7 100644
--- a/lib/vfscore/vnode.c
+++ b/lib/vfscore/vnode.c
@@ -48,6 +48,8 @@
 #include <vfscore/vnode.h>
 #include "vfs.h"
 
+#define S_BLKSIZE 512
+
 enum vtype iftovt_tab[16] = {
        VNON, VFIFO, VCHR, VNON, VDIR, VNON, VBLK, VNON,
        VREG, VNON, VLNK, VNON, VSOCK, VNON, VNON, VBAD,
-- 
2.19.2


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.