]> wimlib.net Git - wimlib/commitdiff
Remove buffer_io.h
authorEric Biggers <ebiggers3@gmail.com>
Fri, 17 May 2013 19:22:01 +0000 (14:22 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Fri, 17 May 2013 19:22:01 +0000 (14:22 -0500)
include/wimlib/buffer_io.h [deleted file]
src/integrity.c
src/ntfs-3g_apply.c
src/ntfs-3g_capture.c
src/reparse.c
src/security.c
src/win32_capture.c

diff --git a/include/wimlib/buffer_io.h b/include/wimlib/buffer_io.h
deleted file mode 100644 (file)
index 43e497b..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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 */
index 0af6fdddeb9687f4881e2f352538148cb91addd8..1998f6c5db41c778b47ccdc26e927205c0f44c18 100644 (file)
@@ -30,7 +30,7 @@
 #endif
 
 #include "wimlib/assert.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"
 #include "wimlib/error.h"
 #include "wimlib/file_io.h"
 #include "wimlib/integrity.h"
@@ -51,8 +51,8 @@ struct integrity_table {
        u32 size;
        u32 num_entries;
        u32 chunk_size;
        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,
 
 static int
 calculate_chunk_sha1(int in_fd, size_t this_chunk_size,
index dde9a1db3ecfde9fa1f48ee514fa8f31406d93de..0bf7989bd74231870d2c578ba2703eb300fc7d88 100644 (file)
@@ -305,7 +305,7 @@ apply_file_attributes_and_security_data(ntfs_inode *ni,
 {
        int ret;
        struct SECURITY_CONTEXT ctx;
 {
        int ret;
        struct SECURITY_CONTEXT ctx;
-       u32 attributes_le32;
+       le32 attributes;
        const struct wim_inode *inode;
 
        inode = dentry->d_inode;
        const struct wim_inode *inode;
 
        inode = dentry->d_inode;
@@ -313,13 +313,13 @@ apply_file_attributes_and_security_data(ntfs_inode *ni,
        DEBUG("Setting NTFS file attributes on `%s' to %#"PRIx32,
              dentry->_full_path, inode->i_attributes);
 
        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,
        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);
        if (ret) {
                ERROR("Failed to set NTFS file attributes on `%s'",
                      dentry->_full_path);
index 034bd1b0e3d897bbfc887dfb79fdff1a3a97900b..d81248ebf8354ba6f6fa268f844386630c063b60 100644 (file)
 #include <ntfs-3g/acls.h> /* This should be included last as it requires
                             definitions from above not included by itself */
 
 #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/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"
 #include "wimlib/error.h"
 #include "wimlib/lookup_table.h"
 #include "wimlib/ntfs_3g.h"
@@ -151,7 +151,7 @@ read_reparse_tag(ntfs_inode *ni, struct ntfs_location *loc,
                 u32 *reparse_tag_ret)
 {
        int ret;
                 u32 *reparse_tag_ret)
 {
        int ret;
-       u8 buf[8];
+       le32 reparse_tag;
        ntfs_attr *na;
 
        na = open_ntfs_attr(ni, loc);
        ntfs_attr *na;
 
        na = open_ntfs_attr(ni, loc);
@@ -160,12 +160,14 @@ read_reparse_tag(ntfs_inode *ni, struct ntfs_location *loc,
                goto out;
        }
 
                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;
        }
                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:
        DEBUG("ReparseTag = %#x", *reparse_tag_ret);
        ret = 0;
 out_close_ntfs_attr:
@@ -545,7 +547,7 @@ build_dentry_tree_ntfs_recursive(struct wim_dentry **root_ret,
                                 ntfs_volume *vol,
                                 struct add_image_params *params)
 {
                                 ntfs_volume *vol,
                                 struct add_image_params *params)
 {
-       u32 attributes;
+       le32 attributes;
        int ret;
        struct wim_dentry *root;
        struct wim_inode *inode;
        int ret;
        struct wim_dentry *root;
        struct wim_inode *inode;
@@ -573,8 +575,8 @@ build_dentry_tree_ntfs_recursive(struct wim_dentry **root_ret,
        ctx.vol = vol;
        ret = ntfs_xattr_system_getxattr(&ctx, XATTR_NTFS_ATTRIB,
                                         ni, dir_ni, (char *)&attributes,
        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;
                ERROR_WITH_ERRNO("Failed to get NTFS attributes from `%s'",
                                 path);
                return WIMLIB_ERR_NTFS_3G;
index 446b6f9f3765fc74f1c89c5eca495338be9cc53f..505910979d06cf24049d741f3052608d2a5429d5 100644 (file)
@@ -45,6 +45,8 @@
 #include <errno.h>
 #include <stdlib.h>
 
 #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;
 struct reparse_buffer_disk {
        le32 rptag;
        le16 rpdatalen;
index 192786dfd17f583ed4eb2f0c1ebd38a307428b64..628b93584d1dfff77727ecc9f845c85c2b6a6152 100644 (file)
@@ -28,7 +28,7 @@
 #endif
 
 #include "wimlib/assert.h"
 #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"
 #include "wimlib/error.h"
 #include "wimlib/security.h"
 #include "wimlib/sha1.h"
index 7f6df42e49393e65614ab512cfecdb1af17d0b25..c05eb192b4105a86c2c90f7652320fe232f056a4 100644 (file)
@@ -519,7 +519,7 @@ win32_capture_try_rpfix(u8 *rpbuf, u16 *rpbuflen_p,
                                                     &rpdata.substitute_name_nbytes,
                                                     capture_root_ino,
                                                     capture_root_dev,
                                                     &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];
        if (rp_status & RP_FIXED) {
                wimlib_assert(rpdata.substitute_name_nbytes % 2 == 0);
                utf16lechar substitute_name_copy[rpdata.substitute_name_nbytes / 2];
@@ -612,7 +612,7 @@ win32_get_reparse_data(HANDLE hFile, const wchar_t *path,
        }
 
        rpbuflen = bytesReturned;
        }
 
        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))
        if (params->add_flags & WIMLIB_ADD_FLAG_RPFIX &&
            (reparse_tag == WIM_IO_REPARSE_TAG_SYMLINK ||
             reparse_tag == WIM_IO_REPARSE_TAG_MOUNT_POINT))
@@ -1061,7 +1061,7 @@ win32_build_dentry_tree_recursive(struct wim_dentry **root_ret,
                /* Reparse point: set the reparse data (which we read already)
                 * */
                inode->i_not_rpfixed = not_rpfixed;
                /* 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) {
                ret = inode_set_unnamed_stream(inode, rpbuf + 8, rpbuflen - 8,
                                               params->lookup_table);
        } else if (inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY) {