NTFS apply fixes
authorEric Biggers <ebiggers3@gmail.com>
Fri, 24 Aug 2012 22:17:45 +0000 (17:17 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Fri, 24 Aug 2012 22:17:45 +0000 (17:17 -0500)
Minor fixes

Also, comment out hard link creation code until a problem is fixed

src/ntfs-3g_security.c
src/ntfs-apply.c

index 83b92ed99a247ca762d4804e90adc56e972389c9..22faa9ec72c42cff1892e0fd0d2e92bbda1551a0 100644 (file)
@@ -4806,8 +4806,8 @@ static BOOL _ntfs_valid_descr(const char *securattr, unsigned int attrsz)
  *
  * Returns nonzero on success
  */
  *
  * Returns nonzero on success
  */
-int _ntfs_set_file_security(ntfs_volume *vol, ntfs_inode *ni,
-                           u32 selection, const char *attr)
+int _ntfs_set_file_security(ntfs_inode *ni, u32 selection,
+                           const char *attr)
 {
        const SECURITY_DESCRIPTOR_RELATIVE *phead;
        int attrsz;
 {
        const SECURITY_DESCRIPTOR_RELATIVE *phead;
        int attrsz;
@@ -4828,10 +4828,10 @@ int _ntfs_set_file_security(ntfs_volume *vol, ntfs_inode *ni,
        if (!missing
            && (phead->control & SE_SELF_RELATIVE)
            && _ntfs_valid_descr(attr, attrsz)) {
        if (!missing
            && (phead->control & SE_SELF_RELATIVE)
            && _ntfs_valid_descr(attr, attrsz)) {
-               oldattr = getsecurityattr(vol, ni);
+               oldattr = getsecurityattr(ni->vol, ni);
                if (oldattr) {
                        if (mergesecurityattr(
                if (oldattr) {
                        if (mergesecurityattr(
-                               vol,
+                               ni->vol,
                                oldattr, attr,
                                selection, ni)) {
                                if (test_nino_flag(ni,
                                oldattr, attr,
                                selection, ni)) {
                                if (test_nino_flag(ni,
index f2a79fd0f79cec0d97931fcfc65890df7d801821..bf29014393dbaeec89d74621c4271f3e57ca8a8b 100644 (file)
@@ -49,8 +49,8 @@ struct ntfs_apply_args {
        WIMStruct *w;
 };
 
        WIMStruct *w;
 };
 
-extern int _ntfs_set_file_security(ntfs_volume *vol, ntfs_inode *ni,
-                                  u32 selection, const char *attr);
+extern int _ntfs_set_file_security(ntfs_inode *ni, u32 selection,
+                                  const char *attr);
 extern int _ntfs_set_file_attributes(ntfs_inode *ni, s32 attrib);
 
 /* 
 extern int _ntfs_set_file_attributes(ntfs_inode *ni, s32 attrib);
 
 /* 
@@ -109,13 +109,16 @@ static int write_ntfs_data_streams(ntfs_inode *ni, const struct dentry *dentry,
        ntfschar *stream_name = AT_UNNAMED;
        u32 stream_name_len = 0;
 
        ntfschar *stream_name = AT_UNNAMED;
        u32 stream_name_len = 0;
 
-       DEBUG("Writing NTFS data streams for `%s'", dentry->full_path_utf8);
+       DEBUG("Writing %u NTFS data stream%s for `%s'",
+             dentry->num_ads + 1,
+             (dentry->num_ads == 0 ? "" : "s"),
+             dentry->full_path_utf8);
 
        while (1) {
                struct lookup_table_entry *lte;
                ntfs_attr *na;
 
 
        while (1) {
                struct lookup_table_entry *lte;
                ntfs_attr *na;
 
-               lte = dentry_stream_lte(dentry, 0, w->lookup_table);
+               lte = dentry_stream_lte(dentry, stream_idx, w->lookup_table);
                na = ntfs_attr_open(ni, AT_DATA, stream_name, stream_name_len);
                if (!na) {
                        ERROR_WITH_ERRNO("Failed to open a data stream of "
                na = ntfs_attr_open(ni, AT_DATA, stream_name, stream_name_len);
                if (!na) {
                        ERROR_WITH_ERRNO("Failed to open a data stream of "
@@ -124,7 +127,7 @@ static int write_ntfs_data_streams(ntfs_inode *ni, const struct dentry *dentry,
                        ret = WIMLIB_ERR_NTFS_3G;
                        break;
                }
                        ret = WIMLIB_ERR_NTFS_3G;
                        break;
                }
-               if (lte && wim_resource_size(lte) != 0)
+               if (lte)
                        ret = extract_wim_resource_to_ntfs_attr(lte, na);
                ntfs_attr_close(na);
                if (ret != 0)
                        ret = extract_wim_resource_to_ntfs_attr(lte, na);
                ntfs_attr_close(na);
                if (ret != 0)
@@ -206,7 +209,7 @@ apply_file_attributes_and_security_data(ntfs_inode *ni,
                                DACL_SECURITY_INFORMATION  |
                                SACL_SECURITY_INFORMATION;
                                
                                DACL_SECURITY_INFORMATION  |
                                SACL_SECURITY_INFORMATION;
                                
-               if (!_ntfs_set_file_security(ni->vol, ni, selection,
+               if (!_ntfs_set_file_security(ni, selection,
                                             sd->descriptors[dentry->security_id]))
                {
                        ERROR_WITH_ERRNO("Failed to set security data on `%s'",
                                             sd->descriptors[dentry->security_id]))
                {
                        ERROR_WITH_ERRNO("Failed to set security data on `%s'",
@@ -279,6 +282,7 @@ static int do_wim_apply_dentry_ntfs(struct dentry *dentry, ntfs_inode *dir_ni,
                type = S_IFDIR;
        } else {
                type = S_IFREG;
                type = S_IFDIR;
        } else {
                type = S_IFREG;
+#if 0
                const struct list_head *head = &dentry->link_group_list;
                if (head->next != head) {
                        /* This dentry is one of a hard link set of at least 2
                const struct list_head *head = &dentry->link_group_list;
                if (head->next != head) {
                        /* This dentry is one of a hard link set of at least 2
@@ -302,13 +306,14 @@ static int do_wim_apply_dentry_ntfs(struct dentry *dentry, ntfs_inode *dir_ni,
                        ERROR("Failed to allocate memory for filename");
                        return WIMLIB_ERR_NOMEM;
                }
                        ERROR("Failed to allocate memory for filename");
                        return WIMLIB_ERR_NOMEM;
                }
+#endif
        }
 
        /* 
         * Create a directory or file.
         *
        }
 
        /* 
         * Create a directory or file.
         *
-        * Note: if it's a reparse point (such as a symbolic link), we still
-        * pass S_IFREG here, since we manually set the reparse data later.
+        * Note: For symbolic links that are not directory junctions, pass
+        * S_IFREG here, since we manually set the reparse data later.
         */
        ni = ntfs_create(dir_ni, 0, (ntfschar*)dentry->file_name,
                         dentry->file_name_len / 2, type);
         */
        ni = ntfs_create(dir_ni, 0, (ntfschar*)dentry->file_name,
                         dentry->file_name_len / 2, type);