aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Alcantara <pcacjr@gmail.com>2011-07-24 08:04:58 +0000
committerPaulo Alcantara <pcacjr@gmail.com>2011-09-07 07:19:07 +0000
commit64f292595ae2f0a993b2e68eb2ba3372cbb91479 (patch)
treec5cfd8902b0ea0292b699c745007c706ab0ae573
parent338081d635fccb80ee533a46babc6c3718f6a99d (diff)
downloadsyslinux-64f292595ae2f0a993b2e68eb2ba3372cbb91479.tar.gz
syslinux-64f292595ae2f0a993b2e68eb2ba3372cbb91479.tar.xz
syslinux-64f292595ae2f0a993b2e68eb2ba3372cbb91479.zip
ntfs: implement fixups_realloc()
Signed-off-by: Paulo Alcantara <pcacjr@gmail.com>
-rw-r--r--core/fs/ntfs/ntfs.c57
1 files changed, 32 insertions, 25 deletions
diff --git a/core/fs/ntfs/ntfs.c b/core/fs/ntfs/ntfs.c
index a1c35726..8d4c042c 100644
--- a/core/fs/ntfs/ntfs.c
+++ b/core/fs/ntfs/ntfs.c
@@ -669,6 +669,37 @@ out:
return -1;
}
+/* Fixups reallocation */
+static void fixups_realloc(void *buf, MFT_RECORD *mrec)
+{
+ uint8_t *usa_start;
+ uint16_t usa_no;
+ uint8_t *usa_end;
+ char *p;
+ uint16_t val;
+
+ /* get the Update Sequence Array */
+ usa_start = (uint8_t *)mrec + mrec->usa_ofs; /* there it is! grr... */
+ usa_no = *(uint16_t *)usa_start;
+ usa_end = (uint8_t *)usa_start + mrec->usa_count + 1;
+
+ p = (char *)buf;
+ usa_start += 2; /* make it to point to the fixups */
+ while (*p) {
+ val = *p | *(p + 1);
+ if (val == usa_no) {
+ if (usa_start < usa_end && usa_start + 1 < usa_end) {
+ *p++ = *usa_start++;
+ *p++ = *usa_start++;
+ } else {
+ p++;
+ }
+ } else {
+ p++;
+ }
+ }
+}
+
static uint32_t ntfs_getfssec(struct file *file, char *buf, int sectors,
bool *have_more)
{
@@ -680,13 +711,8 @@ static uint32_t ntfs_getfssec(struct file *file, char *buf, int sectors,
sector_t block;
MFT_RECORD *mrec;
ATTR_RECORD *attr;
- uint8_t *usa_start;
- uint16_t usa_no;
- uint8_t *usa_end;
char data[1024];
char *pbuf;
- char *p;
- uint16_t val;
non_resident = NTFS_PVT(inode)->non_resident;
@@ -706,11 +732,6 @@ static uint32_t ntfs_getfssec(struct file *file, char *buf, int sectors,
goto out;
}
- /* get the Update Sequence Array */
- usa_start = (uint8_t *)mrec + mrec->usa_ofs; /* there it is! grr... */
- usa_no = *(uint16_t *)usa_start;
- usa_end = (uint8_t *)usa_start + mrec->usa_count + 1;
-
attr = attr_lookup(NTFS_AT_DATA, mrec);
if (!attr) {
printf("No attribute found!\n");
@@ -724,21 +745,7 @@ static uint32_t ntfs_getfssec(struct file *file, char *buf, int sectors,
*/
memcpy(buf, pbuf, inode->size);
- p = buf;
- usa_start += 2; /* make it to point to the fixups */
- while (*p) {
- val = *p | *(p + 1);
- if (val == usa_no) {
- if (usa_start != usa_end && usa_start + 1 != usa_end) {
- *p++ = *usa_start++;
- *p++ = *usa_start++;
- } else {
- p++;
- }
- } else {
- p++;
- }
- }
+ fixups_realloc(buf, mrec);
ret = inode->size;
}