Commit 91a7dab9 authored by Anton Altaparmakov's avatar Anton Altaparmakov

NTFS: Various fixes and cleanups. Make it work with kernel 2.5.9.

parent 9a5d1f49
......@@ -31,6 +31,10 @@
#define MAX_BUF_PER_PAGE (PAGE_CACHE_SIZE / 512)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,8)
#define page_buffers(page) (page)->buffers
#endif
/*
* Async io completion handler for accessing files. Adapted from
* end_buffer_read_mst_async().
......@@ -110,7 +114,7 @@ static int ntfs_file_read_block(struct page *page)
blocksize = 1 << blocksize_bits;
create_empty_buffers(page, blocksize);
bh = head = page->buffers;
bh = head = page_buffers(page);
if (!bh)
return -ENOMEM;
......@@ -387,7 +391,7 @@ static int ntfs_mftbmp_readpage(ntfs_volume *vol, struct page *page)
blocksize_bits = vol->sb->s_blocksize_bits;
create_empty_buffers(page, blocksize);
bh = head = page->buffers;
bh = head = page_buffers(page);
if (!bh)
return -ENOMEM;
......@@ -621,7 +625,7 @@ int ntfs_mst_readpage(struct file *dir, struct page *page)
blocksize = 1 << blocksize_bits;
create_empty_buffers(page, blocksize);
bh = head = page->buffers;
bh = head = page_buffers(page);
if (!bh)
return -ENOMEM;
......
......@@ -485,7 +485,6 @@ run_list_element *merge_run_lists(run_list_element *drl, run_list_element *srl)
finish = ((drl[dins].lcn >= LCN_RL_NOT_MAPPED) && /* End of file */
((drl[dins].vcn + drl[dins].length) <= /* End of hole */
(srl[send-1].vcn + srl[send-1].length)));
//srl[send-1].vcn));
/* Or we'll lose an end marker */
if (start && finish && (drl[dins].length == 0))
......@@ -510,9 +509,10 @@ run_list_element *merge_run_lists(run_list_element *drl, run_list_element *srl)
else
nrl = ntfs_rl_split (drl, ds, srl + sstart, ss, dins);
if (marker) {
for (ds = 0; nrl[ds].lcn; ds++) ;
nrl = ntfs_rl_insert (nrl, ds+1, srl + marker, 1, ds-1);
if (marker && !IS_ERR(nrl)) {
for (ds = 0; nrl[ds].length; ds++)
;
nrl = ntfs_rl_insert(nrl, ds + 1, srl + marker, 1, ds);
}
}
......@@ -1576,7 +1576,7 @@ attr_search_context *get_attr_search_ctx(ntfs_inode *ni, MFT_RECORD *mrec)
ctx = kmem_cache_alloc(ntfs_attr_ctx_cache, SLAB_NOFS);
if (ctx)
init_attr_search_ctx(ctx, ni, mrec);
return NULL;
return ctx;
}
/**
......
......@@ -81,8 +81,15 @@ typedef struct {
u8 jump[3]; /* Irrelevant (jump to boot up code).*/
u64 oem_id; /* Magic "NTFS ". */
BIOS_PARAMETER_BLOCK bpb; /* See BIOS_PARAMETER_BLOCK. */
u8 unused[4]; /* zero */
s64 number_of_sectors; /* Number of sectors in volume. Gives
u8 unused[4]; /* zero, NTFS diskedit.exe states that
this is actually:
__u8 physical_drive; // 0x80
__u8 current_head; // zero
__u8 extended_boot_signature;
// 0x80
__u8 unused; // zero
*/
/*0x28*/s64 number_of_sectors; /* Number of sectors in volume. Gives
maximum volume size of 2^63 sectors.
Assuming standard sector size of 512
bytes, the maximum byte size is
......@@ -95,9 +102,10 @@ typedef struct {
u8 reserved1[3]; /* zero */
u64 volume_serial_number; /* Irrelevant (serial number). */
u32 checksum; /* Boot sector checksum. */
u8 bootstrap[426]; /* Irrelevant (boot up code). */
/*0x54*/u8 bootstrap[426]; /* Irrelevant (boot up code). */
u16 end_of_sector_marker; /* End of bootsector magic. Always is
0xaa55 in little endian. */
/* sizeof() = 512 (0x200) bytes */
} __attribute__ ((__packed__)) NTFS_BOOT_SECTOR;
/*
......@@ -174,8 +182,10 @@ typedef enum {
FILE_MFT = 0, /* Master file table (mft). Data attribute
contains the entries and bitmap attribute
records which ones are in use (bit==1). */
FILE_MFTMirr = 1, /* Mft mirror (copy of first four mft records)
in data attribute. */
FILE_MFTMirr = 1, /* Mft mirror: copy of first four mft records
in data attribute. If cluster size > 4kiB,
copy of first N mft records, with
N = cluster_size / mft_record_size. */
FILE_LogFile = 2, /* Journalling log in data attribute. */
FILE_Volume = 3, /* Volume name attribute and volume information
attribute (flags and ntfs version). Windows
......
......@@ -327,12 +327,12 @@ int ntfs_ucstonls(const ntfs_volume *vol, const uchar_t *ins,
if (ins) {
ns = *outs;
ns_len = outs_len;
if (!ns_len) {
if (ns && !ns_len) {
wc = -ENAMETOOLONG;
goto conversion_err;
}
if (!ns) {
ns_len = ins_len * 3;
ns_len = ins_len * NLS_MAX_CHARSET_SIZE;
ns = (unsigned char*)kmalloc(ns_len, GFP_NOFS);
if (!ns)
goto mem_err_out;
......@@ -347,12 +347,12 @@ retry: wc = nls->uni2char(le16_to_cpu(ins[i]), ns + o,
break;
else if (wc == -ENAMETOOLONG && ns != *outs) {
unsigned char *tc;
/* Grow by 64 bytes. (Chosen at random.) */
tc = (unsigned char*)kmalloc(ns_len + 64,
GFP_NOFS);
/* Grow in multiples of 64 bytes. */
tc = (unsigned char*)kmalloc((ns_len + 64) &
~63, GFP_NOFS);
if (tc) {
memcpy(tc, ns, ns_len);
ns_len += 64;
ns_len = (ns_len + 64) & ~63;
kfree(ns);
ns = tc;
goto retry;
......@@ -364,7 +364,7 @@ retry: wc = nls->uni2char(le16_to_cpu(ins[i]), ns + o,
*outs = ns;
return o;
} /* else (!ins) */
ntfs_error(NULL, "Received NULL pointer.");
ntfs_error(vol->sb, "Received NULL pointer.");
return -EINVAL;
conversion_err:
ntfs_error(vol->sb, "Unicode name contains characters that cannot be "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment