]> wimlib.net Git - wimlib/blob - include/wimlib/reparse.h
Use little endian types for 'struct wim_header_disk'
[wimlib] / include / wimlib / reparse.h
1 #ifndef _WIMLIB_REPARSE_H
2 #define _WIMLIB_REPARSE_H
3
4 #include <sys/types.h>
5
6 #include "wimlib/types.h"
7
8 struct wim_inode;
9 struct blob_table;
10 struct blob_descriptor;
11
12 #define REPARSE_POINT_MAX_SIZE (16 * 1024)
13
14 /* On-disk format of reparse point buffer  */
15 struct reparse_buffer_disk {
16         le32 rptag;
17         le16 rpdatalen;
18         le16 rpreserved;
19         union {
20                 u8 rpdata[REPARSE_POINT_MAX_SIZE - 8];
21
22                 struct {
23                         le16 substitute_name_offset;
24                         le16 substitute_name_nbytes;
25                         le16 print_name_offset;
26                         le16 print_name_nbytes;
27                         le32 rpflags;
28                         u8 data[REPARSE_POINT_MAX_SIZE - 20];
29                 } _packed_attribute symlink;
30
31                 struct {
32                         le16 substitute_name_offset;
33                         le16 substitute_name_nbytes;
34                         le16 print_name_offset;
35                         le16 print_name_nbytes;
36                         u8 data[REPARSE_POINT_MAX_SIZE - 16];
37                 } _packed_attribute junction;
38         };
39 } _packed_attribute;
40
41 #define REPARSE_DATA_OFFSET (offsetof(struct reparse_buffer_disk, rpdata))
42
43 #define REPARSE_DATA_MAX_SIZE (REPARSE_POINT_MAX_SIZE - REPARSE_DATA_OFFSET)
44
45
46 /* Structured format for symbolic link, junction point, or mount point reparse
47  * data. */
48 struct reparse_data {
49         /* Reparse point tag (see WIM_IO_REPARSE_TAG_* values) */
50         u32 rptag;
51
52         /* Length of reparse data, not including the 8-byte header (ReparseTag,
53          * ReparseDataLength, ReparseReserved) */
54         u16 rpdatalen;
55
56         /* ReparseReserved */
57         u16 rpreserved;
58
59         /* Flags (only for WIM_IO_REPARSE_TAG_SYMLINK reparse points).
60          * SYMBOLIC_LINK_RELATIVE means this is a relative symbolic link;
61          * otherwise should be set to 0. */
62 #define SYMBOLIC_LINK_RELATIVE 0x00000001
63         u32 rpflags;
64
65         /* Pointer to the substitute name of the link (UTF-16LE). */
66         utf16lechar *substitute_name;
67
68         /* Pointer to the print name of the link (UTF-16LE). */
69         utf16lechar *print_name;
70
71         /* Number of bytes of the substitute name, not including null terminator
72          * if present */
73         u16 substitute_name_nbytes;
74
75         /* Number of bytes of the print name, not including null terminator if
76          * present */
77         u16 print_name_nbytes;
78 };
79
80 extern int
81 parse_reparse_data(const u8 * restrict rpbuf, u16 rpbuflen,
82                    struct reparse_data * restrict rpdata);
83
84 extern int
85 make_reparse_buffer(const struct reparse_data * restrict rpdata,
86                     u8 * restrict rpbuf,
87                     u16 * restrict rpbuflen_ret);
88
89 #ifndef __WIN32__
90 ssize_t
91 wim_inode_readlink(const struct wim_inode * restrict inode, char * restrict buf,
92                    size_t buf_len, struct blob_descriptor *blob);
93
94 extern int
95 wim_inode_set_symlink(struct wim_inode *inode, const char *target,
96                       struct blob_table *blob_table);
97 #endif
98
99 #endif /* _WIMLIB_REPARSE_H */