+++ /dev/null
-/*
- * buffer_io.h
- *
- * A few endianness-aware macros for reading and writing data from in-memory
- * buffers.
- */
-
-#ifndef _WIMLIB_BUFFER_IO_H
-#define _WIMLIB_BUFFER_IO_H
-
-#include "wimlib/types.h"
-#include "endianness.h"
-#include <string.h>
-
-/* Note that in the WIM format, integers are always in little-endian format. */
-
-/* The get_u8, get_u16, get_u32, get_u56, and get_u64 functions take in a
- * pointer to an input location as the first argument and a pointer to an output
- * location as the second argument. The data in the input location is copied to
- * the output location, with the size indicated in the function name, in little
- * endian format. A pointer to the input location directly following the bytes
- * read is returned. */
-static inline const void *
-get_u8(const void *p, u8 *res)
-{
- *res = *(const u8*)p;
- return p + 1;
-}
-
-static inline const void *
-get_u16(const void *p, u16 *res)
-{
- *res = le16_to_cpu(*(const u16*)p);
- return p + 2;
-}
-
-
-
-static inline const void *
-get_u32(const void *p, u32 *res)
-{
- *res = le32_to_cpu(*(const u32*)p);
- return p + 4;
-}
-
-
-static inline const void *
-get_u56(const void *p, u64 *res)
-{
- *res = le64_to_cpu(*(const u64*)p) & 0x00ffffffffffffff;
- return p + 7;
-}
-
-
-static inline const void *
-get_u64(const void *p, u64 *res)
-{
- *res = le64_to_cpu(*(const u64*)p);
- return p + 8;
-}
-
-/* The put_u8, put_u16, put_u32, put_u56, and put_u64 functions take in a
- * pointer to an output location as the first argument and a value for the
- * second argument. The value of the second argument is written to the output
- * location in little-endian format as the data type indicated in the function
- * name, and a pointer to the output location directory following the bytes
- * written is returned. */
-static inline void *
-put_u8(void *res, u8 val)
-{
- *(u8*)res = val;
- return res + 1;
-}
-
-static inline void *
-put_u16(void *res, u16 val)
-{
- *(uint16_t*)res = cpu_to_le16(val);
- return res + 2;
-}
-
-static inline void *
-put_u32(void *res, u32 val)
-{
- *(uint32_t*)res = cpu_to_le32(val);
- return res + 4;
-}
-
-static inline void *
-put_u56(void *res, u64 val)
-{
- const u8 *__p = (const u8*)&val;
-#ifdef WORDS_BIGENDIAN
- res[0] = __p[6];
- res[1] = __p[5];
- res[2] = __p[4];
- res[3] = __p[3];
- res[4] = __p[2];
- res[5] = __p[1];
- res[6] = __p[0];
-#else
- memcpy(res, __p, 7);
-#endif
- return res + 7;
-}
-
-static inline void *
-put_u64(void *res, u64 val)
-{
- *(u64*)res = cpu_to_le64(val);
- return res + 8;
-}
-
-static inline const void *
-get_bytes(const void *p, size_t num_bytes, void *res)
-{
- memcpy(res, p, num_bytes);
- return p + num_bytes;
-}
-
-static inline void *
-put_zeroes(void *p, size_t num_bytes)
-{
- return memset(p, 0, num_bytes) + num_bytes;
-}
-
-static inline void *
-put_bytes(void *p, size_t num_bytes, const void *input)
-{
- return memcpy(p, input, num_bytes) + num_bytes;
-}
-
-#endif /* _WIMLIB_BUFFER_IO_H */
#endif
#include "wimlib/assert.h"
-#include "wimlib/buffer_io.h"
+#include "wimlib/endianness.h"
#include "wimlib/error.h"
#include "wimlib/file_io.h"
#include "wimlib/integrity.h"
u32 size;
u32 num_entries;
u32 chunk_size;
- u8 sha1sums[0][20];
-};
+ u8 sha1sums[][20];
+} _packed_attribute;
static int
calculate_chunk_sha1(int in_fd, size_t this_chunk_size,
{
int ret;
struct SECURITY_CONTEXT ctx;
- u32 attributes_le32;
+ le32 attributes;
const struct wim_inode *inode;
inode = dentry->d_inode;
DEBUG("Setting NTFS file attributes on `%s' to %#"PRIx32,
dentry->_full_path, inode->i_attributes);
- attributes_le32 = cpu_to_le32(inode->i_attributes);
+ attributes = cpu_to_le32(inode->i_attributes);
memset(&ctx, 0, sizeof(ctx));
ctx.vol = ni->vol;
ret = ntfs_xattr_system_setxattr(&ctx, XATTR_NTFS_ATTRIB,
ni, dir_ni,
- (const char*)&attributes_le32,
- sizeof(u32), 0);
+ (char*)&attributes,
+ sizeof(attributes), 0);
if (ret) {
ERROR("Failed to set NTFS file attributes on `%s'",
dentry->_full_path);
#include <ntfs-3g/acls.h> /* This should be included last as it requires
definitions from above not included by itself */
-#include "wimlib/buffer_io.h"
#include "wimlib/capture.h"
#include "wimlib/dentry.h"
#include "wimlib/encoding.h"
+#include "wimlib/endianness.h"
#include "wimlib/error.h"
#include "wimlib/lookup_table.h"
#include "wimlib/ntfs_3g.h"
u32 *reparse_tag_ret)
{
int ret;
- u8 buf[8];
+ le32 reparse_tag;
ntfs_attr *na;
na = open_ntfs_attr(ni, loc);
goto out;
}
- if (ntfs_attr_pread(na, 0, 8, buf) != 8) {
+ if (ntfs_attr_pread(na, 0, sizeof(reparse_tag),
+ &reparse_tag) != sizeof(reparse_tag))
+ {
ERROR_WITH_ERRNO("Error reading reparse data");
ret = WIMLIB_ERR_NTFS_3G;
goto out_close_ntfs_attr;
}
- *reparse_tag_ret = le32_to_cpu(*(u32*)buf);
+ *reparse_tag_ret = le32_to_cpu(reparse_tag);
DEBUG("ReparseTag = %#x", *reparse_tag_ret);
ret = 0;
out_close_ntfs_attr:
ntfs_volume *vol,
struct add_image_params *params)
{
- u32 attributes;
+ le32 attributes;
int ret;
struct wim_dentry *root;
struct wim_inode *inode;
ctx.vol = vol;
ret = ntfs_xattr_system_getxattr(&ctx, XATTR_NTFS_ATTRIB,
ni, dir_ni, (char *)&attributes,
- sizeof(u32));
- if (ret != 4) {
+ sizeof(attributes));
+ if (ret != sizeof(attributes)) {
ERROR_WITH_ERRNO("Failed to get NTFS attributes from `%s'",
path);
return WIMLIB_ERR_NTFS_3G;
#include <errno.h>
#include <stdlib.h>
+/* On-disk format of a symbolic link (WIM_IO_REPARSE_TAG_SYMLINK) or junction
+ * point (WIM_IO_REPARSE_TAG_MOUNT_POINT) reparse data buffer. */
struct reparse_buffer_disk {
le32 rptag;
le16 rpdatalen;
#endif
#include "wimlib/assert.h"
-#include "wimlib/buffer_io.h"
+#include "wimlib/endianness.h"
#include "wimlib/error.h"
#include "wimlib/security.h"
#include "wimlib/sha1.h"
&rpdata.substitute_name_nbytes,
capture_root_ino,
capture_root_dev,
- le32_to_cpu(*(u32*)rpbuf));
+ le32_to_cpu(*(le32*)rpbuf));
if (rp_status & RP_FIXED) {
wimlib_assert(rpdata.substitute_name_nbytes % 2 == 0);
utf16lechar substitute_name_copy[rpdata.substitute_name_nbytes / 2];
}
rpbuflen = bytesReturned;
- reparse_tag = le32_to_cpu(*(u32*)rpbuf);
+ reparse_tag = le32_to_cpu(*(le32*)rpbuf);
if (params->add_flags & WIMLIB_ADD_FLAG_RPFIX &&
(reparse_tag == WIM_IO_REPARSE_TAG_SYMLINK ||
reparse_tag == WIM_IO_REPARSE_TAG_MOUNT_POINT))
/* Reparse point: set the reparse data (which we read already)
* */
inode->i_not_rpfixed = not_rpfixed;
- inode->i_reparse_tag = le32_to_cpu(*(u32*)rpbuf);
+ inode->i_reparse_tag = le32_to_cpu(*(le32*)rpbuf);
ret = inode_set_unnamed_stream(inode, rpbuf + 8, rpbuflen - 8,
params->lookup_table);
} else if (inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY) {