aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAnton Altaparmakov <aia21@cantab.net>2005-09-08 15:40:32 -0400
committerAnton Altaparmakov <aia21@cantab.net>2005-09-08 15:40:32 -0400
commit0aacceacf35451ffb771ec825555e98c5dce8b01 (patch)
tree91ee974bcc56bf4bb55352098fa1b69131a2fe89 /fs
parentf25dfb5e44fa8641961780d681bc1871abcfb861 (diff)
NTFS: Add fs/ntfs/attrib.[hc]::ntfs_resident_attr_value_resize().
Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
Diffstat (limited to 'fs')
-rw-r--r--fs/ntfs/ChangeLog1
-rw-r--r--fs/ntfs/attrib.c40
-rw-r--r--fs/ntfs/attrib.h2
3 files changed, 43 insertions, 0 deletions
diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
index 96224c020797..29841bf82264 100644
--- a/fs/ntfs/ChangeLog
+++ b/fs/ntfs/ChangeLog
@@ -59,6 +59,7 @@ ToDo/Notes:
59 index entry is in the index root, we forgot to set the @ir pointer in 59 index entry is in the index root, we forgot to set the @ir pointer in
60 the index context. Thanks to Yura Pakhuchiy for finding this bug. 60 the index context. Thanks to Yura Pakhuchiy for finding this bug.
61 - Remove bogus setting of PageError in ntfs_read_compressed_block(). 61 - Remove bogus setting of PageError in ntfs_read_compressed_block().
62 - Add fs/ntfs/attrib.[hc]::ntfs_resident_attr_value_resize().
62 63
632.1.23 - Implement extension of resident files and make writing safe as well as 642.1.23 - Implement extension of resident files and make writing safe as well as
64 many bug fixes, cleanups, and enhancements... 65 many bug fixes, cleanups, and enhancements...
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index cd0f9e740b14..79dda3980684 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -1247,6 +1247,46 @@ int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size)
1247} 1247}
1248 1248
1249/** 1249/**
1250 * ntfs_resident_attr_value_resize - resize the value of a resident attribute
1251 * @m: mft record containing attribute record
1252 * @a: attribute record whose value to resize
1253 * @new_size: new size in bytes to which to resize the attribute value of @a
1254 *
1255 * Resize the value of the attribute @a in the mft record @m to @new_size bytes.
1256 * If the value is made bigger, the newly allocated space is cleared.
1257 *
1258 * Return 0 on success and -errno on error. The following error codes are
1259 * defined:
1260 * -ENOSPC - Not enough space in the mft record @m to perform the resize.
1261 *
1262 * Note: On error, no modifications have been performed whatsoever.
1263 *
1264 * Warning: If you make a record smaller without having copied all the data you
1265 * are interested in the data may be overwritten.
1266 */
1267int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a,
1268 const u32 new_size)
1269{
1270 u32 old_size;
1271
1272 /* Resize the resident part of the attribute record. */
1273 if (ntfs_attr_record_resize(m, a,
1274 le16_to_cpu(a->data.resident.value_offset) + new_size))
1275 return -ENOSPC;
1276 /*
1277 * The resize succeeded! If we made the attribute value bigger, clear
1278 * the area between the old size and @new_size.
1279 */
1280 old_size = le32_to_cpu(a->data.resident.value_length);
1281 if (new_size > old_size)
1282 memset((u8*)a + le16_to_cpu(a->data.resident.value_offset) +
1283 old_size, 0, new_size - old_size);
1284 /* Finally update the length of the attribute value. */
1285 a->data.resident.value_length = cpu_to_le32(new_size);
1286 return 0;
1287}
1288
1289/**
1250 * ntfs_attr_make_non_resident - convert a resident to a non-resident attribute 1290 * ntfs_attr_make_non_resident - convert a resident to a non-resident attribute
1251 * @ni: ntfs inode describing the attribute to convert 1291 * @ni: ntfs inode describing the attribute to convert
1252 * 1292 *
diff --git a/fs/ntfs/attrib.h b/fs/ntfs/attrib.h
index 0e4ac6d3c0e7..0618ed6fd7b3 100644
--- a/fs/ntfs/attrib.h
+++ b/fs/ntfs/attrib.h
@@ -99,6 +99,8 @@ extern int ntfs_attr_can_be_resident(const ntfs_volume *vol,
99 const ATTR_TYPE type); 99 const ATTR_TYPE type);
100 100
101extern int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size); 101extern int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size);
102extern int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a,
103 const u32 new_size);
102 104
103extern int ntfs_attr_make_non_resident(ntfs_inode *ni); 105extern int ntfs_attr_make_non_resident(ntfs_inode *ni);
104 106