1 /* SPDX-License-Identifier: MIT */
2 /******************************************************************************
3  * Xen Hypervisor Filesystem
4  *
5  * Copyright (c) 2019, SUSE Software Solutions Germany GmbH
6  *
7  */
8 
9 #ifndef __XEN_PUBLIC_HYPFS_H__
10 #define __XEN_PUBLIC_HYPFS_H__
11 
12 #include "xen.h"
13 
14 /*
15  * Definitions for the __HYPERVISOR_hypfs_op hypercall.
16  */
17 
18 /* Highest version number of the hypfs interface currently defined. */
19 #define XEN_HYPFS_VERSION      1
20 
21 /* Maximum length of a path in the filesystem. */
22 #define XEN_HYPFS_MAX_PATHLEN  1024
23 
24 struct xen_hypfs_direntry {
25     uint8_t type;
26 #define XEN_HYPFS_TYPE_DIR     0
27 #define XEN_HYPFS_TYPE_BLOB    1
28 #define XEN_HYPFS_TYPE_STRING  2
29 #define XEN_HYPFS_TYPE_UINT    3
30 #define XEN_HYPFS_TYPE_INT     4
31 #define XEN_HYPFS_TYPE_BOOL    5
32     uint8_t encoding;
33 #define XEN_HYPFS_ENC_PLAIN    0
34 #define XEN_HYPFS_ENC_GZIP     1
35     uint16_t pad;              /* Returned as 0. */
36     uint32_t content_len;      /* Current length of data. */
37     uint32_t max_write_len;    /* Max. length for writes (0 if read-only). */
38 };
39 typedef struct xen_hypfs_direntry xen_hypfs_direntry_t;
40 
41 struct xen_hypfs_dirlistentry {
42     xen_hypfs_direntry_t e;
43     /* Offset in bytes to next entry (0 == this is the last entry). */
44     uint16_t off_next;
45     /* Zero terminated entry name, possibly with some padding for alignment. */
46     char name[XEN_FLEX_ARRAY_DIM];
47 };
48 
49 /*
50  * Hypercall operations.
51  */
52 
53 /*
54  * XEN_HYPFS_OP_get_version
55  *
56  * Read highest interface version supported by the hypervisor.
57  *
58  * arg1 - arg4: all 0/NULL
59  *
60  * Possible return values:
61  * >0: highest supported interface version
62  * <0: negative Xen errno value
63  */
64 #define XEN_HYPFS_OP_get_version     0
65 
66 /*
67  * XEN_HYPFS_OP_read
68  *
69  * Read a filesystem entry.
70  *
71  * Returns the direntry and contents of an entry in the buffer supplied by the
72  * caller (struct xen_hypfs_direntry with the contents following directly
73  * after it).
74  * The data buffer must be at least the size of the direntry returned. If the
75  * data buffer was not large enough for all the data -ENOBUFS and no entry
76  * data is returned, but the direntry will contain the needed size for the
77  * returned data.
78  * The format of the contents is according to its entry type and encoding.
79  * The contents of a directory are multiple struct xen_hypfs_dirlistentry
80  * items.
81  *
82  * arg1: XEN_GUEST_HANDLE(path name)
83  * arg2: length of path name (including trailing zero byte)
84  * arg3: XEN_GUEST_HANDLE(data buffer written by hypervisor)
85  * arg4: data buffer size
86  *
87  * Possible return values:
88  * 0: success
89  * <0 : negative Xen errno value
90  */
91 #define XEN_HYPFS_OP_read              1
92 
93 /*
94  * XEN_HYPFS_OP_write_contents
95  *
96  * Write contents of a filesystem entry.
97  *
98  * Writes an entry with the contents of a buffer supplied by the caller.
99  * The data type and encoding can't be changed. The size can be changed only
100  * for blobs and strings.
101  *
102  * arg1: XEN_GUEST_HANDLE(path name)
103  * arg2: length of path name (including trailing zero byte)
104  * arg3: XEN_GUEST_HANDLE(content buffer read by hypervisor)
105  * arg4: content buffer size
106  *
107  * Possible return values:
108  * 0: success
109  * <0 : negative Xen errno value
110  */
111 #define XEN_HYPFS_OP_write_contents    2
112 
113 #endif /* __XEN_PUBLIC_HYPFS_H__ */
114