Changes by: cha0smaster
Update of /cvsroot/linux-ntfs/ntfsprogs/libntfs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31630/libntfs
Modified Files:
attrib.c dir.c inode.c mft.c
Log Message:
see changelog
Index: attrib.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/attrib.c,v
retrieving revision 1.193
retrieving revision 1.194
diff -u -p -r1.193 -r1.194
--- attrib.c 2 Nov 2005 18:06:48 -0000 1.193
+++ attrib.c 7 Nov 2005 20:37:08 -0000 1.194
@@ -409,9 +409,8 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni
s64 l = le32_to_cpu(a->value_length);
ntfs_attr_init(na, FALSE, a->flags & ATTR_IS_COMPRESSED,
a->flags & ATTR_IS_ENCRYPTED,
- a->flags & ATTR_IS_SPARSE, l, l, l,
- cs ? sle64_to_cpu(a->compressed_size) : 0,
- cs ? a->compression_unit : 0);
+ a->flags & ATTR_IS_SPARSE, (l + 7) & ~7, l, l,
+ cs ? (l + 7) & ~7 : 0, 0);
}
ntfs_attr_put_search_ctx(ctx);
return na;
@@ -3702,10 +3701,10 @@ static int ntfs_resident_attr_resize(ntf
if (!ntfs_resident_attr_value_resize(ctx->mrec, ctx->attr,
newsize)) {
/* Update the ntfs attribute structure, too. */
- na->allocated_size = na->data_size =
- na->initialized_size = newsize;
+ na->data_size = na->initialized_size = newsize;
+ na->allocated_size = (newsize + 7) & ~7;
if (NAttrCompressed(na) || NAttrSparse(na))
- na->compressed_size = newsize;
+ na->compressed_size = na->allocated_size;
goto resize_done;
}
/* Error! If not enough space, just continue. */
@@ -4027,8 +4026,8 @@ static int ntfs_attr_make_resident(ntfs_
NAttrClearCompressed(na);
NAttrClearSparse(na);
NAttrClearEncrypted(na);
- na->allocated_size = na->initialized_size = na->compressed_size =
- na->data_size;
+ na->initialized_size = na->data_size;
+ na->allocated_size = na->compressed_size = (na->data_size + 7) & ~7;
na->compression_block_size = 0;
na->compression_block_size_bits = na->compression_block_clusters = 0;
return 0;
Index: dir.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/dir.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -p -r1.40 -r1.41
--- dir.c 4 Nov 2005 22:43:10 -0000 1.40
+++ dir.c 7 Nov 2005 20:37:08 -0000 1.41
@@ -1465,8 +1465,11 @@ int ntfs_link(ntfs_inode *ni, ntfs_inode
le16_to_cpu(dir_ni->mrec->sequence_number));
fn->file_name_length = name_len;
fn->file_name_type = FILE_NAME_POSIX;
+ fn->file_attributes = ni->flags;
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
- fn->file_attributes = FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT;
+ fn->file_attributes |= FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT;
+ fn->allocated_size = cpu_to_sle64(ni->allocated_size);
+ fn->data_size = cpu_to_sle64(ni->data_size);
fn->creation_time = utc2ntfs(ni->creation_time);
fn->last_data_change_time = utc2ntfs(ni->last_data_change_time);
fn->last_mft_change_time = utc2ntfs(ni->last_mft_change_time);
@@ -1502,15 +1505,6 @@ int ntfs_link(ntfs_inode *ni, ntfs_inode
/* Increment hard links count. */
ni->mrec->link_count = cpu_to_le16(le16_to_cpu(
ni->mrec->link_count) + 1);
- /*
- * Do not set attributes and file size, instead of this mark filenames
- * dirty to force attribute and size update during sync.
- * NOTE: File size may will be not updated and not all attributes will
- * be set, but it is acceptable since windows driver does not update
- * all file names when one of the hard links changed.
- * FIXME: It will be nice to update them all.
- */
- NInoFileNameSetDirty(ni);
/* Done! */
ntfs_inode_mark_dirty(ni);
free(fn);
Index: inode.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/inode.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -p -r1.76 -r1.77
--- inode.c 5 Nov 2005 22:54:43 -0000 1.76
+++ inode.c 7 Nov 2005 20:37:08 -0000 1.77
@@ -145,8 +145,6 @@ ntfs_inode *ntfs_inode_open(ntfs_volume
goto err_out;
}
ni->mft_no = MREF(mref);
- ni->data_size = -1;
- ni->allocated_size = -1;
ctx = ntfs_attr_get_search_ctx(ni, NULL);
if (!ctx)
goto err_out;
@@ -160,12 +158,6 @@ ntfs_inode *ntfs_inode_open(ntfs_volume
}
std_info = (STANDARD_INFORMATION *)((u8 *)ctx->attr +
le16_to_cpu(ctx->attr->value_offset));
- if (std_info->file_attributes & FILE_ATTR_COMPRESSED)
- NInoSetCompressed(ni);
- if (std_info->file_attributes & FILE_ATTR_ENCRYPTED)
- NInoSetEncrypted(ni);
- if (std_info->file_attributes & FILE_ATTR_SPARSE_FILE)
- NInoSetSparse(ni);
ni->flags = std_info->file_attributes;
ni->creation_time = ntfs2utc(std_info->creation_time);
ni->last_data_change_time = ntfs2utc(std_info->last_data_change_time);
@@ -176,9 +168,8 @@ ntfs_inode *ntfs_inode_open(ntfs_volume
ctx)) {
if (errno != ENOENT)
goto put_err_out;
- /* Attribute list attribute not present so we are done. */
- ntfs_attr_put_search_ctx(ctx);
- return ni;
+ /* Attribute list attribute does not present. */
+ goto get_size;
}
NInoSetAttrList(ni);
l = ntfs_get_attribute_value_length(ctx->attr);
@@ -199,6 +190,27 @@ ntfs_inode *ntfs_inode_open(ntfs_volume
err = EIO;
goto put_err_out;
}
+get_size:
+ if (ntfs_attr_lookup(AT_DATA, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
+ if (errno != ENOENT)
+ goto put_err_out;
+ /* Directory or special file. */
+ ni->data_size = ni->allocated_size = 0;
+ } else {
+ if (ctx->attr->non_resident) {
+ ni->data_size = sle64_to_cpu(ctx->attr->data_size);
+ if (ctx->attr->flags &
+ (ATTR_IS_COMPRESSED & ATTR_IS_SPARSE))
+ ni->allocated_size = sle64_to_cpu(
+ ctx->attr->compressed_size);
+ else
+ ni->allocated_size = sle64_to_cpu(
+ ctx->attr->allocated_size);
+ } else {
+ ni->data_size = le32_to_cpu(ctx->attr->value_length);
+ ni->allocated_size = (ni->data_size + 7) & ~7;
+ }
+ }
ntfs_attr_put_search_ctx(ctx);
return ni;
put_err_out:
@@ -475,18 +487,7 @@ static int ntfs_inode_sync_standard_info
}
std_info = (STANDARD_INFORMATION *)((u8 *)ctx->attr +
le16_to_cpu(ctx->attr->value_offset));
- if (NInoCompressed(ni))
- std_info->file_attributes |= FILE_ATTR_COMPRESSED;
- else
- std_info->file_attributes &= ~FILE_ATTR_COMPRESSED;
- if (NInoEncrypted(ni))
- std_info->file_attributes |= FILE_ATTR_ENCRYPTED;
- else
- std_info->file_attributes &= ~FILE_ATTR_ENCRYPTED;
- if (NInoSparse(ni))
- std_info->file_attributes |= FILE_ATTR_SPARSE_FILE;
- else
- std_info->file_attributes &= ~FILE_ATTR_SPARSE_FILE;
+ std_info->file_attributes = ni->flags;
std_info->creation_time = utc2ntfs(ni->creation_time);
std_info->last_data_change_time = utc2ntfs(ni->last_data_change_time);
std_info->last_mft_change_time = utc2ntfs(ni->last_mft_change_time);
@@ -562,22 +563,11 @@ static int ntfs_inode_sync_file_name(ntf
}
/* Update flags and file size. */
fn = (FILE_NAME_ATTR *)ictx->data;
- if (NInoCompressed(ni))
- fn->file_attributes |= FILE_ATTR_COMPRESSED;
- else
- fn->file_attributes &= ~FILE_ATTR_COMPRESSED;
- if (NInoEncrypted(ni))
- fn->file_attributes |= FILE_ATTR_ENCRYPTED;
- else
- fn->file_attributes &= ~FILE_ATTR_ENCRYPTED;
- if (NInoSparse(ni))
- fn->file_attributes |= FILE_ATTR_SPARSE_FILE;
- else
- fn->file_attributes &= ~FILE_ATTR_SPARSE_FILE;
- if (ni->allocated_size != -1)
- fn->allocated_size = cpu_to_sle64(ni->allocated_size);
- if (ni->data_size != -1)
- fn->data_size = cpu_to_sle64(ni->data_size);
+ fn->file_attributes =
+ (fn->file_attributes & ~FILE_ATTR_VALID_FLAGS) |
+ (ni->flags & FILE_ATTR_VALID_FLAGS);
+ fn->allocated_size = cpu_to_sle64(ni->allocated_size);
+ fn->data_size = cpu_to_sle64(ni->data_size);
fn->creation_time = utc2ntfs(ni->creation_time);
fn->last_data_change_time = utc2ntfs(ni->last_data_change_time);
fn->last_mft_change_time = utc2ntfs(ni->last_mft_change_time);
Index: mft.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/mft.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -p -r1.41 -r1.42
--- mft.c 2 Nov 2005 17:34:08 -0000 1.41
+++ mft.c 7 Nov 2005 20:37:08 -0000 1.42
@@ -1459,7 +1459,8 @@ mft_rec_already_initialized:
/* Make sure the allocated inode is written out to disk later. */
ntfs_inode_mark_dirty(ni);
/* Initialize time, allocated and data size in ntfs_inode struct. */
- ni->data_size = ni->allocated_size = -1;
+ ni->data_size = ni->allocated_size = 0;
+ ni->flags = 0;
ni->creation_time = ni->last_data_change_time =
ni->last_mft_change_time =
ni->last_access_time = time(NULL);
|