diff mbox series

[10/33] Add struct target_freebsd_fhandle and fcntl flags to bsd-user/syscall_defs.h

Message ID 20230808060815.9001-11-kariem.taha2.7@gmail.com
State New
Headers show
Series Implement the stat system calls for FreeBSD. | expand

Commit Message

Karim Taha Aug. 8, 2023, 6:07 a.m. UTC
From: Stacey Son <sson@FreeBSD.org>

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
---
 bsd-user/syscall_defs.h | 51 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

Comments

Richard Henderson Aug. 8, 2023, 9:26 p.m. UTC | #1
On 8/7/23 23:07, Karim Taha wrote:
> +struct target_freebsd_fid {
> +    u_short     fid_len;            /* len of data in bytes */
> +    u_short     fid_data0;          /* force longword align */
> +    char        fid_data[TARGET_MAXFIDSZ];  /* data (variable len) */

uint16_t?

Otherwise,
Acked-by: Richard Henderson <richard.henderson@linaro.org>


r~
Warner Losh Aug. 9, 2023, 2:54 a.m. UTC | #2
On Tue, Aug 8, 2023 at 3:26 PM Richard Henderson <
richard.henderson@linaro.org> wrote:

> On 8/7/23 23:07, Karim Taha wrote:
> > +struct target_freebsd_fid {
> > +    u_short     fid_len;            /* len of data in bytes */
> > +    u_short     fid_data0;          /* force longword align */
> > +    char        fid_data[TARGET_MAXFIDSZ];  /* data (variable len) */
>
> uint16_t?
>

These were copied from FreeBSD's sys/mount.h... Changing to uint16_t likely
is a good idea, though. I'll handle the logistics of making changes like
this in
bsd-user upstream with Kariim.

Warner


> Otherwise,
> Acked-by: Richard Henderson <richard.henderson@linaro.org>
>
diff mbox series

Patch

diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h
index ab59d00a47..608731f0ac 100644
--- a/bsd-user/syscall_defs.h
+++ b/bsd-user/syscall_defs.h
@@ -340,6 +340,57 @@  struct target_statfs {
         char      f_mntonname[1024];    /* directory on which mounted */
 };
 
+/* File identifier. These are unique per filesystem on a single machine. */
+#define TARGET_MAXFIDSZ     16
+
+struct target_freebsd_fid {
+    u_short     fid_len;            /* len of data in bytes */
+    u_short     fid_data0;          /* force longword align */
+    char        fid_data[TARGET_MAXFIDSZ];  /* data (variable len) */
+};
+
+/* Generic file handle */
+struct target_freebsd_fhandle {
+    target_freebsd_fsid_t   fh_fsid;    /* Filesystem id of mount point */
+    struct target_freebsd_fid fh_fid;   /* Filesys specific id */
+};
+typedef struct target_freebsd_fhandle target_freebsd_fhandle_t;
+
+/*
+ * sys/fcntl.h
+ */
+#define TARGET_F_DUPFD              0
+#define TARGET_F_GETFD              1
+#define TARGET_F_SETFD              2
+#define TARGET_F_GETFL              3
+#define TARGET_F_SETFL              4
+#define TARGET_F_GETOWN             5
+#define TARGET_F_SETOWN             6
+#define TARGET_F_OGETLK             7
+#define TARGET_F_OSETLK             8
+#define TARGET_F_OSETLKW            9
+#define TARGET_F_DUP2FD             10
+#define TARGET_F_GETLK              11
+#define TARGET_F_SETLK              12
+#define TARGET_F_SETLKW             13
+#define TARGET_F_SETLK_REMOTE       14
+#define TARGET_F_READAHEAD          15
+#define TARGET_F_RDAHEAD            16
+#define TARGET_F_DUPFD_CLOEXEC     17
+#define TARGET_F_DUP2FD_CLOEXEC    18
+/* FreeBSD-specific */
+#define TARGET_F_ADD_SEALS          19
+#define TARGET_F_GET_SEALS          20
+
+struct target_freebsd_flock {
+    int64_t l_start;
+    int64_t l_len;
+    int32_t l_pid;
+    int16_t l_type;
+    int16_t l_whence;
+    int32_t l_sysid;
+} QEMU_PACKED;
+
 #define safe_syscall0(type, name) \
 type safe_##name(void) \
 { \