1 #ifndef _WIMLIB_REPARSE_H
2 #define _WIMLIB_REPARSE_H
4 #include "wimlib/inode.h" /* for reparse tag definitions */
5 #include "wimlib/types.h"
7 struct blob_descriptor;
10 /* Windows enforces this limit on the size of a reparse point buffer. */
11 #define REPARSE_POINT_MAX_SIZE 16384
14 * On-disk format of a reparse point buffer. See:
15 * https://msdn.microsoft.com/en-us/library/dd541671.aspx
17 * Note: we are not using _packed_attribute for this structure, so only cast to
18 * this if properly aligned!
20 struct reparse_buffer_disk {
25 u8 rpdata[REPARSE_POINT_MAX_SIZE - 8];
28 le16 substitute_name_offset;
29 le16 substitute_name_nbytes;
30 le16 print_name_offset;
31 le16 print_name_nbytes;
35 u8 data[REPARSE_POINT_MAX_SIZE - 16];
40 #define SYMBOLIC_LINK_RELATIVE 0x00000001
41 u8 data[REPARSE_POINT_MAX_SIZE - 20];
48 #define REPARSE_DATA_OFFSET ((unsigned)offsetof(struct reparse_buffer_disk, rpdata))
50 #define REPARSE_DATA_MAX_SIZE (REPARSE_POINT_MAX_SIZE - REPARSE_DATA_OFFSET)
52 static _unused_attribute void
53 check_reparse_buffer_disk(void)
55 STATIC_ASSERT(offsetof(struct reparse_buffer_disk, rpdata) == 8);
56 STATIC_ASSERT(offsetof(struct reparse_buffer_disk, link.junction.data) == 16);
57 STATIC_ASSERT(offsetof(struct reparse_buffer_disk, link.symlink.data) == 20);
58 STATIC_ASSERT(sizeof(struct reparse_buffer_disk) == REPARSE_POINT_MAX_SIZE);
61 /* Wrapper around a symbolic link or junction reparse point
62 * (WIM_IO_REPARSE_TAG_SYMLINK or WIM_IO_REPARSE_TAG_MOUNT_POINT) */
63 struct link_reparse_point {
68 /* Flags, valid for symbolic links only */
71 /* Pointers to the substitute name and print name of the link,
72 * potentially not null terminated */
73 utf16lechar *substitute_name;
74 utf16lechar *print_name;
76 /* Lengths of the substitute and print names in bytes, not including
77 * their null terminators if present */
78 size_t substitute_name_nbytes;
79 size_t print_name_nbytes;
83 link_is_relative_symlink(const struct link_reparse_point *link)
85 return link->rptag == WIM_IO_REPARSE_TAG_SYMLINK &&
86 (link->symlink_flags & SYMBOLIC_LINK_RELATIVE);
90 complete_reparse_point(struct reparse_buffer_disk *rpbuf,
91 const struct wim_inode *inode, u16 blob_size);
94 parse_link_reparse_point(const struct reparse_buffer_disk *rpbuf, u16 rpbuflen,
95 struct link_reparse_point *link);
98 make_link_reparse_point(const struct link_reparse_point *link,
99 struct reparse_buffer_disk *rpbuf, u16 *rpbuflen_ret);
103 wim_inode_readlink(const struct wim_inode *inode, char *buf, size_t bufsize,
104 const struct blob_descriptor *blob,
105 const char *altroot, size_t altroot_len);
108 wim_inode_set_symlink(struct wim_inode *inode, const char *target,
109 struct blob_table *blob_table);
112 #endif /* _WIMLIB_REPARSE_H */