1 /******************************************************************************
2 * Xen Hypervisor Filesystem
4 * Copyright (c) 2019, SUSE Software Solutions Germany GmbH
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
26 #ifndef __XEN_PUBLIC_HYPFS_H__
27 #define __XEN_PUBLIC_HYPFS_H__
32 * Definitions for the __HYPERVISOR_hypfs_op hypercall.
35 /* Highest version number of the hypfs interface currently defined. */
36 #define XEN_HYPFS_VERSION 1
38 /* Maximum length of a path in the filesystem. */
39 #define XEN_HYPFS_MAX_PATHLEN 1024
41 struct xen_hypfs_direntry {
43 #define XEN_HYPFS_TYPE_DIR 0
44 #define XEN_HYPFS_TYPE_BLOB 1
45 #define XEN_HYPFS_TYPE_STRING 2
46 #define XEN_HYPFS_TYPE_UINT 3
47 #define XEN_HYPFS_TYPE_INT 4
48 #define XEN_HYPFS_TYPE_BOOL 5
50 #define XEN_HYPFS_ENC_PLAIN 0
51 #define XEN_HYPFS_ENC_GZIP 1
52 uint16_t pad; /* Returned as 0. */
53 uint32_t content_len; /* Current length of data. */
54 uint32_t max_write_len; /* Max. length for writes (0 if read-only). */
57 struct xen_hypfs_dirlistentry {
58 struct xen_hypfs_direntry e;
59 /* Offset in bytes to next entry (0 == this is the last entry). */
61 /* Zero terminated entry name, possibly with some padding for alignment. */
62 char name[XEN_FLEX_ARRAY_DIM];
66 * Hypercall operations.
70 * XEN_HYPFS_OP_get_version
72 * Read highest interface version supported by the hypervisor.
74 * arg1 - arg4: all 0/NULL
76 * Possible return values:
77 * >0: highest supported interface version
78 * <0: negative Xen errno value
80 #define XEN_HYPFS_OP_get_version 0
85 * Read a filesystem entry.
87 * Returns the direntry and contents of an entry in the buffer supplied by the
88 * caller (struct xen_hypfs_direntry with the contents following directly
90 * The data buffer must be at least the size of the direntry returned. If the
91 * data buffer was not large enough for all the data -ENOBUFS and no entry
92 * data is returned, but the direntry will contain the needed size for the
94 * The format of the contents is according to its entry type and encoding.
95 * The contents of a directory are multiple struct xen_hypfs_dirlistentry
98 * arg1: XEN_GUEST_HANDLE(path name)
99 * arg2: length of path name (including trailing zero byte)
100 * arg3: XEN_GUEST_HANDLE(data buffer written by hypervisor)
101 * arg4: data buffer size
103 * Possible return values:
105 * <0 : negative Xen errno value
107 #define XEN_HYPFS_OP_read 1
110 * XEN_HYPFS_OP_write_contents
112 * Write contents of a filesystem entry.
114 * Writes an entry with the contents of a buffer supplied by the caller.
115 * The data type and encoding can't be changed. The size can be changed only
116 * for blobs and strings.
118 * arg1: XEN_GUEST_HANDLE(path name)
119 * arg2: length of path name (including trailing zero byte)
120 * arg3: XEN_GUEST_HANDLE(content buffer read by hypervisor)
121 * arg4: content buffer size
123 * Possible return values:
125 * <0 : negative Xen errno value
127 #define XEN_HYPFS_OP_write_contents 2
129 #endif /* __XEN_PUBLIC_HYPFS_H__ */