parent
f6171df97b
commit
69306cc493
|
@ -1,9 +1,7 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* attrib.h - Exports for attribute handling. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -79,33 +77,33 @@ struct _ntfs_attr_search_ctx {
|
|||
ATTR_RECORD *base_attr;
|
||||
};
|
||||
|
||||
extern void ntfs_reinit_attr_search_ctx(ntfs_attr_search_ctx *ctx);
|
||||
extern ntfs_attr_search_ctx *ntfs_get_attr_search_ctx(ntfs_inode *ni,
|
||||
extern void ntfs_attr_reinit_search_ctx(ntfs_attr_search_ctx *ctx);
|
||||
extern ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni,
|
||||
MFT_RECORD *mrec);
|
||||
extern void ntfs_put_attr_search_ctx(ntfs_attr_search_ctx *ctx);
|
||||
extern void ntfs_attr_put_search_ctx(ntfs_attr_search_ctx *ctx);
|
||||
|
||||
extern int ntfs_lookup_attr(const ATTR_TYPES type, const uchar_t *name,
|
||||
extern int ntfs_attr_lookup(const ATTR_TYPES type, const uchar_t *name,
|
||||
const u32 name_len, const IGNORE_CASE_BOOL ic,
|
||||
const VCN lowest_vcn, const u8 *val, const u32 val_len,
|
||||
ntfs_attr_search_ctx *ctx);
|
||||
|
||||
/**
|
||||
* ntfs_walk_attrs - syntactic sugar for walking all attributes in an inode
|
||||
* ntfs_attrs_walk - syntactic sugar for walking all attributes in an inode
|
||||
* @ctx: initialised attribute search context
|
||||
*
|
||||
* Syntactic sugar for walking attributes in an inode.
|
||||
*
|
||||
* Return 0 on success and -1 on error with errno set to the error code from
|
||||
* ntfs_lookup_attr().
|
||||
* ntfs_attr_lookup().
|
||||
*
|
||||
* Example: When you want to enumerate all attributes in an open ntfs inode
|
||||
* @ni, you can simply do:
|
||||
*
|
||||
* int err;
|
||||
* ntfs_attr_search_ctx *ctx = ntfs_get_attr_search_ctx(ni, NULL);
|
||||
* ntfs_attr_search_ctx *ctx = ntfs_attr_get_search_ctx(ni, NULL);
|
||||
* if (!ctx)
|
||||
* // Error code is in errno. Handle this case.
|
||||
* while (!(err = ntfs_walk_attrs(ctx))) {
|
||||
* while (!(err = ntfs_attrs_walk(ctx))) {
|
||||
* ATTR_RECORD *attr = ctx->attr;
|
||||
* // attr now contains the next attribute. Do whatever you want
|
||||
* // with it and then just continue with the while loop.
|
||||
|
@ -114,9 +112,9 @@ extern int ntfs_lookup_attr(const ATTR_TYPES type, const uchar_t *name,
|
|||
* // Ooops. An error occured! You should handle this case.
|
||||
* // Now finished with all attributes in the inode.
|
||||
*/
|
||||
static __inline__ int ntfs_walk_attrs(ntfs_attr_search_ctx *ctx)
|
||||
static __inline__ int ntfs_attrs_walk(ntfs_attr_search_ctx *ctx)
|
||||
{
|
||||
return ntfs_lookup_attr(0, NULL, 0, 0, 0, NULL, 0, ctx);
|
||||
return ntfs_attr_lookup(0, NULL, 0, 0, 0, NULL, 0, ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -276,7 +274,7 @@ extern int ntfs_write_significant_bytes(s8 *dst, const s8 *dst_max,
|
|||
*
|
||||
* FIXME: Describe possible errnos.
|
||||
*/
|
||||
s64 get_attribute_value_length(const ATTR_RECORD *a);
|
||||
s64 ntfs_get_attribute_value_length(const ATTR_RECORD *a);
|
||||
|
||||
/**
|
||||
* get_attribute_value - return the attribute value of an attribute
|
||||
|
@ -292,7 +290,7 @@ s64 get_attribute_value_length(const ATTR_RECORD *a);
|
|||
* then nothing was read due to a zero-length attribute value, otherwise
|
||||
* errno describes the error.
|
||||
*/
|
||||
s64 get_attribute_value(const ntfs_volume *vol, const MFT_RECORD *m,
|
||||
s64 ntfs_get_attribute_value(const ntfs_volume *vol, const MFT_RECORD *m,
|
||||
const ATTR_RECORD *a, u8 *b);
|
||||
|
||||
#endif /* defined _NTFS_ATTRIB_H */
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* bitmap.h - Exports for bitmap handling. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -37,14 +35,14 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* ntfs_set_bit - set a bit in a field of bits
|
||||
* ntfs_bit_set - set a bit in a field of bits
|
||||
* @bitmap: field of bits
|
||||
* @bit: bit to set
|
||||
* @new_value: value to set bit to (0 or 1)
|
||||
*
|
||||
* Set the bit @bit in the @bitmap to @new_value. Ignore all errors.
|
||||
*/
|
||||
static __inline__ void ntfs_set_bit(u8 *bitmap, const u64 bit,
|
||||
static __inline__ void ntfs_bit_set(u8 *bitmap, const u64 bit,
|
||||
const u8 new_value)
|
||||
{
|
||||
// Dprintf("bitmap %p, bit 0x%Lx, new_value %i\n", bitmap, bit, new_value);
|
||||
|
@ -57,21 +55,21 @@ static __inline__ void ntfs_set_bit(u8 *bitmap, const u64 bit,
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_get_bit - get value of a bit in a field of bits
|
||||
* ntfs_bit_get - get value of a bit in a field of bits
|
||||
* @bitmap: field of bits
|
||||
* @bit: bit to get
|
||||
*
|
||||
* Get and return the value of the bit @bit in @bitmap (0 or 1).
|
||||
* Return -1 on error.
|
||||
*/
|
||||
static __inline__ char ntfs_get_bit(const u8 *bitmap, const u64 bit)
|
||||
static __inline__ char ntfs_bit_get(const u8 *bitmap, const u64 bit)
|
||||
{
|
||||
if (!bitmap)
|
||||
return -1;
|
||||
return (bitmap[bit >> 3] >> (bit & 7)) & 1;
|
||||
}
|
||||
|
||||
static __inline__ void ntfs_change_bit(u8 *bitmap, const u64 bit)
|
||||
static __inline__ void ntfs_bit_change(u8 *bitmap, const u64 bit)
|
||||
{
|
||||
if (!bitmap)
|
||||
return;
|
||||
|
@ -79,7 +77,7 @@ static __inline__ void ntfs_change_bit(u8 *bitmap, const u64 bit)
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_get_and_set_bit - get value of a bit in a field of bits and set it
|
||||
* ntfs_bit_get_and_set - get value of a bit in a field of bits and set it
|
||||
* @bitmap: field of bits
|
||||
* @bit: bit to get/set
|
||||
* @new_value: value to set bit to (0 or 1)
|
||||
|
@ -87,7 +85,7 @@ static __inline__ void ntfs_change_bit(u8 *bitmap, const u64 bit)
|
|||
* Return the value of the bit @bit and set it to @new_value (0 or 1).
|
||||
* Return -1 on error.
|
||||
*/
|
||||
static __inline__ char ntfs_get_and_set_bit(u8 *bitmap, const u64 bit,
|
||||
static __inline__ char ntfs_bit_get_and_set(u8 *bitmap, const u64 bit,
|
||||
const u8 new_value)
|
||||
{
|
||||
register u8 old_bit, shift;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* bootsect.h - Exports for bootsector record handling. Part of the Linux-NTFS
|
||||
* project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -41,8 +39,9 @@
|
|||
* disregarding the value of silent (but only if configure was run with
|
||||
* --enable-debug).
|
||||
*/
|
||||
extern BOOL is_boot_sector_ntfs(const NTFS_BOOT_SECTOR *b, const BOOL silent);
|
||||
extern int parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b);
|
||||
extern BOOL ntfs_boot_sector_is_ntfs(const NTFS_BOOT_SECTOR *b,
|
||||
const BOOL silent);
|
||||
extern int ntfs_boot_sector_parse(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b);
|
||||
|
||||
#endif /* defined _NTFS_BOOTSECT_H */
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* compat.h - Tweaks for Windows compatability.
|
||||
*
|
||||
* Copyright (c) 2002 Richard Russon
|
||||
* Copyright (c) 2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
* by the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program/include file is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program (in the main directory of the Linux-NTFS
|
||||
* distribution in the file COPYING); if not, write to the Free Software
|
||||
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _NTFS_COMPAT_H
|
||||
#define _NTFS_COMPAT_H
|
||||
|
||||
#ifdef WINDOWS
|
||||
|
||||
#ifndef HAVE_FFS
|
||||
#define HAVE_FFS
|
||||
extern int ffs(int i);
|
||||
#endif /* HAVE_FFS */
|
||||
|
||||
#define HAVE_STDIO_H /* mimic config.h */
|
||||
#define HAVE_STDARG_H
|
||||
|
||||
#define atoll _atoi64
|
||||
#define fdatasync commit
|
||||
#define __inline__ inline
|
||||
#define __attribute__(X) /*nothing*/
|
||||
|
||||
#else /* !defined WINDOWS */
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0 /* unix is binary by default */
|
||||
#endif
|
||||
|
||||
#endif /* defined WINDOWS */
|
||||
|
||||
#endif /* defined _NTFS_COMPAT_H */
|
||||
|
|
@ -1,9 +1,7 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* debug.h - Debugging output functions. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -65,14 +63,14 @@ static __inline__ void Dperror(const char *s)
|
|||
errno = eo;
|
||||
}
|
||||
|
||||
extern void ntfs_debug_dump_runlist(const runlist_element *rl);
|
||||
extern void ntfs_debug_runlist_dump(const runlist_element *rl);
|
||||
|
||||
#else
|
||||
|
||||
static __inline__ void Dprintf(const char *fmt, ...) {}
|
||||
static __inline__ void Dputs(const char *s) {}
|
||||
static __inline__ void Dperror(const char *s) {}
|
||||
static __inline__ void ntfs_debug_dump_runlist(const runlist_element *rl) {}
|
||||
static __inline__ void ntfs_debug_runlist_dump(const runlist_element *rl) {}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* dir.h - Exports for directory handling. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -29,7 +27,7 @@
|
|||
/* The little endian Unicode string $I30 as a global constant. */
|
||||
extern uchar_t I30[5];
|
||||
|
||||
extern u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni,
|
||||
extern u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni,
|
||||
const uchar_t *uname, const int uname_len);
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* disk_io.h - Exports for disk io. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -34,9 +32,9 @@ extern s64 ntfs_mst_pread(const int fd, const s64 pos, s64 count,
|
|||
extern s64 ntfs_mst_pwrite(const int fd, const s64 pos, s64 count,
|
||||
const u32 bksize, const void *b);
|
||||
|
||||
extern s64 ntfs_read_clusters(const ntfs_volume *vol, const s64 lcn,
|
||||
extern s64 ntfs_clusters_read(const ntfs_volume *vol, const s64 lcn,
|
||||
const s64 count, const void *b);
|
||||
extern s64 ntfs_write_clusters(const ntfs_volume *vol, const s64 lcn,
|
||||
extern s64 ntfs_clusters_write(const ntfs_volume *vol, const s64 lcn,
|
||||
const s64 count, const void *b);
|
||||
|
||||
#endif /* defined _NTFS_DISK_IO_H */
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* endians.h - Definitions related to handling of byte ordering. Part of the
|
||||
* Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000,2001 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* inode.h - Defines for NTFS inode handling. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2001,2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2001,2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -100,11 +98,11 @@ struct _ntfs_inode {
|
|||
};
|
||||
};
|
||||
|
||||
extern ntfs_inode *ntfs_open_inode(ntfs_volume *vol, const MFT_REF mref);
|
||||
extern ntfs_inode *ntfs_inode_open(ntfs_volume *vol, const MFT_REF mref);
|
||||
|
||||
extern int ntfs_close_inode(ntfs_inode *ni);
|
||||
extern int ntfs_inode_close(ntfs_inode *ni);
|
||||
|
||||
extern ntfs_inode *ntfs_open_extent_inode(ntfs_inode *base_ni,
|
||||
extern ntfs_inode *ntfs_extent_inode_open(ntfs_inode *base_ni,
|
||||
const MFT_REF mref);
|
||||
|
||||
#endif /* defined _NTFS_INODE_H */
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* layout.h - Ntfs on-disk layout structures. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -110,25 +108,25 @@ typedef enum {
|
|||
* Generic magic comparison macros. Finally found a use for the ## preprocessor
|
||||
* operator! (-8
|
||||
*/
|
||||
#define is_magic(x, m) ( (u32)(x) == (u32)magic_##m )
|
||||
#define is_magicp(p, m) ( *(u32*)(p) == (u32)magic_##m )
|
||||
#define ntfs_is_magic(x, m) ( (u32)(x) == (u32)magic_##m )
|
||||
#define ntfs_is_magicp(p, m) ( *(u32*)(p) == (u32)magic_##m )
|
||||
|
||||
/*
|
||||
* Specialised magic comparison macros.
|
||||
*/
|
||||
#define is_baad_record(x) ( is_magic (x, BAAD) )
|
||||
#define is_baad_recordp(p) ( is_magicp(p, BAAD) )
|
||||
#define is_chkd_record(x) ( is_magic (x, CHKD) )
|
||||
#define is_chkd_recordp(p) ( is_magicp(p, CHKD) )
|
||||
#define is_file_record(x) ( is_magic (x, FILE) )
|
||||
#define is_file_recordp(p) ( is_magicp(p, FILE) )
|
||||
#define is_hole_record(x) ( is_magic (x, HOLE) )
|
||||
#define is_hole_recordp(p) ( is_magicp(p, HOLE) )
|
||||
#define is_indx_record(x) ( is_magic (x, INDX) )
|
||||
#define is_indx_recordp(p) ( is_magicp(p, INDX) )
|
||||
#define ntfs_is_baad_record(x) ( ntfs_is_magic (x, BAAD) )
|
||||
#define ntfs_is_baad_recordp(p) ( ntfs_is_magicp(p, BAAD) )
|
||||
#define ntfs_is_chkd_record(x) ( ntfs_is_magic (x, CHKD) )
|
||||
#define ntfs_is_chkd_recordp(p) ( ntfs_is_magicp(p, CHKD) )
|
||||
#define ntfs_is_file_record(x) ( ntfs_is_magic (x, FILE) )
|
||||
#define ntfs_is_file_recordp(p) ( ntfs_is_magicp(p, FILE) )
|
||||
#define ntfs_is_hole_record(x) ( ntfs_is_magic (x, HOLE) )
|
||||
#define ntfs_is_hole_recordp(p) ( ntfs_is_magicp(p, HOLE) )
|
||||
#define ntfs_is_indx_record(x) ( ntfs_is_magic (x, INDX) )
|
||||
#define ntfs_is_indx_recordp(p) ( ntfs_is_magicp(p, INDX) )
|
||||
|
||||
#define is_mft_record(x) ( is_file_record(x) )
|
||||
#define is_mft_recordp(p) ( is_file_recordp(p) )
|
||||
#define ntfs_is_mft_record(x) ( ntfs_is_file_record(x) )
|
||||
#define ntfs_is_mft_recordp(p) ( ntfs_is_file_recordp(p) )
|
||||
|
||||
/*
|
||||
* Defines for the NTFS filesystem. Don't want to use BLOCK_SIZE and
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* list.h - Linked list implementation. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c)
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov and others
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* logfile.h - Exports for $LogFile handling. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000,2001 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -34,10 +32,10 @@ typedef enum {
|
|||
/*
|
||||
* Specialised magic comparison macros.
|
||||
*/
|
||||
#define is_rstr_record(x) ( is_magic (x, RSTR) )
|
||||
#define is_rstr_recordp(p) ( is_magicp(p, RSTR) )
|
||||
#define is_rcrd_record(x) ( is_magic (x, RCRD) )
|
||||
#define is_rcrd_recordp(p) ( is_magicp(p, RCRD) )
|
||||
#define ntfs_is_rstr_record(x) ( ntfs_is_magic (x, RSTR) )
|
||||
#define ntfs_is_rstr_recordp(p) ( ntfs_is_magicp(p, RSTR) )
|
||||
#define ntfs_is_rcrd_record(x) ( ntfs_is_magic (x, RCRD) )
|
||||
#define ntfs_is_rcrd_recordp(p) ( ntfs_is_magicp(p, RCRD) )
|
||||
|
||||
/*
|
||||
* Log file organization:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* mft.h - Exports for MFT record handling. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -77,7 +77,7 @@ static __inline__ int ntfs_mft_record_write(const ntfs_volume *vol,
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_get_mft_record_data_size - return number of bytes used in mft record @b
|
||||
* ntfs_mft_record_get_data_size - return number of bytes used in mft record @b
|
||||
* @m: mft record to get the data size of
|
||||
*
|
||||
* Takes the mft record @m and returns the number of bytes used in the record
|
||||
|
@ -92,9 +92,9 @@ static __inline__ int ntfs_mft_record_write(const ntfs_volume *vol,
|
|||
* as well but that could in theory be non-existent (don't know if Windows'
|
||||
* NTFS driver/chkdsk wouldn't view this as corruption in itself though).
|
||||
*/
|
||||
static __inline__ u32 ntfs_get_mft_record_data_size(const MFT_RECORD *m)
|
||||
static __inline__ u32 ntfs_mft_record_get_data_size(const MFT_RECORD *m)
|
||||
{
|
||||
if (!m || !is_mft_record(m->magic))
|
||||
if (!m || !ntfs_is_mft_record(m->magic))
|
||||
return 0;
|
||||
/* Get the number of used bytes and return it. */
|
||||
return le32_to_cpu(m->bytes_in_use);
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* mst.h - Exports for multi sector transfer fixup functions. Part of the
|
||||
* Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -28,9 +26,9 @@
|
|||
#include "types.h"
|
||||
#include "layout.h"
|
||||
|
||||
extern int ntfs_post_read_mst_fixup(NTFS_RECORD *b, const u32 size);
|
||||
extern int ntfs_pre_write_mst_fixup(NTFS_RECORD *b, const u32 size);
|
||||
extern void ntfs_post_write_mst_fixup(NTFS_RECORD *b);
|
||||
extern int ntfs_mst_post_read_fixup(NTFS_RECORD *b, const u32 size);
|
||||
extern int ntfs_mst_pre_write_fixup(NTFS_RECORD *b, const u32 size);
|
||||
extern void ntfs_mst_post_write_fixup(NTFS_RECORD *b);
|
||||
|
||||
#endif /* defined _NTFS_MST_H */
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* runlist.h - Exports for runlist handling. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2002 Richard Russon.
|
||||
* Copyright (c) 2002 Anton Altaparmakov
|
||||
* Copyright (c) 2002 Richard Russon
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -56,13 +54,13 @@ extern LCN ntfs_rl_vcn_to_lcn(const runlist_element *rl, const VCN vcn);
|
|||
extern s64 ntfs_rl_pwrite(const ntfs_volume *vol, const runlist_element *rl,
|
||||
const s64 pos, s64 count, void *b);
|
||||
|
||||
extern runlist_element *ntfs_merge_runlists(runlist_element *drl,
|
||||
extern runlist_element *ntfs_runlists_merge(runlist_element *drl,
|
||||
runlist_element *srl);
|
||||
|
||||
extern runlist_element *ntfs_decompress_mapping_pairs(const ntfs_volume *vol,
|
||||
extern runlist_element *ntfs_mapping_pairs_decompress(const ntfs_volume *vol,
|
||||
const ATTR_RECORD *attr, runlist_element *old_rl);
|
||||
|
||||
extern int ntfs_build_mapping_pairs(const ntfs_volume *vol, s8 *dst,
|
||||
extern int ntfs_mapping_pairs_build(const ntfs_volume *vol, s8 *dst,
|
||||
const int dst_len, const runlist_element *rl);
|
||||
|
||||
#endif /* defined _NTFS_RUNLIST_H */
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* support.h - Useful definitions and macros. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* types.h - Misc type definitions not related to on-disk structure. Part of
|
||||
* the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* unistr.h - Exports for unicode string handling. Part of the Linux-NTFS
|
||||
* project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -30,11 +28,11 @@
|
|||
|
||||
extern const u8 legal_ansi_char_array[0x40];
|
||||
|
||||
extern BOOL ntfs_are_names_equal(const uchar_t *s1, size_t s1_len,
|
||||
extern BOOL ntfs_names_are_equal(const uchar_t *s1, size_t s1_len,
|
||||
const uchar_t *s2, size_t s2_len, const IGNORE_CASE_BOOL ic,
|
||||
const uchar_t *upcase, const u32 upcase_size);
|
||||
|
||||
extern int ntfs_collate_names(const uchar_t *name1, const u32 name1_len,
|
||||
extern int ntfs_names_collate(const uchar_t *name1, const u32 name1_len,
|
||||
const uchar_t *name2, const u32 name2_len,
|
||||
const int err_val, const IGNORE_CASE_BOOL ic,
|
||||
const uchar_t *upcase, const u32 upcase_len);
|
||||
|
@ -44,7 +42,7 @@ extern int ntfs_ucsncmp(const uchar_t *s1, const uchar_t *s2, size_t n);
|
|||
extern int ntfs_ucsncasecmp(const uchar_t *s1, const uchar_t *s2, size_t n,
|
||||
const uchar_t *upcase, const u32 upcase_size);
|
||||
|
||||
extern void ntfs_upcase_name(uchar_t *name, u32 name_len,
|
||||
extern void ntfs_name_upcase(uchar_t *name, u32 name_len,
|
||||
const uchar_t *upcase, const u32 upcase_len);
|
||||
|
||||
extern void ntfs_file_upcase_value(FILE_NAME_ATTR *file_name_attr,
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* volume.h - Exports for NTFS volume handling. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -141,14 +139,14 @@ struct _ntfs_volume {
|
|||
table. */
|
||||
};
|
||||
|
||||
extern ntfs_volume *ntfs_startup_volume(const char *name, unsigned long rwflag);
|
||||
extern ntfs_volume *ntfs_volume_startup(const char *name, unsigned long rwflag);
|
||||
extern ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag);
|
||||
|
||||
extern int ntfs_umount(ntfs_volume *vol, const BOOL force);
|
||||
|
||||
extern int ntfs_is_version_supported(ntfs_volume *vol);
|
||||
extern int ntfs_reset_logfile(ntfs_volume *vol);
|
||||
extern int ntfs_set_volume_flags(ntfs_volume *v, const u16 flags);
|
||||
extern int ntfs_version_is_supported(ntfs_volume *vol);
|
||||
extern int ntfs_logfile_reset(ntfs_volume *vol);
|
||||
extern int ntfs_volume_set_flags(ntfs_volume *v, const u16 flags);
|
||||
|
||||
#endif /* defined _NTFS_VOLUME_H */
|
||||
|
||||
|
|
184
libntfs/attrib.c
184
libntfs/attrib.c
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* attrib.c - Attribute handling code. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (C) 2002 Richard Russon.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
* Copyright (c) 2002 Richard Russon
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -39,9 +39,9 @@
|
|||
uchar_t AT_UNNAMED[] = { const_cpu_to_le16('\0') };
|
||||
|
||||
/**
|
||||
* get_attribute_value_length
|
||||
* ntfs_get_attribute_value_length
|
||||
*/
|
||||
s64 get_attribute_value_length(const ATTR_RECORD *a)
|
||||
s64 ntfs_get_attribute_value_length(const ATTR_RECORD *a)
|
||||
{
|
||||
if (!a) {
|
||||
errno = EINVAL;
|
||||
|
@ -57,9 +57,9 @@ s64 get_attribute_value_length(const ATTR_RECORD *a)
|
|||
}
|
||||
|
||||
/**
|
||||
* get_attribute_value
|
||||
* ntfs_get_attribute_value
|
||||
*/
|
||||
s64 get_attribute_value(const ntfs_volume *vol, const MFT_RECORD *m,
|
||||
s64 ntfs_get_attribute_value(const ntfs_volume *vol, const MFT_RECORD *m,
|
||||
const ATTR_RECORD *a, u8 *b)
|
||||
{
|
||||
/* Sanity checks. */
|
||||
|
@ -98,7 +98,7 @@ s64 get_attribute_value(const ntfs_volume *vol, const MFT_RECORD *m,
|
|||
* FIXME: What about attribute lists?!? (AIA)
|
||||
*/
|
||||
/* Decompress the mapping pairs array into a runlist. */
|
||||
rl = ntfs_decompress_mapping_pairs(vol, a, NULL);
|
||||
rl = ntfs_mapping_pairs_decompress(vol, a, NULL);
|
||||
if (!rl) {
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
|
@ -330,13 +330,13 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type,
|
|||
return NULL;
|
||||
__ntfs_attr_init(na, ni, type, name, name_len);
|
||||
|
||||
ctx = ntfs_get_attr_search_ctx(ni, NULL);
|
||||
ctx = ntfs_attr_get_search_ctx(ni, NULL);
|
||||
if (!ctx) {
|
||||
err = errno;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
if (ntfs_lookup_attr(type, name, name_len, 0, 0, NULL, 0, ctx)) {
|
||||
if (ntfs_attr_lookup(type, name, name_len, 0, 0, NULL, 0, ctx)) {
|
||||
err = errno;
|
||||
goto put_err_out;
|
||||
}
|
||||
|
@ -360,10 +360,10 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type,
|
|||
}
|
||||
ntfs_attr_init(na, FALSE, FALSE, FALSE, FALSE, l, l, l, 0, 0);
|
||||
}
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return na;
|
||||
put_err_out:
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
err_out:
|
||||
errno = err;
|
||||
return NULL;
|
||||
|
@ -404,27 +404,27 @@ int ntfs_attr_map_runlist(ntfs_attr *na, VCN vcn)
|
|||
__FUNCTION__, (unsigned long long)na->ni->mft_no,
|
||||
na->type, (long long)vcn);
|
||||
|
||||
ctx = ntfs_get_attr_search_ctx(na->ni, NULL);
|
||||
ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
|
||||
if (!ctx)
|
||||
return -1;
|
||||
|
||||
/* Find the attribute in the mft record. */
|
||||
if (!ntfs_lookup_attr(na->type, na->name, na->name_len, CASE_SENSITIVE,
|
||||
if (!ntfs_attr_lookup(na->type, na->name, na->name_len, CASE_SENSITIVE,
|
||||
vcn, NULL, 0, ctx)) {
|
||||
runlist_element *rl;
|
||||
|
||||
/* Decode the runlist. */
|
||||
rl = ntfs_decompress_mapping_pairs(na->ni->vol, ctx->attr,
|
||||
rl = ntfs_mapping_pairs_decompress(na->ni->vol, ctx->attr,
|
||||
na->rl);
|
||||
if (rl) {
|
||||
na->rl = rl;
|
||||
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
err = errno;
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
errno = err;
|
||||
return -1;
|
||||
}
|
||||
|
@ -620,15 +620,15 @@ s64 ntfs_attr_pread(ntfs_attr *na, const s64 pos, s64 count, void *b)
|
|||
ntfs_attr_search_ctx *ctx;
|
||||
char *val;
|
||||
|
||||
ctx = ntfs_get_attr_search_ctx(na->ni, NULL);
|
||||
ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
|
||||
if (!ctx)
|
||||
return -1;
|
||||
if (ntfs_lookup_attr(na->type, na->name, na->name_len, 0,
|
||||
if (ntfs_attr_lookup(na->type, na->name, na->name_len, 0,
|
||||
0, NULL, 0, ctx)) {
|
||||
int eo;
|
||||
res_err_out:
|
||||
eo = errno;
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
errno = eo;
|
||||
return -1;
|
||||
}
|
||||
|
@ -640,7 +640,7 @@ res_err_out:
|
|||
goto res_err_out;
|
||||
}
|
||||
memcpy(b, val + pos, count);
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return count;
|
||||
}
|
||||
total = total2 = 0;
|
||||
|
@ -801,10 +801,10 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, void *b)
|
|||
if (!NAttrNonResident(na)) {
|
||||
char *val;
|
||||
|
||||
ctx = ntfs_get_attr_search_ctx(na->ni, NULL);
|
||||
ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
|
||||
if (!ctx)
|
||||
goto err_out;
|
||||
if (ntfs_lookup_attr(na->type, na->name, na->name_len, 0,
|
||||
if (ntfs_attr_lookup(na->type, na->name, na->name_len, 0,
|
||||
0, NULL, 0, ctx))
|
||||
goto err_out;
|
||||
val = (char*)ctx->attr + le16_to_cpu(ctx->attr->value_offset);
|
||||
|
@ -826,7 +826,7 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, void *b)
|
|||
*/
|
||||
goto err_out;
|
||||
}
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return count;
|
||||
}
|
||||
total = 0;
|
||||
|
@ -845,10 +845,10 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, void *b)
|
|||
/* Handle writes beyond initialized_size. */
|
||||
if (pos + count > na->initialized_size) {
|
||||
/* Set initialized_size to @pos + @count. */
|
||||
ctx = ntfs_get_attr_search_ctx(na->ni, NULL);
|
||||
ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
|
||||
if (!ctx)
|
||||
goto err_out;
|
||||
if (ntfs_lookup_attr(na->type, na->name, na->name_len, 0,
|
||||
if (ntfs_attr_lookup(na->type, na->name, na->name_len, 0,
|
||||
0, NULL, 0, ctx))
|
||||
goto err_out;
|
||||
/* If write starts beyond initialized_size, zero the gap. */
|
||||
|
@ -877,7 +877,7 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, void *b)
|
|||
goto err_out;
|
||||
}
|
||||
na->initialized_size = pos + count;
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
ctx = NULL;
|
||||
/*
|
||||
* NOTE: At this point the initialized_size in the mft record
|
||||
|
@ -975,7 +975,7 @@ retry:
|
|||
}
|
||||
done:
|
||||
if (ctx)
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
/* Finally, return the number of bytes written. */
|
||||
return total;
|
||||
rl_err_out:
|
||||
|
@ -999,13 +999,13 @@ err_out:
|
|||
|
||||
err = 0;
|
||||
if (!ctx) {
|
||||
ctx = ntfs_get_attr_search_ctx(na->ni, NULL);
|
||||
ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
|
||||
if (!ctx)
|
||||
err = 1;
|
||||
} else
|
||||
ntfs_reinit_attr_search_ctx(ctx);
|
||||
ntfs_attr_reinit_search_ctx(ctx);
|
||||
if (!err) {
|
||||
err = ntfs_lookup_attr(na->type, na->name,
|
||||
err = ntfs_attr_lookup(na->type, na->name,
|
||||
na->name_len, 0, 0, NULL, 0, ctx);
|
||||
if (!err) {
|
||||
na->initialized_size = old_initialized_size;
|
||||
|
@ -1026,7 +1026,7 @@ err_out:
|
|||
}
|
||||
}
|
||||
if (ctx)
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
errno = eo;
|
||||
return -1;
|
||||
}
|
||||
|
@ -1078,7 +1078,7 @@ s64 ntfs_attr_mst_pread(ntfs_attr *na, const s64 pos, const s64 bk_cnt,
|
|||
return br;
|
||||
br /= bk_size;
|
||||
for (end = (u8*)b + br * bk_size; (u8*)b < end; (u8*)b += bk_size)
|
||||
ntfs_post_read_mst_fixup((NTFS_RECORD*)b, bk_size);
|
||||
ntfs_mst_post_read_fixup((NTFS_RECORD*)b, bk_size);
|
||||
/* Finally, return the number of blocks read. */
|
||||
return br;
|
||||
}
|
||||
|
@ -1131,7 +1131,7 @@ s64 ntfs_attr_mst_pwrite(ntfs_attr *na, const s64 pos, s64 bk_cnt,
|
|||
for (i = 0; i < bk_cnt; ++i) {
|
||||
int err;
|
||||
|
||||
err = ntfs_pre_write_mst_fixup((NTFS_RECORD*)
|
||||
err = ntfs_mst_pre_write_fixup((NTFS_RECORD*)
|
||||
((u8*)b + i * bk_size), bk_size);
|
||||
if (err < 0) {
|
||||
/* Abort write at this position. */
|
||||
|
@ -1145,7 +1145,7 @@ s64 ntfs_attr_mst_pwrite(ntfs_attr *na, const s64 pos, s64 bk_cnt,
|
|||
written = ntfs_attr_pwrite(na, pos, bk_cnt * bk_size, b);
|
||||
/* Quickly deprotect the data again. */
|
||||
for (i = 0; i < bk_cnt; ++i)
|
||||
ntfs_post_write_mst_fixup((NTFS_RECORD*)((u8*)b + i * bk_size));
|
||||
ntfs_mst_post_write_fixup((NTFS_RECORD*)((u8*)b + i * bk_size));
|
||||
if (written <= 0)
|
||||
return written;
|
||||
/* Finally, return the number of complete blocks written. */
|
||||
|
@ -1155,7 +1155,7 @@ s64 ntfs_attr_mst_pwrite(ntfs_attr *na, const s64 pos, s64 bk_cnt,
|
|||
/**
|
||||
* Internal:
|
||||
*
|
||||
* ntfs_find_attr - find (next) attribute in mft record
|
||||
* ntfs_attr_find - find (next) attribute in mft record
|
||||
* @type: attribute type to find
|
||||
* @name: attribute name to find (optional, i.e. NULL means don't care)
|
||||
* @name_len: attribute name length (only needed if @name present)
|
||||
|
@ -1166,11 +1166,11 @@ s64 ntfs_attr_mst_pwrite(ntfs_attr *na, const s64 pos, s64 bk_cnt,
|
|||
*
|
||||
* You shouldn't need to call this function directly. Use lookup_attr() instead.
|
||||
*
|
||||
* ntfs_find_attr() takes a search context @ctx as parameter and searches the
|
||||
* ntfs_attr_find() takes a search context @ctx as parameter and searches the
|
||||
* mft record specified by @ctx->mrec, beginning at @ctx->attr, for an
|
||||
* attribute of @type, optionally @name and @val. If found, ntfs_find_attr()
|
||||
* attribute of @type, optionally @name and @val. If found, ntfs_attr_find()
|
||||
* returns 0 and @ctx->attr will point to the found attribute. If not found,
|
||||
* ntfs_find_attr() returns -1, with errno set to the error code and @ctx->attr
|
||||
* ntfs_attr_find() returns -1, with errno set to the error code and @ctx->attr
|
||||
* is undefined (i.e. do not rely on it not changing).
|
||||
*
|
||||
* If @ctx->is_first is TRUE, the search begins with @ctx->attr itself. If it
|
||||
|
@ -1178,15 +1178,15 @@ s64 ntfs_attr_mst_pwrite(ntfs_attr *na, const s64 pos, s64 bk_cnt,
|
|||
*
|
||||
* If @type is zero (i.e. AT_UNUSED), return the first found attribute, i.e.
|
||||
* one can enumerate all attributes by setting @type to zero and then calling
|
||||
* ntfs_find_attr() repeatedly until it returns -1 with errno set to ENOENT to
|
||||
* ntfs_attr_find() repeatedly until it returns -1 with errno set to ENOENT to
|
||||
* indicate that there are no more entries. During the enumeration, each
|
||||
* successful call of ntfs_find_attr() will return the next attribute in the
|
||||
* successful call of ntfs_attr_find() will return the next attribute in the
|
||||
* mft record @ctx->mrec.
|
||||
*
|
||||
* If @type is AT_END, seek to the end and return -1 with errno set to ENOENT.
|
||||
* AT_END is not a valid attribute, its length is zero for example, thus it is
|
||||
* safer to return error instead of success in this case. This also allows us
|
||||
* to interoperate cleanly with ntfs_find_external_attr().
|
||||
* to interoperate cleanly with ntfs_external_attr_find().
|
||||
*
|
||||
* If @name is AT_UNNAMED search for an unnamed attribute. If @name is present
|
||||
* but not AT_UNNAMED search for a named attribute matching @name. Otherwise,
|
||||
|
@ -1205,11 +1205,11 @@ s64 ntfs_attr_mst_pwrite(ntfs_attr *na, const s64 pos, s64 bk_cnt,
|
|||
* Finally, the resident attribute value @val is looked for, if present.
|
||||
* If @val is not present (NULL), @val_len is ignored.
|
||||
*
|
||||
* ntfs_find_attr() only searches the specified mft record and it ignores the
|
||||
* ntfs_attr_find() only searches the specified mft record and it ignores the
|
||||
* presence of an attribute list attribute (unless it is the one being searched
|
||||
* for, obviously). If you need to take attribute lists into consideration, use
|
||||
* ntfs_lookup_attr() instead (see below). This also means that you cannot use
|
||||
* ntfs_find_attr() to search for extent records of non-resident attributes, as
|
||||
* ntfs_attr_lookup() instead (see below). This also means that you cannot use
|
||||
* ntfs_attr_find() to search for extent records of non-resident attributes, as
|
||||
* extents with lowest_vcn != 0 are usually described by the attribute list
|
||||
* attribute only. - Note that it is possible that the first extent is only in
|
||||
* the attribute list while the last extent is in the base mft record, so don't
|
||||
|
@ -1218,7 +1218,7 @@ s64 ntfs_attr_mst_pwrite(ntfs_attr *na, const s64 pos, s64 bk_cnt,
|
|||
* Warning: Never use @val when looking for attribute types which can be
|
||||
* non-resident as this most likely will result in a crash!
|
||||
*/
|
||||
static int ntfs_find_attr(const ATTR_TYPES type, const uchar_t *name,
|
||||
static int ntfs_attr_find(const ATTR_TYPES type, const uchar_t *name,
|
||||
const u32 name_len, const IGNORE_CASE_BOOL ic,
|
||||
const u8 *val, const u32 val_len, ntfs_attr_search_ctx *ctx)
|
||||
{
|
||||
|
@ -1279,12 +1279,12 @@ static int ntfs_find_attr(const ATTR_TYPES type, const uchar_t *name,
|
|||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
} else if (name && !ntfs_are_names_equal(name, name_len,
|
||||
} else if (name && !ntfs_names_are_equal(name, name_len,
|
||||
(uchar_t*)((char*)a + le16_to_cpu(a->name_offset)),
|
||||
a->name_length, ic, upcase, upcase_len)) {
|
||||
register int rc;
|
||||
|
||||
rc = ntfs_collate_names(name, name_len,
|
||||
rc = ntfs_names_collate(name, name_len,
|
||||
(uchar_t*)((char*)a +
|
||||
le16_to_cpu(a->name_offset)),
|
||||
a->name_length, 1, IGNORE_CASE,
|
||||
|
@ -1300,7 +1300,7 @@ static int ntfs_find_attr(const ATTR_TYPES type, const uchar_t *name,
|
|||
/* If the strings are not equal, continue search. */
|
||||
if (rc)
|
||||
continue;
|
||||
rc = ntfs_collate_names(name, name_len,
|
||||
rc = ntfs_names_collate(name, name_len,
|
||||
(uchar_t*)((char*)a +
|
||||
le16_to_cpu(a->name_offset)),
|
||||
a->name_length, 1, CASE_SENSITIVE,
|
||||
|
@ -1345,7 +1345,7 @@ static int ntfs_find_attr(const ATTR_TYPES type, const uchar_t *name,
|
|||
}
|
||||
}
|
||||
}
|
||||
Dputs("ntfs_find_attr(): File is corrupt. Run chkdsk.");
|
||||
Dputs("ntfs_attr_find(): File is corrupt. Run chkdsk.");
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
|
@ -1353,7 +1353,7 @@ static int ntfs_find_attr(const ATTR_TYPES type, const uchar_t *name,
|
|||
/**
|
||||
* Internal:
|
||||
*
|
||||
* ntfs_find_external_attr - find an attribute in the attribute list of an inode
|
||||
* ntfs_external_attr_find - find an attribute in the attribute list of an inode
|
||||
* @type: attribute type to find
|
||||
* @name: attribute name to find (optional, i.e. NULL means don't care)
|
||||
* @name_len: attribute name length (only needed if @name present)
|
||||
|
@ -1363,7 +1363,7 @@ static int ntfs_find_attr(const ATTR_TYPES type, const uchar_t *name,
|
|||
* @val_len: attribute value length
|
||||
* @ctx: search context with mft record and attribute to search from
|
||||
*
|
||||
* You shouldn't need to call this function directly. Use ntfs_lookup_attr()
|
||||
* You shouldn't need to call this function directly. Use ntfs_attr_lookup()
|
||||
* instead.
|
||||
*
|
||||
* Find an attribute by searching the attribute list for the corresponding
|
||||
|
@ -1373,9 +1373,9 @@ static int ntfs_find_attr(const ATTR_TYPES type, const uchar_t *name,
|
|||
*
|
||||
* If @type is zero (i.e. AT_UNUSED), return the first found attribute, i.e.
|
||||
* one can enumerate all attributes by setting @type to zero and then calling
|
||||
* ntfs_find_external_attr() repeatedly until it returns -1 with errno set to
|
||||
* ntfs_external_attr_find() repeatedly until it returns -1 with errno set to
|
||||
* ENOENT to indicate that there are no more entries. During the enumeration,
|
||||
* each successful call of ntfs_find_external_attr() will return the next
|
||||
* each successful call of ntfs_external_attr_find() will return the next
|
||||
* attribute described by the attribute list of the base mft record described
|
||||
* by the search context @ctx.
|
||||
*
|
||||
|
@ -1388,12 +1388,12 @@ static int ntfs_find_attr(const ATTR_TYPES type, const uchar_t *name,
|
|||
* match both named and unnamed attributes.
|
||||
*
|
||||
* On first search @ctx->ntfs_ino must be the inode of the base mft record and
|
||||
* @ctx must have been obtained from a call to ntfs_get_attr_search_ctx().
|
||||
* @ctx must have been obtained from a call to ntfs_attr_get_search_ctx().
|
||||
* On subsequent calls, @ctx->ntfs_ino can be any extent inode, too
|
||||
* (@ctx->base_ntfs_ino is then the base inode).
|
||||
*
|
||||
* After finishing with the attribute/mft record you need to call
|
||||
* ntfs_put_attr_search_ctx() to cleanup the search context (unmapping any
|
||||
* ntfs_attr_put_search_ctx() to cleanup the search context (unmapping any
|
||||
* mapped extent inodes, etc).
|
||||
*
|
||||
* Return 0 if the search was successful and -1 if not, with errno set to the
|
||||
|
@ -1416,7 +1416,7 @@ static int ntfs_find_attr(const ATTR_TYPES type, const uchar_t *name,
|
|||
* EIO I/O error or corrupt data structures found.
|
||||
* ENOMEM Not enough memory to allocate necessary buffers.
|
||||
*/
|
||||
static int ntfs_find_external_attr(ATTR_TYPES type, const uchar_t *name,
|
||||
static int ntfs_external_attr_find(ATTR_TYPES type, const uchar_t *name,
|
||||
const u32 name_len, const IGNORE_CASE_BOOL ic,
|
||||
const VCN lowest_vcn, const u8 *val, const u32 val_len,
|
||||
ntfs_attr_search_ctx *ctx)
|
||||
|
@ -1495,12 +1495,12 @@ static int ntfs_find_external_attr(ATTR_TYPES type, const uchar_t *name,
|
|||
if (name == AT_UNNAMED) {
|
||||
if (al_name_len)
|
||||
goto not_found;
|
||||
} else if (name && !ntfs_are_names_equal(al_name, al_name_len,
|
||||
} else if (name && !ntfs_names_are_equal(al_name, al_name_len,
|
||||
name, name_len, ic, vol->upcase,
|
||||
vol->upcase_len)) {
|
||||
register int rc;
|
||||
|
||||
rc = ntfs_collate_names(name, name_len, al_name,
|
||||
rc = ntfs_names_collate(name, name_len, al_name,
|
||||
al_name_len, 1, IGNORE_CASE,
|
||||
vol->upcase, vol->upcase_len);
|
||||
/*
|
||||
|
@ -1514,13 +1514,13 @@ static int ntfs_find_external_attr(ATTR_TYPES type, const uchar_t *name,
|
|||
continue;
|
||||
/*
|
||||
* FIXME: Reverse engineering showed 0, IGNORE_CASE but
|
||||
* that is inconsistent with ntfs_find_attr(). The
|
||||
* that is inconsistent with ntfs_attr_find(). The
|
||||
* subsequent rc checks were also different. Perhaps I
|
||||
* made a mistake in one of the two. Need to recheck
|
||||
* which is correct or at least see what is going
|
||||
* on... (AIA)
|
||||
*/
|
||||
rc = ntfs_collate_names(name, name_len, al_name,
|
||||
rc = ntfs_names_collate(name, name_len, al_name,
|
||||
al_name_len, 1, CASE_SENSITIVE,
|
||||
vol->upcase, vol->upcase_len);
|
||||
if (rc == -1)
|
||||
|
@ -1542,7 +1542,7 @@ static int ntfs_find_external_attr(ATTR_TYPES type, const uchar_t *name,
|
|||
sle64_to_cpu(lowest_vcn) &&
|
||||
next_al_entry->type == al_entry->type &&
|
||||
next_al_entry->name_length == al_name_len &&
|
||||
ntfs_are_names_equal((uchar_t*)((char*)
|
||||
ntfs_names_are_equal((uchar_t*)((char*)
|
||||
next_al_entry +
|
||||
next_al_entry->name_offset),
|
||||
next_al_entry->name_length,
|
||||
|
@ -1561,7 +1561,7 @@ is_enumeration:
|
|||
} else { /* Mft references do not match. */
|
||||
/* If there is a mapped extent inode unmap it first. */
|
||||
if (ni != base_ni)
|
||||
ntfs_close_inode(ni);
|
||||
ntfs_inode_close(ni);
|
||||
/* Do we want the base record back? */
|
||||
if (MREF_LE(al_entry->mft_reference) ==
|
||||
base_ni->mft_no) {
|
||||
|
@ -1569,7 +1569,7 @@ is_enumeration:
|
|||
ctx->mrec = ctx->base_mrec;
|
||||
} else {
|
||||
/* We want an extent record. */
|
||||
ni = ntfs_open_extent_inode(base_ni,
|
||||
ni = ntfs_extent_inode_open(base_ni,
|
||||
al_entry->mft_reference);
|
||||
if (!ni) {
|
||||
Dperror("Failed to map extent inode");
|
||||
|
@ -1587,14 +1587,14 @@ is_enumeration:
|
|||
* current al_entry.
|
||||
*/
|
||||
/*
|
||||
* We could call into ntfs_find_attr() to find the right
|
||||
* We could call into ntfs_attr_find() to find the right
|
||||
* attribute in this mft record but this would be less
|
||||
* efficient and not quite accurate as ntfs_find_attr() ignores
|
||||
* efficient and not quite accurate as ntfs_attr_find() ignores
|
||||
* the attribute instance numbers for example which become
|
||||
* important when one plays with attribute lists. Also, because
|
||||
* a proper match has been found in the attribute list entry
|
||||
* above, the comparison can now be optimized. So it is worth
|
||||
* re-implementing a simplified ntfs_find_attr() here.
|
||||
* re-implementing a simplified ntfs_attr_find() here.
|
||||
*/
|
||||
a = ctx->attr;
|
||||
/*
|
||||
|
@ -1618,7 +1618,7 @@ do_next_attr_loop:
|
|||
*/
|
||||
if (al_entry->type != a->type)
|
||||
break;
|
||||
if (!ntfs_are_names_equal((uchar_t*)((char*)a +
|
||||
if (!ntfs_names_are_equal((uchar_t*)((char*)a +
|
||||
le16_to_cpu(a->name_offset)),
|
||||
a->name_length, al_name,
|
||||
al_name_len, CASE_SENSITIVE,
|
||||
|
@ -1643,7 +1643,7 @@ do_next_attr:
|
|||
}
|
||||
if (ni != base_ni) {
|
||||
if (ni)
|
||||
ntfs_close_inode(ni);
|
||||
ntfs_inode_close(ni);
|
||||
ctx->ntfs_ino = base_ni;
|
||||
ctx->mrec = ctx->base_mrec;
|
||||
ctx->attr = ctx->base_attr;
|
||||
|
@ -1661,20 +1661,20 @@ not_found:
|
|||
*
|
||||
* FIXME: Do we really want to do this here? Think about it... (AIA)
|
||||
*/
|
||||
ntfs_reinit_attr_search_ctx(ctx);
|
||||
ntfs_attr_reinit_search_ctx(ctx);
|
||||
/*
|
||||
* If we were enumerating and reached the end, we can't just use !@type
|
||||
* because that would return the first attribute instead of the last
|
||||
* one. Thus we just change @type to AT_END which causes
|
||||
* ntfs_find_attr() to seek to the end.
|
||||
* ntfs_attr_find() to seek to the end.
|
||||
*/
|
||||
if (!type)
|
||||
type = AT_END;
|
||||
return ntfs_find_attr(type, name, name_len, ic, val, val_len, ctx);
|
||||
return ntfs_attr_find(type, name, name_len, ic, val, val_len, ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_lookup_attr - find an attribute in an ntfs inode
|
||||
* ntfs_attr_lookup - find an attribute in an ntfs inode
|
||||
* @type: attribute type to find
|
||||
* @name: attribute name to find (optional, i.e. NULL means don't care)
|
||||
* @name_len: attribute name length (only needed if @name present)
|
||||
|
@ -1686,30 +1686,30 @@ not_found:
|
|||
*
|
||||
* Find an attribute in an ntfs inode. On first search @ctx->ntfs_ino must
|
||||
* be the base mft record and @ctx must have been obtained from a call to
|
||||
* ntfs_get_attr_search_ctx().
|
||||
* ntfs_attr_get_search_ctx().
|
||||
*
|
||||
* This function transparently handles attribute lists and @ctx is used to
|
||||
* continue searches where they were left off at.
|
||||
*
|
||||
* If @type is zero (i.e. AT_UNUSED), return the first found attribute, i.e.
|
||||
* one can enumerate all attributes by setting @type to zero and then calling
|
||||
* ntfs_lookup_attr() repeatedly until it returns -1 with errno set to ENOENT
|
||||
* ntfs_attr_lookup() repeatedly until it returns -1 with errno set to ENOENT
|
||||
* to indicate that there are no more entries. During the enumeration, each
|
||||
* successful call of ntfs_lookup_attr() will return the next attribute, with
|
||||
* successful call of ntfs_attr_lookup() will return the next attribute, with
|
||||
* the current attribute being described by the search context @ctx.
|
||||
*
|
||||
* If @type is AT_END, seek to the end of the attribute and return -1 with
|
||||
* errno set to ENOENT. AT_END is not a valid attribute, its length is zero for
|
||||
* example, thus it is safer to return error instead of success in this case.
|
||||
* It should never ne needed to do this, but we implement the functionality
|
||||
* because it allows for simpler code inside ntfs_find_external_attr().
|
||||
* because it allows for simpler code inside ntfs_external_attr_find().
|
||||
*
|
||||
* If @name is AT_UNNAMED search for an unnamed attribute. If @name is present
|
||||
* but not AT_UNNAMED search for a named attribute matching @name. Otherwise,
|
||||
* match both named and unnamed attributes.
|
||||
*
|
||||
* After finishing with the attribute/mft record you need to call
|
||||
* ntfs_put_attr_search_ctx() to cleanup the search context (unmapping any
|
||||
* ntfs_attr_put_search_ctx() to cleanup the search context (unmapping any
|
||||
* mapped extent inodes, etc).
|
||||
*
|
||||
* Return 0 if the search was successful and -1 if not, with errno set to the
|
||||
|
@ -1730,7 +1730,7 @@ not_found:
|
|||
* EIO I/O error or corrupt data structures found.
|
||||
* ENOMEM Not enough memory to allocate necessary buffers.
|
||||
*/
|
||||
int ntfs_lookup_attr(const ATTR_TYPES type, const uchar_t *name,
|
||||
int ntfs_attr_lookup(const ATTR_TYPES type, const uchar_t *name,
|
||||
const u32 name_len, const IGNORE_CASE_BOOL ic,
|
||||
const VCN lowest_vcn, const u8 *val, const u32 val_len,
|
||||
ntfs_attr_search_ctx *ctx)
|
||||
|
@ -1746,23 +1746,23 @@ int ntfs_lookup_attr(const ATTR_TYPES type, const uchar_t *name,
|
|||
else
|
||||
base_ni = ctx->ntfs_ino;
|
||||
if (!base_ni || !NInoAttrList(base_ni) || type == AT_ATTRIBUTE_LIST)
|
||||
return ntfs_find_attr(type, name, name_len, ic, val, val_len,
|
||||
return ntfs_attr_find(type, name, name_len, ic, val, val_len,
|
||||
ctx);
|
||||
return ntfs_find_external_attr(type, name, name_len, ic, lowest_vcn,
|
||||
return ntfs_external_attr_find(type, name, name_len, ic, lowest_vcn,
|
||||
val, val_len, ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal:
|
||||
*
|
||||
* ntfs_init_attr_search_ctx - initialize an attribute search context
|
||||
* ntfs_attr_init_search_ctx - initialize an attribute search context
|
||||
* @ctx: attribute search context to initialize
|
||||
* @ni: ntfs inode with which to initialize the search context
|
||||
* @mrec: mft record with which to initialize the search context
|
||||
*
|
||||
* Initialize the attribute search context @ctx with @ni and @mrec.
|
||||
*/
|
||||
static __inline__ void ntfs_init_attr_search_ctx(ntfs_attr_search_ctx *ctx,
|
||||
static __inline__ void ntfs_attr_init_search_ctx(ntfs_attr_search_ctx *ctx,
|
||||
ntfs_inode *ni, MFT_RECORD *mrec)
|
||||
{
|
||||
if (ni && !mrec)
|
||||
|
@ -1780,7 +1780,7 @@ static __inline__ void ntfs_init_attr_search_ctx(ntfs_attr_search_ctx *ctx,
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_reinit_attr_search_ctx - reinitialize an attribute search context
|
||||
* ntfs_attr_reinit_search_ctx - reinitialize an attribute search context
|
||||
* @ctx: attribute search context to reinitialize
|
||||
*
|
||||
* Reinitialize the attribute search context @ctx, unmapping an associated
|
||||
|
@ -1789,7 +1789,7 @@ static __inline__ void ntfs_init_attr_search_ctx(ntfs_attr_search_ctx *ctx,
|
|||
* This is used when a search for a new attribute is being started to reset
|
||||
* the search context to the beginning.
|
||||
*/
|
||||
void ntfs_reinit_attr_search_ctx(ntfs_attr_search_ctx *ctx)
|
||||
void ntfs_attr_reinit_search_ctx(ntfs_attr_search_ctx *ctx)
|
||||
{
|
||||
if (!ctx->base_ntfs_ino) {
|
||||
/* No attribute list. */
|
||||
|
@ -1800,13 +1800,13 @@ void ntfs_reinit_attr_search_ctx(ntfs_attr_search_ctx *ctx)
|
|||
return;
|
||||
} /* Attribute list. */
|
||||
if (ctx->ntfs_ino != ctx->base_ntfs_ino)
|
||||
ntfs_close_inode(ctx->ntfs_ino);
|
||||
ntfs_init_attr_search_ctx(ctx, ctx->base_ntfs_ino, ctx->base_mrec);
|
||||
ntfs_inode_close(ctx->ntfs_ino);
|
||||
ntfs_attr_init_search_ctx(ctx, ctx->base_ntfs_ino, ctx->base_mrec);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_get_attr_search_ctx - allocate/initialize a new attribute search context
|
||||
* ntfs_attr_get_search_ctx - allocate/initialize a new attribute search context
|
||||
* @ctx: address of pointer in which to return the new search context
|
||||
* @ni: ntfs inode with which to initialize the search context
|
||||
* @mrec: mft record with which to initialize the search context
|
||||
|
@ -1824,25 +1824,25 @@ void ntfs_reinit_attr_search_ctx(ntfs_attr_search_ctx *ctx)
|
|||
* If both @ni and @mrec are specified, the mft record is taken from @mrec and
|
||||
* the value of @ni->mrec is ignored.
|
||||
*/
|
||||
ntfs_attr_search_ctx *ntfs_get_attr_search_ctx(ntfs_inode *ni, MFT_RECORD *mrec)
|
||||
ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni, MFT_RECORD *mrec)
|
||||
{
|
||||
ntfs_attr_search_ctx *ctx = malloc(sizeof(ntfs_attr_search_ctx));
|
||||
if (ctx)
|
||||
ntfs_init_attr_search_ctx(ctx, ni, mrec);
|
||||
ntfs_attr_init_search_ctx(ctx, ni, mrec);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_put_attr_search_ctx - release an attribute search context
|
||||
* ntfs_attr_put_search_ctx - release an attribute search context
|
||||
* @ctx: attribute search context to free
|
||||
*
|
||||
* Release the attribute search context @ctx, unmapping an associated extent
|
||||
* mft record if present.
|
||||
*/
|
||||
void ntfs_put_attr_search_ctx(ntfs_attr_search_ctx *ctx)
|
||||
void ntfs_attr_put_search_ctx(ntfs_attr_search_ctx *ctx)
|
||||
{
|
||||
if (ctx->base_ntfs_ino && ctx->ntfs_ino != ctx->base_ntfs_ino)
|
||||
ntfs_close_inode(ctx->ntfs_ino);
|
||||
ntfs_inode_close(ctx->ntfs_ino);
|
||||
free(ctx);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ typedef struct {
|
|||
u8 *alist_old_base;
|
||||
} attr_search_context;
|
||||
|
||||
BOOL find_attr(const ntfs_volume *vol, const ATTR_TYPES type,
|
||||
BOOL attr_find(const ntfs_volume *vol, const ATTR_TYPES type,
|
||||
const wchar_t *name, const u32 name_len,
|
||||
const IGNORE_CASE_BOOL ic, const u8 *val, const u32 val_len,
|
||||
ntfs_attr_search_ctx *ctx)
|
||||
|
@ -56,7 +56,7 @@ BOOL find_attr(const ntfs_volume *vol, const ATTR_TYPES type,
|
|||
|
||||
#ifdef DEBUG
|
||||
if (!vol || !ctx || !ctx->mrec || !ctx->attr) {
|
||||
printf(stderr, "find_attr() received NULL pointer!\n");
|
||||
printf(stderr, "attr_find() received NULL pointer!\n");
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
@ -102,11 +102,11 @@ found_it:
|
|||
goto do_next;
|
||||
goto not_found;
|
||||
}
|
||||
if (ntfs_are_names_equal(name, name_len,
|
||||
if (ntfs_names_are_equal(name, name_len,
|
||||
(wchar_t*)((char*)a + le16_to_cpu(a->name_offset)),
|
||||
a->name_length, ic, vol->upcase, vol->upcase_len))
|
||||
goto found_it;
|
||||
{ register int rc = ntfs_collate_names(vol->upcase,
|
||||
{ register int rc = ntfs_names_collate(vol->upcase,
|
||||
vol->upcase_len, name, name_len,
|
||||
(wchar_t*)((char*)a + le16_to_cpu(a->name_offset)),
|
||||
a->name_length, IGNORE_CASE, 1);
|
||||
|
@ -120,7 +120,7 @@ found_it:
|
|||
}
|
||||
/* If case sensitive collation of names doesn't collate @name before
|
||||
a->name, we continue the search. Otherwise we haven't found it. */
|
||||
if (ntfs_collate_names(vol->upcase, vol->upcase_len, name, name_len,
|
||||
if (ntfs_names_collate(vol->upcase, vol->upcase_len, name, name_len,
|
||||
(wchar_t*)((char*)a + le16_to_cpu(a->name_offset)),
|
||||
a->name_length, CASE_SENSITIVE, 1) != -1)
|
||||
goto do_next;
|
||||
|
@ -133,7 +133,7 @@ file_corrupt:
|
|||
goto not_found;
|
||||
}
|
||||
|
||||
BOOL lookup_external_attr(const ntfs_volume *vol, const MFT_REFERENCE mref,
|
||||
BOOL external_attr_lookup(const ntfs_volume *vol, const MFT_REFERENCE mref,
|
||||
const ATTR_TYPES type, const wchar_t *name,
|
||||
const u32 name_len, const IGNORE_CASE_BOOL ic,
|
||||
const s64 lowest_vcn, const u8 *val,
|
||||
|
@ -186,7 +186,7 @@ already_have_the_base_and_is_first:
|
|||
if (ntfs_file_record_read(vol, mref, &ctx->mrec, &ctx->attr) < 0)
|
||||
return FALSE;
|
||||
ctx->base = ctx->mrec;
|
||||
find_attr(vol, type, name, name_len, ic, val, val_len, ctx);
|
||||
attr_find(vol, type, name, name_len, ic, val, val_len, ctx);
|
||||
return FALSE;
|
||||
al_pos_below_alist_val_end:
|
||||
if (al_pos < ctx->alist_val)
|
||||
|
@ -212,15 +212,15 @@ compare_names:
|
|||
else
|
||||
rc = FALSE;
|
||||
} else /* IGNORE_CASE */
|
||||
rc = ntfs_are_names_equal(al_name, al_name_len, name, name_len,
|
||||
rc = ntfs_names_are_equal(al_name, al_name_len, name, name_len,
|
||||
ic, vol->upcase, vol->upcase_len);
|
||||
if (rc)
|
||||
goto compare_lowest_vcn;
|
||||
rc = ntfs_collate_names(vol->upcase, vol->upcase_len, name, name_len,
|
||||
rc = ntfs_names_collate(vol->upcase, vol->upcase_len, name, name_len,
|
||||
al_name, al_name_len, IGNORE_CASE, 1);
|
||||
if (rc == -1)
|
||||
goto name_collates_before_al_name;
|
||||
if (!rc && ntfs_collate_names(vol->upcase, vol->upcase_len, name,
|
||||
if (!rc && ntfs_names_collate(vol->upcase, vol->upcase_len, name,
|
||||
name_len, al_name, al_name_len,
|
||||
IGNORE_CASE, 0) == -1)
|
||||
goto name_collates_before_al_name;
|
||||
|
@ -313,7 +313,7 @@ loc_5217c:
|
|||
if (ntfs_file_record_read(vol, mref, &mrec, &ctx->attr) < 0)
|
||||
return FALSE;
|
||||
ctx->base = mrec;
|
||||
find_attr(vol, type, name, name_len, ic, val, val_len, ctx);
|
||||
attr_find(vol, type, name, name_len, ic, val, val_len, ctx);
|
||||
return FALSE;
|
||||
file_corrupt:
|
||||
#ifdef DEBUG
|
||||
|
@ -322,7 +322,7 @@ file_corrupt:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL lookup_attr(const ntfs_volume *vol, const MFT_REFERENCE *mref,
|
||||
BOOL attr_lookup(const ntfs_volume *vol, const MFT_REFERENCE *mref,
|
||||
const ATTR_TYPES type, const wchar_t *name,
|
||||
const u32 name_len, const IGNORE_CASE_BOOL ic,
|
||||
const s64 lowest_vcn, const u8 *val, const u32 val_len,
|
||||
|
@ -366,7 +366,7 @@ no_attr_list:
|
|||
a->type == AT_STANDARD_INFORMATION)
|
||||
goto found_it;
|
||||
call_find_attr:
|
||||
return find_attr(vol, type, name, name_len, ic, val, val_len, ctx);
|
||||
return attr_find(vol, type, name, name_len, ic, val, val_len, ctx);
|
||||
found_it:
|
||||
ctx->attr = a;
|
||||
return TRUE;
|
||||
|
@ -405,7 +405,7 @@ search_attr_list:
|
|||
* "a" contains the attribute list attribute at this stage.
|
||||
*/
|
||||
ctx->alist_attr = a;
|
||||
len = get_attribute_value_length(a);
|
||||
len = ntfs_get_attribute_value_length(a);
|
||||
#ifdef DEBUG
|
||||
if (len > 0x40000LL) {
|
||||
printf(stderr, "lookup_attr() found corrupt attribute list.\n");
|
||||
|
@ -420,7 +420,7 @@ search_attr_list:
|
|||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
if (get_attribute_value(vol, ctx->mrec, a, ctx->alist_val) !=
|
||||
if (ntfs_get_attribute_value(vol, ctx->mrec, a, ctx->alist_val) !=
|
||||
ctx->alist_val_len) {
|
||||
#ifdef DEBUG
|
||||
printf(stderr, "lookup_attr() failed to read attribute list "
|
||||
|
@ -438,11 +438,11 @@ search_attr_list:
|
|||
ctx->base = NULL;
|
||||
}
|
||||
lookup_external:
|
||||
return lookup_external_attr(vol, mref, type, name, name_len, ic,
|
||||
return external_attr_lookup(vol, mref, type, name, name_len, ic,
|
||||
lowest_vcn, val, val_len, ctx);
|
||||
file_corrupt:
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "lookup_attr() encountered corrupt file record.\n");
|
||||
fprintf(stderr, "attr_lookup() encountered corrupt file record.\n");
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* bootsect.c - Boot sector handling code. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000,2001 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -28,7 +28,7 @@
|
|||
#include "debug.h"
|
||||
|
||||
/**
|
||||
* is_boot_sector_ntfs - check if a buffer contains a valid ntfs boot sector
|
||||
* ntfs_boot_sector_is_ntfs - check if buffer contains a valid ntfs boot sector
|
||||
* @b: buffer containing putative boot sector to analyze
|
||||
* @silent: if zero, output progress messages to stdout
|
||||
*
|
||||
|
@ -41,7 +41,7 @@
|
|||
*
|
||||
* Return TRUE if @b contains a valid ntfs boot sector and FALSE if not.
|
||||
*/
|
||||
BOOL is_boot_sector_ntfs(const NTFS_BOOT_SECTOR *b, const BOOL silent)
|
||||
BOOL ntfs_boot_sector_is_ntfs(const NTFS_BOOT_SECTOR *b, const BOOL silent)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
|
@ -166,7 +166,7 @@ not_ntfs:
|
|||
}
|
||||
|
||||
/**
|
||||
* parse_ntfs_boot_sector - setup an ntfs volume from an ntfs boot sector
|
||||
* ntfs_boot_sector_parse - setup an ntfs volume from an ntfs boot sector
|
||||
* @vol: ntfs_volume to setup
|
||||
* @bs: buffer containing ntfs boot sector to parse
|
||||
*
|
||||
|
@ -175,7 +175,7 @@ not_ntfs:
|
|||
*
|
||||
* Return 0 on success or -1 on error with errno set to the error code EINVAL.
|
||||
*/
|
||||
int parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *bs)
|
||||
int ntfs_boot_sector_parse(ntfs_volume *vol, const NTFS_BOOT_SECTOR *bs)
|
||||
{
|
||||
u8 sectors_per_cluster;
|
||||
s8 c;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
/*
|
||||
* compat.c - Tweaks for Windows compatability
|
||||
*
|
||||
* Copyright (c) 2002 Richard Russon.
|
||||
* Copyright (c) 2002 Richard Russon
|
||||
* Copyright (c) 2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -23,7 +24,9 @@
|
|||
|
||||
#include "compat.h"
|
||||
|
||||
int ffs (int x)
|
||||
// TODO: Add check for FFS in the configure script... (AIA)
|
||||
#ifndef HAVE_FFS
|
||||
int ffs(int x)
|
||||
{
|
||||
int r = 1;
|
||||
|
||||
|
@ -51,6 +54,7 @@ int ffs (int x)
|
|||
}
|
||||
return r;
|
||||
}
|
||||
#endif /* HAVE_FFS */
|
||||
|
||||
#endif /* WINDOWS */
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* debug.c - Debugging output functions. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -23,9 +23,9 @@
|
|||
|
||||
#ifdef DEBUG
|
||||
/**
|
||||
* ntfs_debug_dump_runlist - Dump a runlist.
|
||||
* ntfs_debug_runlist_dump - Dump a runlist.
|
||||
*/
|
||||
void ntfs_debug_dump_runlist(const runlist_element *rl)
|
||||
void ntfs_debug_runlist_dump(const runlist_element *rl)
|
||||
{
|
||||
int i = 0;
|
||||
const char *lcn_str[5] = { "LCN_HOLE ", "LCN_RL_NOT_MAPPED",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* dir.c - Directory handling code. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -38,13 +38,13 @@ uchar_t I30[5] = { const_cpu_to_le16('$'), const_cpu_to_le16('I'),
|
|||
const_cpu_to_le16('\0') };
|
||||
|
||||
/**
|
||||
* ntfs_lookup_inode_by_name - find an inode in a directory given its name
|
||||
* ntfs_inode_lookup_by_name - find an inode in a directory given its name
|
||||
* @dir_ni: ntfs inode of the directory in which to search for the name
|
||||
* @uname: Unicode name for which to search in the directory
|
||||
* @uname_len: length of the name @uname in Unicode characters
|
||||
*
|
||||
* Look for an inode with name @uname in the directory with inode @dir_ni.
|
||||
* ntfs_lookup_inode_by_name() walks the contents of the directory looking for
|
||||
* ntfs_inode_lookup_by_name() walks the contents of the directory looking for
|
||||
* the Unicode name. If the name is found in the directory, the corresponding
|
||||
* inode number (>= 0) is returned as a mft reference in cpu format, i.e. it
|
||||
* is a 64-bit number containing the sequence number.
|
||||
|
@ -62,7 +62,7 @@ uchar_t I30[5] = { const_cpu_to_le16('$'), const_cpu_to_le16('I'),
|
|||
* If the volume is mounted with the case sensitive flag set, then we only
|
||||
* allow exact matches.
|
||||
*/
|
||||
u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const uchar_t *uname,
|
||||
u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni, const uchar_t *uname,
|
||||
const int uname_len)
|
||||
{
|
||||
VCN vcn;
|
||||
|
@ -84,12 +84,12 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const uchar_t *uname,
|
|||
return -1;
|
||||
}
|
||||
|
||||
ctx = ntfs_get_attr_search_ctx(dir_ni, NULL);
|
||||
ctx = ntfs_attr_get_search_ctx(dir_ni, NULL);
|
||||
if (!ctx)
|
||||
return -1;
|
||||
|
||||
/* Find the index root attribute in the mft record. */
|
||||
if (!ntfs_lookup_attr(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL,
|
||||
if (!ntfs_attr_lookup(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL,
|
||||
0, ctx)) {
|
||||
Dprintf("Index root attribute missing in directory inode "
|
||||
"0x%Lx: %s\n",
|
||||
|
@ -134,7 +134,7 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const uchar_t *uname,
|
|||
* consistency checking). We convert it to cpu format before
|
||||
* returning.
|
||||
*/
|
||||
if (ntfs_are_names_equal(uname, uname_len,
|
||||
if (ntfs_names_are_equal(uname, uname_len,
|
||||
(uchar_t*)&ie->key.file_name.file_name,
|
||||
ie->key.file_name.file_name_length,
|
||||
CASE_SENSITIVE, vol->upcase, vol->upcase_len)) {
|
||||
|
@ -144,7 +144,7 @@ found_it:
|
|||
* about having matched imperfectly before.
|
||||
*/
|
||||
mref = le64_to_cpu(ie->indexed_file);
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return mref;
|
||||
}
|
||||
/*
|
||||
|
@ -155,7 +155,7 @@ found_it:
|
|||
*/
|
||||
if (!NVolCaseSensitive(vol) &&
|
||||
ie->key.file_name.file_name_type &&
|
||||
ntfs_are_names_equal(uname, uname_len,
|
||||
ntfs_names_are_equal(uname, uname_len,
|
||||
(uchar_t*)&ie->key.file_name.file_name,
|
||||
ie->key.file_name.file_name_length,
|
||||
IGNORE_CASE, vol->upcase, vol->upcase_len)) {
|
||||
|
@ -175,7 +175,7 @@ found_it:
|
|||
* Not a perfect match, need to do full blown collation so we
|
||||
* know which way in the B+tree we have to go.
|
||||
*/
|
||||
rc = ntfs_collate_names(uname, uname_len,
|
||||
rc = ntfs_names_collate(uname, uname_len,
|
||||
(uchar_t*)&ie->key.file_name.file_name,
|
||||
ie->key.file_name.file_name_length, 1,
|
||||
IGNORE_CASE, vol->upcase, vol->upcase_len);
|
||||
|
@ -194,7 +194,7 @@ found_it:
|
|||
* case sensitive comparison, which is required for proper
|
||||
* collation.
|
||||
*/
|
||||
rc = ntfs_collate_names(uname, uname_len,
|
||||
rc = ntfs_names_collate(uname, uname_len,
|
||||
(uchar_t*)&ie->key.file_name.file_name,
|
||||
ie->key.file_name.file_name_length, 1,
|
||||
CASE_SENSITIVE, vol->upcase, vol->upcase_len);
|
||||
|
@ -216,7 +216,7 @@ found_it:
|
|||
* cached in mref in which case return mref.
|
||||
*/
|
||||
if (!(ie->flags & INDEX_ENTRY_NODE)) {
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
if (mref)
|
||||
return mref;
|
||||
Dputs("Entry not found.");
|
||||
|
@ -325,7 +325,7 @@ descend_into_child_node:
|
|||
* consistency checking). We convert it to cpu format before
|
||||
* returning.
|
||||
*/
|
||||
if (ntfs_are_names_equal(uname, uname_len,
|
||||
if (ntfs_names_are_equal(uname, uname_len,
|
||||
(uchar_t*)&ie->key.file_name.file_name,
|
||||
ie->key.file_name.file_name_length,
|
||||
CASE_SENSITIVE, vol->upcase, vol->upcase_len)) {
|
||||
|
@ -336,7 +336,7 @@ found_it2:
|
|||
*/
|
||||
mref = le64_to_cpu(ie->indexed_file);
|
||||
ntfs_attr_close(ia_na);
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return mref;
|
||||
}
|
||||
/*
|
||||
|
@ -347,7 +347,7 @@ found_it2:
|
|||
*/
|
||||
if (!NVolCaseSensitive(vol) &&
|
||||
ie->key.file_name.file_name_type &&
|
||||
ntfs_are_names_equal(uname, uname_len,
|
||||
ntfs_names_are_equal(uname, uname_len,
|
||||
(uchar_t*)&ie->key.file_name.file_name,
|
||||
ie->key.file_name.file_name_length,
|
||||
IGNORE_CASE, vol->upcase, vol->upcase_len)) {
|
||||
|
@ -367,7 +367,7 @@ found_it2:
|
|||
* Not a perfect match, need to do full blown collation so we
|
||||
* know which way in the B+tree we have to go.
|
||||
*/
|
||||
rc = ntfs_collate_names(uname, uname_len,
|
||||
rc = ntfs_names_collate(uname, uname_len,
|
||||
(uchar_t*)&ie->key.file_name.file_name,
|
||||
ie->key.file_name.file_name_length, 1,
|
||||
IGNORE_CASE, vol->upcase, vol->upcase_len);
|
||||
|
@ -386,7 +386,7 @@ found_it2:
|
|||
* case sensitive comparison, which is required for proper
|
||||
* collation.
|
||||
*/
|
||||
rc = ntfs_collate_names(uname, uname_len,
|
||||
rc = ntfs_names_collate(uname, uname_len,
|
||||
(uchar_t*)&ie->key.file_name.file_name,
|
||||
ie->key.file_name.file_name_length, 1,
|
||||
CASE_SENSITIVE, vol->upcase, vol->upcase_len);
|
||||
|
@ -423,7 +423,7 @@ found_it2:
|
|||
goto close_err_out;
|
||||
}
|
||||
ntfs_attr_close(ia_na);
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
/*
|
||||
* No child node present, return error code ENOENT, unless we have got
|
||||
* the mft reference of a matching name cached in mref in which case
|
||||
|
@ -438,7 +438,7 @@ put_err_out:
|
|||
eo = EIO;
|
||||
Dputs("Corrupt directory. Aborting lookup.");
|
||||
eo_put_err_out:
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
errno = eo;
|
||||
return -1;
|
||||
close_err_out:
|
||||
|
@ -514,7 +514,7 @@ static inline int ntfs_filldir(ntfs_inode *dir_ni, s64 *pos, u8 ivcn_bits,
|
|||
/**
|
||||
* Internal:
|
||||
*
|
||||
* ntfs_get_parent_mft_ref - find mft reference of parent directory of an inode
|
||||
* ntfs_mft_get_parent_ref - find mft reference of parent directory of an inode
|
||||
* @ni: ntfs inode whose parent directory to find
|
||||
*
|
||||
* Find the parent directory of the ntfs inode @ni. To do this, find the first
|
||||
|
@ -531,7 +531,7 @@ static inline int ntfs_filldir(ntfs_inode *dir_ni, s64 *pos, u8 ivcn_bits,
|
|||
* Return the mft reference of the parent directory on success or -1 on error
|
||||
* with errno set to the error code.
|
||||
*/
|
||||
static MFT_REF ntfs_get_parent_mft_ref(ntfs_inode *ni)
|
||||
static MFT_REF ntfs_mft_get_parent_ref(ntfs_inode *ni)
|
||||
{
|
||||
MFT_REF mref;
|
||||
ntfs_attr_search_ctx *ctx;
|
||||
|
@ -543,10 +543,10 @@ static MFT_REF ntfs_get_parent_mft_ref(ntfs_inode *ni)
|
|||
return -1;
|
||||
}
|
||||
|
||||
ctx = ntfs_get_attr_search_ctx(ni, NULL);
|
||||
ctx = ntfs_attr_get_search_ctx(ni, NULL);
|
||||
if (!ctx)
|
||||
return -1;
|
||||
if (ntfs_lookup_attr(AT_FILE_NAME, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
if (ntfs_attr_lookup(AT_FILE_NAME, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
Dprintf("No file name found in inode 0x%Lx. Corrupt inode.\n",
|
||||
(unsigned long long)ni->mft_no);
|
||||
goto err_out;
|
||||
|
@ -565,13 +565,13 @@ static MFT_REF ntfs_get_parent_mft_ref(ntfs_inode *ni)
|
|||
goto io_err_out;
|
||||
}
|
||||
mref = le64_to_cpu(fn->parent_directory);
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return mref;
|
||||
io_err_out:
|
||||
errno = EIO;
|
||||
err_out:
|
||||
eo = errno;
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
errno = eo;
|
||||
return -1;
|
||||
}
|
||||
|
@ -651,7 +651,7 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos,
|
|||
if (*pos == 1) {
|
||||
MFT_REF parent_mref;
|
||||
|
||||
parent_mref = ntfs_get_parent_mft_ref(dir_ni);
|
||||
parent_mref = ntfs_mft_get_parent_ref(dir_ni);
|
||||
if (parent_mref == -1) {
|
||||
Dprintf("Parent directory not found: %s\n", errno);
|
||||
goto dir_err_out;
|
||||
|
@ -664,14 +664,14 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos,
|
|||
++*pos;
|
||||
}
|
||||
|
||||
ctx = ntfs_get_attr_search_ctx(dir_ni, NULL);
|
||||
ctx = ntfs_attr_get_search_ctx(dir_ni, NULL);
|
||||
if (!ctx)
|
||||
goto err_out;
|
||||
|
||||
/* Get the offset into the index root attribute. */
|
||||
ir_pos = (int)*pos;
|
||||
/* Find the index root attribute in the mft record. */
|
||||
if (!ntfs_lookup_attr(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL,
|
||||
if (!ntfs_attr_lookup(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL,
|
||||
0, ctx)) {
|
||||
Dprintf("Index root attribute missing in directory inode "
|
||||
"0x%Lx.\n", (unsigned long long)dir_ni->mft_no);
|
||||
|
@ -699,7 +699,7 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos,
|
|||
|
||||
/* Are we jumping straight into the index allocation attribute? */
|
||||
if (*pos >= vol->mft_record_size) {
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
ctx = NULL;
|
||||
goto skip_index_root;
|
||||
}
|
||||
|
@ -734,12 +734,12 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos,
|
|||
rc = ntfs_filldir(dir_ni, pos, index_vcn_size_bits,
|
||||
INDEX_TYPE_ROOT, ir, ie, dirent, filldir);
|
||||
if (rc) {
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
ctx = NULL;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
ctx = NULL;
|
||||
|
||||
/* If there is no index allocation attribute we are finished. */
|
||||
|
@ -913,7 +913,7 @@ err_out:
|
|||
eo = errno;
|
||||
Dprintf("%s() failed.\n", __FUNCTION__);
|
||||
if (ctx)
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
if (bmp_na)
|
||||
ntfs_attr_close(bmp_na);
|
||||
ntfs_attr_close(ia_na);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* disk_io.c - Disk io functions. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -191,7 +191,7 @@ s64 ntfs_mst_pread(const int fd, const s64 pos, s64 count,
|
|||
*/
|
||||
count = br / bksize;
|
||||
for (i = 0; i < count; ++i)
|
||||
ntfs_post_read_mst_fixup((NTFS_RECORD*)
|
||||
ntfs_mst_post_read_fixup((NTFS_RECORD*)
|
||||
((u8*)b + i * bksize), bksize);
|
||||
/* Finally, return the number of complete blocks read. */
|
||||
return count;
|
||||
|
@ -242,7 +242,7 @@ s64 ntfs_mst_pwrite(const int fd, const s64 pos, s64 count,
|
|||
for (i = 0; i < count; ++i) {
|
||||
int err;
|
||||
|
||||
err = ntfs_pre_write_mst_fixup((NTFS_RECORD*)
|
||||
err = ntfs_mst_pre_write_fixup((NTFS_RECORD*)
|
||||
((u8*)b + i * bksize), bksize);
|
||||
if (err < 0) {
|
||||
/* Abort write at this position. */
|
||||
|
@ -256,7 +256,7 @@ s64 ntfs_mst_pwrite(const int fd, const s64 pos, s64 count,
|
|||
written = ntfs_pwrite(fd, pos, count * bksize, b);
|
||||
/* Quickly deprotect the data again. */
|
||||
for (i = 0; i < count; ++i)
|
||||
ntfs_post_write_mst_fixup((NTFS_RECORD*)((u8*)b + i * bksize));
|
||||
ntfs_mst_post_write_fixup((NTFS_RECORD*)((u8*)b + i * bksize));
|
||||
if (written <= 0)
|
||||
return written;
|
||||
/* Finally, return the number of complete blocks written. */
|
||||
|
@ -264,7 +264,7 @@ s64 ntfs_mst_pwrite(const int fd, const s64 pos, s64 count,
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_read_clusters - read ntfs clusters
|
||||
* ntfs_clusters_read - read ntfs clusters
|
||||
* @vol: volume to read from
|
||||
* @lcn: starting logical cluster number
|
||||
* @count: number of clusters to read
|
||||
|
@ -274,7 +274,7 @@ s64 ntfs_mst_pwrite(const int fd, const s64 pos, s64 count,
|
|||
* volume @vol into buffer @b. Return number of clusters read or -1 on error,
|
||||
* with errno set to the error code.
|
||||
*/
|
||||
s64 ntfs_read_clusters(const ntfs_volume *vol, const s64 lcn,
|
||||
s64 ntfs_clusters_read(const ntfs_volume *vol, const s64 lcn,
|
||||
const s64 count, const void *b)
|
||||
{
|
||||
s64 br;
|
||||
|
@ -297,7 +297,7 @@ s64 ntfs_read_clusters(const ntfs_volume *vol, const s64 lcn,
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_write_clusters - write ntfs clusters
|
||||
* ntfs_clusters_write - write ntfs clusters
|
||||
* @vol: volume to write to
|
||||
* @lcn: starting logical cluster number
|
||||
* @count: number of clusters to write
|
||||
|
@ -307,7 +307,7 @@ s64 ntfs_read_clusters(const ntfs_volume *vol, const s64 lcn,
|
|||
* buffer @b to volume @vol. Return the number of clusters written or -1 on
|
||||
* error, with errno set to the error code.
|
||||
*/
|
||||
s64 ntfs_write_clusters(const ntfs_volume *vol, const s64 lcn,
|
||||
s64 ntfs_clusters_write(const ntfs_volume *vol, const s64 lcn,
|
||||
const s64 count, const void *b)
|
||||
{
|
||||
s64 bw;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* inode.c - Inode handling code. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -33,9 +33,9 @@
|
|||
/**
|
||||
* Internal:
|
||||
*
|
||||
* __allocate_ntfs_inode - desc
|
||||
* __ntfs_inode_allocate - desc
|
||||
*/
|
||||
static __inline__ ntfs_inode *__allocate_ntfs_inode(ntfs_volume *vol)
|
||||
static __inline__ ntfs_inode *__ntfs_inode_allocate(ntfs_volume *vol)
|
||||
{
|
||||
ntfs_inode *ni;
|
||||
|
||||
|
@ -48,19 +48,19 @@ static __inline__ ntfs_inode *__allocate_ntfs_inode(ntfs_volume *vol)
|
|||
/**
|
||||
* Internal:
|
||||
*
|
||||
* allocate_ntfs_inode - desc
|
||||
* ntfs_inode_allocate - desc
|
||||
*/
|
||||
ntfs_inode *allocate_ntfs_inode(ntfs_volume *vol)
|
||||
ntfs_inode *ntfs_inode_allocate(ntfs_volume *vol)
|
||||
{
|
||||
return __allocate_ntfs_inode(vol);
|
||||
return __ntfs_inode_allocate(vol);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal:
|
||||
*
|
||||
* __release_ntfs_inode - desc
|
||||
* __ntfs_inode_release - desc
|
||||
*/
|
||||
static __inline__ int __release_ntfs_inode(ntfs_inode *ni)
|
||||
static __inline__ int __ntfs_inode_release(ntfs_inode *ni)
|
||||
{
|
||||
if (NInoDirty(ni))
|
||||
Dputs("Eeek. Discarding dirty inode!");
|
||||
|
@ -75,7 +75,7 @@ static __inline__ int __release_ntfs_inode(ntfs_inode *ni)
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_open_inode - open an inode ready for access
|
||||
* ntfs_inode_open - open an inode ready for access
|
||||
* @vol: volume to get the inode from
|
||||
* @mref: inode number / mft record number to open
|
||||
*
|
||||
|
@ -99,7 +99,7 @@ static __inline__ int __release_ntfs_inode(ntfs_inode *ni)
|
|||
* Return a pointer to the ntfs_inode structure on success or NULL on error,
|
||||
* with errno set to the error code.
|
||||
*/
|
||||
ntfs_inode *ntfs_open_inode(ntfs_volume *vol, const MFT_REF mref)
|
||||
ntfs_inode *ntfs_inode_open(ntfs_volume *vol, const MFT_REF mref)
|
||||
{
|
||||
s64 l;
|
||||
ntfs_inode *ni;
|
||||
|
@ -111,7 +111,7 @@ ntfs_inode *ntfs_open_inode(ntfs_volume *vol, const MFT_REF mref)
|
|||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
ni = __allocate_ntfs_inode(vol);
|
||||
ni = __ntfs_inode_allocate(vol);
|
||||
if (!ni)
|
||||
return NULL;
|
||||
if (ntfs_file_record_read(vol, mref, &ni->mrec, NULL))
|
||||
|
@ -119,18 +119,18 @@ ntfs_inode *ntfs_open_inode(ntfs_volume *vol, const MFT_REF mref)
|
|||
if (!(ni->mrec->flags & MFT_RECORD_IN_USE))
|
||||
goto err_out;
|
||||
ni->mft_no = MREF(mref);
|
||||
ctx = ntfs_get_attr_search_ctx(ni, NULL);
|
||||
ctx = ntfs_attr_get_search_ctx(ni, NULL);
|
||||
if (!ctx)
|
||||
goto err_out;
|
||||
if (ntfs_lookup_attr(AT_ATTRIBUTE_LIST, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
if (ntfs_attr_lookup(AT_ATTRIBUTE_LIST, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
if (errno != ENOENT)
|
||||
goto put_err_out;
|
||||
/* Attribute list attribute not present so we are done. */
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return ni;
|
||||
}
|
||||
NInoSetAttrList(ni);
|
||||
l = get_attribute_value_length(ctx->attr);
|
||||
l = ntfs_get_attribute_value_length(ctx->attr);
|
||||
if (!l)
|
||||
goto put_err_out;
|
||||
if (l > 0x40000) {
|
||||
|
@ -141,7 +141,7 @@ ntfs_inode *ntfs_open_inode(ntfs_volume *vol, const MFT_REF mref)
|
|||
ni->attr_list = malloc(ni->attr_list_size);
|
||||
if (!ni->attr_list)
|
||||
goto put_err_out;
|
||||
l = get_attribute_value(vol, ni->mrec, ctx->attr, ni->attr_list);
|
||||
l = ntfs_get_attribute_value(vol, ni->mrec, ctx->attr, ni->attr_list);
|
||||
if (!l)
|
||||
goto put_err_out;
|
||||
if (l != ni->attr_list_size) {
|
||||
|
@ -150,32 +150,32 @@ ntfs_inode *ntfs_open_inode(ntfs_volume *vol, const MFT_REF mref)
|
|||
}
|
||||
if (!ctx->attr->non_resident) {
|
||||
/* Attribute list attribute is resident so we are done. */
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return ni;
|
||||
}
|
||||
NInoSetAttrListNonResident(ni);
|
||||
// FIXME: We are duplicating work here! (AIA)
|
||||
ni->attr_list_rl = ntfs_decompress_mapping_pairs(vol, ctx->attr, NULL);
|
||||
ni->attr_list_rl = ntfs_mapping_pairs_decompress(vol, ctx->attr, NULL);
|
||||
if (ni->attr_list_rl) {
|
||||
/* We got the runlist, so we are done. */
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return ni;
|
||||
}
|
||||
err = EIO;
|
||||
put_err_out:
|
||||
if (!err)
|
||||
err = errno;
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
err_out:
|
||||
if (!err)
|
||||
err = errno;
|
||||
__release_ntfs_inode(ni);
|
||||
__ntfs_inode_release(ni);
|
||||
errno = err;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_close_inode - close an ntfs inode and free all associated memory
|
||||
* ntfs_inode_close - close an ntfs inode and free all associated memory
|
||||
* @ni: ntfs inode to close
|
||||
*
|
||||
* Make sure the ntfs inode @ni is clean.
|
||||
|
@ -185,17 +185,17 @@ err_out:
|
|||
* structure itself.
|
||||
*
|
||||
* If it is an extent inode, we postpone to when the base inode is being closed
|
||||
* with ntfs_close_inode() to tear down all structures and free all allocated
|
||||
* with ntfs_inode_close() to tear down all structures and free all allocated
|
||||
* memory. That way we keep the extent records cached in memory so we get an
|
||||
* efficient ntfs_lookup_attr().
|
||||
*
|
||||
* Return 0 on success or -1 on error with errno set to the error code. On
|
||||
* error, @ni has not been freed. The user should attempt to handle the error
|
||||
* and call ntfs_close_inode() again. The following error codes are defined:
|
||||
* and call ntfs_inode_close() again. The following error codes are defined:
|
||||
*
|
||||
* EBUSY @ni is dirty and/or the attribute list runlist is dirty.
|
||||
*/
|
||||
int ntfs_close_inode(ntfs_inode *ni)
|
||||
int ntfs_inode_close(ntfs_inode *ni)
|
||||
{
|
||||
// TODO: This needs to be replaced with a flush to disk attempt. (AIA)
|
||||
if (NInoDirty(ni) || NInoAttrListDirty(ni)) {
|
||||
|
@ -208,14 +208,14 @@ int ntfs_close_inode(ntfs_inode *ni)
|
|||
|
||||
// FIXME: Handle dirty case for each extent inode! (AIA)
|
||||
for (i = 0; i < ni->nr_extents; i++)
|
||||
__release_ntfs_inode(ni->extent_nis[i]);
|
||||
__ntfs_inode_release(ni->extent_nis[i]);
|
||||
free(ni->extent_nis);
|
||||
}
|
||||
return __release_ntfs_inode(ni);
|
||||
return __ntfs_inode_release(ni);
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_open_extent_inode - load an extent inode and attach it to its base
|
||||
* ntfs_extent_inode_open - load an extent inode and attach it to its base
|
||||
* @base_ni: base ntfs inode
|
||||
* @mref: mft reference of the extent inode to load (in little endian)
|
||||
*
|
||||
|
@ -236,7 +236,7 @@ int ntfs_close_inode(ntfs_inode *ni)
|
|||
* pointer to the ntfs_inode structure on success or NULL on error, with errno
|
||||
* set to the error code.
|
||||
*/
|
||||
ntfs_inode *ntfs_open_extent_inode(ntfs_inode *base_ni, const MFT_REF mref)
|
||||
ntfs_inode *ntfs_extent_inode_open(ntfs_inode *base_ni, const MFT_REF mref)
|
||||
{
|
||||
u64 mft_no = MREF_LE(mref);
|
||||
ntfs_inode *ni;
|
||||
|
@ -274,7 +274,7 @@ ntfs_inode *ntfs_open_extent_inode(ntfs_inode *base_ni, const MFT_REF mref)
|
|||
}
|
||||
}
|
||||
/* Wasn't there, we need to load the extent inode. */
|
||||
ni = __allocate_ntfs_inode(base_ni->vol);
|
||||
ni = __ntfs_inode_allocate(base_ni->vol);
|
||||
if (!ni)
|
||||
return NULL;
|
||||
if (ntfs_file_record_read(base_ni->vol, le64_to_cpu(mref), &ni->mrec,
|
||||
|
@ -301,7 +301,7 @@ ntfs_inode *ntfs_open_extent_inode(ntfs_inode *base_ni, const MFT_REF mref)
|
|||
return ni;
|
||||
err_out:
|
||||
i = errno;
|
||||
__release_ntfs_inode(ni);
|
||||
__ntfs_inode_release(ni);
|
||||
errno = i;
|
||||
Dperror("Failed to open extent inode");
|
||||
return NULL;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* mft.c - Mft record handling code. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -210,7 +210,7 @@ int ntfs_file_record_read(const ntfs_volume *vol, const MFT_REF mref,
|
|||
err = errno;
|
||||
goto read_failed;
|
||||
}
|
||||
if (!is_file_record(m->magic))
|
||||
if (!ntfs_is_file_record(m->magic))
|
||||
goto file_corrupt;
|
||||
if (MSEQNO(mref) && MSEQNO(mref) != le16_to_cpu(m->sequence_number))
|
||||
goto file_corrupt;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* mst.c - Multi sector fixup handling code. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -23,7 +23,7 @@
|
|||
#include <errno.h>
|
||||
|
||||
/**
|
||||
* ntfs_post_read_mst_fixup - deprotect multi sector transfer protected data
|
||||
* ntfs_mst_post_read_fixup - deprotect multi sector transfer protected data
|
||||
* @b: pointer to the data to deprotect
|
||||
* @size: size in bytes of @b
|
||||
*
|
||||
|
@ -37,7 +37,7 @@
|
|||
* EIO Mulit sector transfer error was detected. Magic of the NTFS
|
||||
* record in @b will have been set to "BAAD".
|
||||
*/
|
||||
int ntfs_post_read_mst_fixup(NTFS_RECORD *b, const u32 size)
|
||||
int ntfs_mst_post_read_fixup(NTFS_RECORD *b, const u32 size)
|
||||
{
|
||||
u16 usa_ofs, usa_count, usn;
|
||||
u16 *usa_pos, *data_pos;
|
||||
|
@ -100,7 +100,7 @@ int ntfs_post_read_mst_fixup(NTFS_RECORD *b, const u32 size)
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_pre_write_mst_fixup - apply multi sector transfer protection
|
||||
* ntfs_mst_pre_write_fixup - apply multi sector transfer protection
|
||||
* @b: pointer to the data to protect
|
||||
* @size: size in bytes of @b
|
||||
*
|
||||
|
@ -119,13 +119,14 @@ int ntfs_post_read_mst_fixup(NTFS_RECORD *b, const u32 size)
|
|||
* otherwise a random word will be used (whatever was in the record at that
|
||||
* position at that time).
|
||||
*/
|
||||
int ntfs_pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
|
||||
int ntfs_mst_pre_write_fixup(NTFS_RECORD *b, const u32 size)
|
||||
{
|
||||
u16 usa_ofs, usa_count, usn;
|
||||
u16 *usa_pos, *data_pos;
|
||||
|
||||
/* Sanity check + only fixup if it makes sense. */
|
||||
if (!b || is_baad_record(b->magic) || is_hole_record(b->magic)) {
|
||||
if (!b || ntfs_is_baad_record(b->magic) ||
|
||||
ntfs_is_hole_record(b->magic)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
@ -169,7 +170,7 @@ int ntfs_pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_post_write_mst_fixup - deprotect multi sector transfer protected data
|
||||
* ntfs_mst_post_write_fixup - deprotect multi sector transfer protected data
|
||||
* @b: pointer to the data to deprotect
|
||||
*
|
||||
* Perform the necessary post write multi sector transfer fixup, not checking
|
||||
|
@ -177,7 +178,7 @@ int ntfs_pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
|
|||
* ntfs_pre_write_mst_fixup(), thus the data will be fine or we would never
|
||||
* have gotten here.
|
||||
*/
|
||||
void ntfs_post_write_mst_fixup(NTFS_RECORD *b)
|
||||
void ntfs_mst_post_write_fixup(NTFS_RECORD *b)
|
||||
{
|
||||
u16 *usa_pos, *data_pos;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* runlist.c - Run list handling code. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2002 Richard Russon.
|
||||
* Copyright (c) 2002 Anton Altaparmakov
|
||||
* Copyright (c) 2002 Richard Russon
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -87,7 +87,7 @@ static __inline__ runlist_element *ntfs_rl_realloc(runlist_element *rl,
|
|||
/**
|
||||
* Internal:
|
||||
*
|
||||
* ntfs_are_rl_mergeable - test if two runlists can be joined together
|
||||
* ntfs_rl_are_mergeable - test if two runlists can be joined together
|
||||
* @dst: original runlist
|
||||
* @src: new runlist to test for mergeability with @dst
|
||||
*
|
||||
|
@ -97,11 +97,11 @@ static __inline__ runlist_element *ntfs_rl_realloc(runlist_element *rl,
|
|||
* Return: TRUE Success, the runlists can be merged.
|
||||
* FALSE Failure, the runlists cannot be merged.
|
||||
*/
|
||||
static __inline__ BOOL ntfs_are_rl_mergeable(runlist_element *dst,
|
||||
static __inline__ BOOL ntfs_rl_are_mergeable(runlist_element *dst,
|
||||
runlist_element *src)
|
||||
{
|
||||
if (!dst || !src) {
|
||||
Dputs("Eeek. ntfs_are_rl_mergeable() invoked with NULL "
|
||||
Dputs("Eeek. ntfs_rl_are_mergeable() invoked with NULL "
|
||||
"pointer!");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ static __inline__ void __ntfs_rl_merge(runlist_element *dst,
|
|||
static __inline__ BOOL ntfs_rl_merge(runlist_element *dst,
|
||||
runlist_element *src)
|
||||
{
|
||||
BOOL merge = ntfs_are_rl_mergeable(dst, src);
|
||||
BOOL merge = ntfs_rl_are_mergeable(dst, src);
|
||||
|
||||
if (merge)
|
||||
__ntfs_rl_merge(dst, src);
|
||||
|
@ -193,7 +193,7 @@ static __inline__ runlist_element *ntfs_rl_append(runlist_element *dst,
|
|||
}
|
||||
|
||||
/* First, check if the right hand end needs merging. */
|
||||
right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1);
|
||||
right = ntfs_rl_are_mergeable(src + ssize - 1, dst + loc + 1);
|
||||
|
||||
/* Space required: @dst size + @src size, less one if we merged. */
|
||||
dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - right);
|
||||
|
@ -270,7 +270,7 @@ static __inline__ runlist_element *ntfs_rl_insert(runlist_element *dst,
|
|||
else {
|
||||
s64 merged_length;
|
||||
|
||||
left = ntfs_are_rl_mergeable(dst + loc - 1, src);
|
||||
left = ntfs_rl_are_mergeable(dst + loc - 1, src);
|
||||
|
||||
merged_length = dst[loc - 1].length;
|
||||
if (left)
|
||||
|
@ -369,9 +369,9 @@ static __inline__ runlist_element *ntfs_rl_replace(runlist_element *dst,
|
|||
}
|
||||
|
||||
/* First, merge the left and right ends, if necessary. */
|
||||
right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1);
|
||||
right = ntfs_rl_are_mergeable(src + ssize - 1, dst + loc + 1);
|
||||
if (loc > 0)
|
||||
left = ntfs_are_rl_mergeable(dst + loc - 1, src);
|
||||
left = ntfs_rl_are_mergeable(dst + loc - 1, src);
|
||||
|
||||
/* Allocate some space. We'll need less if the left, right, or both
|
||||
* ends were merged. */
|
||||
|
@ -454,7 +454,7 @@ static __inline__ runlist_element *ntfs_rl_split(runlist_element *dst,
|
|||
|
||||
|
||||
/**
|
||||
* ntfs_merge_runlists - merge two runlists into one
|
||||
* ntfs_runlists_merge - merge two runlists into one
|
||||
* @drl: original runlist to be worked on
|
||||
* @srl: new runlist to be merged into @drl
|
||||
*
|
||||
|
@ -485,7 +485,7 @@ static __inline__ runlist_element *ntfs_rl_split(runlist_element *dst,
|
|||
* EINVAL Invalid parameters were passed in.
|
||||
* ERANGE The runlists overlap and cannot be merged.
|
||||
*/
|
||||
runlist_element *ntfs_merge_runlists(runlist_element *drl,
|
||||
runlist_element *ntfs_runlists_merge(runlist_element *drl,
|
||||
runlist_element *srl)
|
||||
{
|
||||
int di, si; /* Current index into @[ds]rl. */
|
||||
|
@ -498,9 +498,9 @@ runlist_element *ntfs_merge_runlists(runlist_element *drl,
|
|||
VCN marker_vcn = 0;
|
||||
|
||||
Dputs("dst:");
|
||||
ntfs_debug_dump_runlist(drl);
|
||||
ntfs_debug_runlist_dump(drl);
|
||||
Dputs("src:");
|
||||
ntfs_debug_dump_runlist(srl);
|
||||
ntfs_debug_runlist_dump(srl);
|
||||
|
||||
/* Check for silly calling... */
|
||||
if (!srl)
|
||||
|
@ -680,7 +680,7 @@ runlist_element *ntfs_merge_runlists(runlist_element *drl,
|
|||
finished:
|
||||
/* The merge was completed successfully. */
|
||||
Dputs("Merged runlist:");
|
||||
ntfs_debug_dump_runlist(drl);
|
||||
ntfs_debug_runlist_dump(drl);
|
||||
return drl;
|
||||
|
||||
critical_error:
|
||||
|
@ -692,7 +692,7 @@ critical_error:
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_decompress_mapping_pairs - convert mapping pairs array to runlist
|
||||
* ntfs_mapping_pairs_decompress - convert mapping pairs array to runlist
|
||||
* @vol: ntfs volume on which the attribute resides
|
||||
* @attr: attribute record whose mapping pairs array to decompress
|
||||
* @old_rl: optional runlist in which to insert @attr's runlist
|
||||
|
@ -718,7 +718,7 @@ critical_error:
|
|||
* two into one, if that is possible (we check for overlap and discard the new
|
||||
* runlist if overlap present before returning NULL, with errno = ERANGE).
|
||||
*/
|
||||
runlist_element *ntfs_decompress_mapping_pairs(const ntfs_volume *vol,
|
||||
runlist_element *ntfs_mapping_pairs_decompress(const ntfs_volume *vol,
|
||||
const ATTR_RECORD *attr, runlist_element *old_rl)
|
||||
{
|
||||
VCN vcn; /* Current vcn. */
|
||||
|
@ -912,11 +912,11 @@ mpa_err:
|
|||
/* If no existing runlist was specified, we are done. */
|
||||
if (!old_rl) {
|
||||
Dputs("Mapping pairs array successfully decompressed:");
|
||||
ntfs_debug_dump_runlist(rl);
|
||||
ntfs_debug_runlist_dump(rl);
|
||||
return rl;
|
||||
}
|
||||
/* Now combine the new and old runlists checking for overlaps. */
|
||||
old_rl = ntfs_merge_runlists(old_rl, rl);
|
||||
old_rl = ntfs_runlists_merge(old_rl, rl);
|
||||
if (old_rl)
|
||||
return old_rl;
|
||||
free(rl);
|
||||
|
@ -1098,7 +1098,7 @@ rl_err_out:
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_build_mapping_pairs - build the mapping pairs array from a runlist
|
||||
* ntfs_mapping_pairs_build - build the mapping pairs array from a runlist
|
||||
* @vol: ntfs volume (needed for the ntfs version)
|
||||
* @dst: destination buffer to which to write the mapping pairs array
|
||||
* @dst_len: size of destination buffer @dst in bytes
|
||||
|
@ -1115,7 +1115,7 @@ rl_err_out:
|
|||
* EIO - The runlist is corrupt.
|
||||
* ENOSPC - The destination buffer is too small.
|
||||
*/
|
||||
int ntfs_build_mapping_pairs(const ntfs_volume *vol, s8 *dst,
|
||||
int ntfs_mapping_pairs_build(const ntfs_volume *vol, s8 *dst,
|
||||
const int dst_len, const runlist_element *rl)
|
||||
{
|
||||
LCN prev_lcn;
|
||||
|
@ -1174,5 +1174,3 @@ err_out:
|
|||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* unistr.c - Unicode string handling. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -56,7 +56,7 @@ const u8 legal_ansi_char_array[0x40] = {
|
|||
};
|
||||
|
||||
/**
|
||||
* ntfs_are_names_equal - compare two Unicode names for equality
|
||||
* ntfs_names_are_equal - compare two Unicode names for equality
|
||||
* @s1: name to compare to @s2
|
||||
* @s1_len: length in Unicode characters of @s1
|
||||
* @s2: name to compare to @s1
|
||||
|
@ -69,7 +69,7 @@ const u8 legal_ansi_char_array[0x40] = {
|
|||
* identical, or FALSE (0) if they are not identical. If @ic is IGNORE_CASE,
|
||||
* the @upcase table is used to performa a case insensitive comparison.
|
||||
*/
|
||||
BOOL ntfs_are_names_equal(const uchar_t *s1, size_t s1_len,
|
||||
BOOL ntfs_names_are_equal(const uchar_t *s1, size_t s1_len,
|
||||
const uchar_t *s2, size_t s2_len,
|
||||
const IGNORE_CASE_BOOL ic,
|
||||
const uchar_t *upcase, const u32 upcase_size)
|
||||
|
@ -85,7 +85,7 @@ BOOL ntfs_are_names_equal(const uchar_t *s1, size_t s1_len,
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_collate_names - collate two Unicode names
|
||||
* ntfs_names_collate - collate two Unicode names
|
||||
* @upcase: upcase table (ignored if @ic is CASE_SENSITIVE)
|
||||
* @upcase_len: upcase table size (ignored if @ic is CASE_SENSITIVE)
|
||||
* @name1: first Unicode name to compare
|
||||
|
@ -93,7 +93,7 @@ BOOL ntfs_are_names_equal(const uchar_t *s1, size_t s1_len,
|
|||
* @ic: either CASE_SENSITIVE or IGNORE_CASE
|
||||
* @err_val: if @name1 contains an invalid character return this value
|
||||
*
|
||||
* ntfs_collate_names collates two Unicode names and returns:
|
||||
* ntfs_names_collate() collates two Unicode names and returns:
|
||||
*
|
||||
* -1 if the first name collates before the second one,
|
||||
* 0 if the names match,
|
||||
|
@ -102,7 +102,7 @@ BOOL ntfs_are_names_equal(const uchar_t *s1, size_t s1_len,
|
|||
*
|
||||
* The following characters are considered invalid: '"', '*', '<', '>' and '?'.
|
||||
*/
|
||||
int ntfs_collate_names(const uchar_t *name1, const u32 name1_len,
|
||||
int ntfs_names_collate(const uchar_t *name1, const u32 name1_len,
|
||||
const uchar_t *name2, const u32 name2_len,
|
||||
const int err_val, const IGNORE_CASE_BOOL ic,
|
||||
const uchar_t *upcase, const u32 upcase_len)
|
||||
|
@ -228,9 +228,9 @@ int ntfs_ucsncasecmp(const uchar_t *s1, const uchar_t *s2, size_t n,
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_upcase_name
|
||||
* ntfs_name_upcase
|
||||
*/
|
||||
void ntfs_upcase_name(uchar_t *name, u32 name_len, const uchar_t *upcase,
|
||||
void ntfs_name_upcase(uchar_t *name, u32 name_len, const uchar_t *upcase,
|
||||
const u32 upcase_len)
|
||||
{
|
||||
u32 i;
|
||||
|
@ -242,24 +242,24 @@ void ntfs_upcase_name(uchar_t *name, u32 name_len, const uchar_t *upcase,
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_file_upcase_value
|
||||
* ntfs_file_value_upcase
|
||||
*/
|
||||
void ntfs_file_upcase_value(FILE_NAME_ATTR *file_name_attr,
|
||||
const uchar_t *upcase, const u32 upcase_len)
|
||||
{
|
||||
ntfs_upcase_name((uchar_t*)&file_name_attr->file_name,
|
||||
ntfs_name_upcase((uchar_t*)&file_name_attr->file_name,
|
||||
file_name_attr->file_name_length, upcase, upcase_len);
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_file_compare_values
|
||||
* ntfs_file_values_compare
|
||||
*/
|
||||
int ntfs_file_compare_values(FILE_NAME_ATTR *file_name_attr1,
|
||||
FILE_NAME_ATTR *file_name_attr2,
|
||||
const int err_val, const IGNORE_CASE_BOOL ic,
|
||||
const uchar_t *upcase, const u32 upcase_len)
|
||||
{
|
||||
return ntfs_collate_names((uchar_t*)&file_name_attr1->file_name,
|
||||
return ntfs_names_collate((uchar_t*)&file_name_attr1->file_name,
|
||||
file_name_attr1->file_name_length,
|
||||
(uchar_t*)&file_name_attr2->file_name,
|
||||
file_name_attr2->file_name_length,
|
||||
|
|
153
libntfs/volume.c
153
libntfs/volume.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* volume.c - NTFS volume handling code. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
|
@ -39,10 +39,10 @@
|
|||
/**
|
||||
* Internal:
|
||||
*
|
||||
* __allocate_ntfs_volume -
|
||||
* __ntfs_volume_allocate -
|
||||
*
|
||||
*/
|
||||
static ntfs_volume *__allocate_ntfs_volume(void)
|
||||
static ntfs_volume *__ntfs_volume_allocate(void)
|
||||
{
|
||||
return (ntfs_volume*)calloc(1, sizeof(ntfs_volume));
|
||||
}
|
||||
|
@ -50,10 +50,10 @@ static ntfs_volume *__allocate_ntfs_volume(void)
|
|||
/**
|
||||
* Internal:
|
||||
*
|
||||
* __release_ntfs_volume -
|
||||
* __ntfs_volume_release -
|
||||
*
|
||||
*/
|
||||
static void __release_ntfs_volume(ntfs_volume *v)
|
||||
static void __ntfs_volume_release(ntfs_volume *v)
|
||||
{
|
||||
if (v->fd)
|
||||
close(v->fd);
|
||||
|
@ -64,29 +64,29 @@ static void __release_ntfs_volume(ntfs_volume *v)
|
|||
if (v->lcnbmp_na)
|
||||
ntfs_attr_close(v->lcnbmp_na);
|
||||
if (v->lcnbmp_ni)
|
||||
ntfs_close_inode(v->lcnbmp_ni);
|
||||
ntfs_inode_close(v->lcnbmp_ni);
|
||||
if (v->mftbmp_na)
|
||||
ntfs_attr_close(v->mftbmp_na);
|
||||
if (v->mft_na)
|
||||
ntfs_attr_close(v->mft_na);
|
||||
if (v->mft_ni)
|
||||
ntfs_close_inode(v->mft_ni);
|
||||
ntfs_inode_close(v->mft_ni);
|
||||
if (v->mftmirr_na)
|
||||
ntfs_attr_close(v->mftmirr_na);
|
||||
if (v->mftmirr_ni)
|
||||
ntfs_close_inode(v->mftmirr_ni);
|
||||
ntfs_inode_close(v->mftmirr_ni);
|
||||
if (v->upcase)
|
||||
free(v->upcase);
|
||||
free(v);
|
||||
}
|
||||
|
||||
/* External declaration for internal function. */
|
||||
extern ntfs_inode *allocate_ntfs_inode(ntfs_volume *);
|
||||
extern ntfs_inode *ntfs_inode_allocate(ntfs_volume *);
|
||||
|
||||
/**
|
||||
* Internal:
|
||||
*
|
||||
* ntfs_load_mft - load the $MFT and setup the ntfs volume with it
|
||||
* ntfs_mft_load - load the $MFT and setup the ntfs volume with it
|
||||
* @vol: ntfs volume whose $MFT to load
|
||||
*
|
||||
* Load $MFT from @vol and setup @vol with it. After calling this function the
|
||||
|
@ -95,7 +95,7 @@ extern ntfs_inode *allocate_ntfs_inode(ntfs_volume *);
|
|||
*
|
||||
* Return 0 on success and -1 on error with errno set to the error code.
|
||||
*/
|
||||
static int ntfs_load_mft(ntfs_volume *vol)
|
||||
static int ntfs_mft_load(ntfs_volume *vol)
|
||||
{
|
||||
VCN next_vcn, last_vcn, highest_vcn;
|
||||
s64 l;
|
||||
|
@ -105,7 +105,7 @@ static int ntfs_load_mft(ntfs_volume *vol)
|
|||
int eo;
|
||||
|
||||
/* Manually setup an ntfs_inode. */
|
||||
vol->mft_ni = allocate_ntfs_inode(vol);
|
||||
vol->mft_ni = ntfs_inode_allocate(vol);
|
||||
mb = (MFT_RECORD*)malloc(vol->mft_record_size);
|
||||
if (!vol->mft_ni || !mb) {
|
||||
Dperror("Error allocating memory for $MFT");
|
||||
|
@ -122,16 +122,16 @@ static int ntfs_load_mft(ntfs_volume *vol)
|
|||
Dperror("Error reading $MFT");
|
||||
goto error_exit;
|
||||
}
|
||||
if (is_baad_record(mb->magic)) {
|
||||
if (ntfs_is_baad_record(mb->magic)) {
|
||||
Dputs("Error: Incomplete multi sector transfer detected in "
|
||||
"$MFT.");
|
||||
goto io_error_exit;
|
||||
}
|
||||
if (!is_mft_record(mb->magic)) {
|
||||
if (!ntfs_is_mft_record(mb->magic)) {
|
||||
Dputs("Error: $MFT has invalid magic.");
|
||||
goto io_error_exit;
|
||||
}
|
||||
ctx = ntfs_get_attr_search_ctx(vol->mft_ni, mb);
|
||||
ctx = ntfs_attr_get_search_ctx(vol->mft_ni, mb);
|
||||
if (!ctx) {
|
||||
Dperror("Failed to allocate attribute search context");
|
||||
goto error_exit;
|
||||
|
@ -142,7 +142,8 @@ static int ntfs_load_mft(ntfs_volume *vol)
|
|||
goto io_error_exit;
|
||||
}
|
||||
/* Find the $ATTRIBUTE_LIST attribute in $MFT if present. */
|
||||
if (ntfs_lookup_attr(AT_ATTRIBUTE_LIST, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
if (ntfs_attr_lookup(AT_ATTRIBUTE_LIST, AT_UNNAMED, 0, 0, 0, NULL, 0,
|
||||
ctx)) {
|
||||
if (errno != ENOENT) {
|
||||
Dputs("Error: $MFT has corrupt attribute list.");
|
||||
goto io_error_exit;
|
||||
|
@ -150,7 +151,7 @@ static int ntfs_load_mft(ntfs_volume *vol)
|
|||
goto mft_has_no_attr_list;
|
||||
}
|
||||
NInoSetAttrList(vol->mft_ni);
|
||||
l = get_attribute_value_length(ctx->attr);
|
||||
l = ntfs_get_attribute_value_length(ctx->attr);
|
||||
if (l <= 0 || l > 0x40000) {
|
||||
Dputs("Error: $MFT/$ATTRIBUTE_LIST has invalid length.");
|
||||
goto io_error_exit;
|
||||
|
@ -161,7 +162,7 @@ static int ntfs_load_mft(ntfs_volume *vol)
|
|||
Dputs("Error: failed to allocate buffer for attribute list.");
|
||||
goto error_exit;
|
||||
}
|
||||
l = get_attribute_value(vol, vol->mft_ni->mrec, ctx->attr,
|
||||
l = ntfs_get_attribute_value(vol, vol->mft_ni->mrec, ctx->attr,
|
||||
vol->mft_ni->attr_list);
|
||||
if (!l) {
|
||||
Dputs("Error: failed to get value of $MFT/$ATTRIBUTE_LIST.");
|
||||
|
@ -175,7 +176,7 @@ static int ntfs_load_mft(ntfs_volume *vol)
|
|||
if (ctx->attr->non_resident) {
|
||||
NInoSetAttrListNonResident(vol->mft_ni);
|
||||
// FIXME: We are duplicating work here! (AIA)
|
||||
vol->mft_ni->attr_list_rl = ntfs_decompress_mapping_pairs(vol,
|
||||
vol->mft_ni->attr_list_rl = ntfs_mapping_pairs_decompress(vol,
|
||||
ctx->attr, NULL);
|
||||
if (!vol->mft_ni->attr_list_rl) {
|
||||
Dperror("Error: failed to get runlist for "
|
||||
|
@ -196,11 +197,12 @@ mft_has_no_attr_list:
|
|||
vol->nr_mft_records = vol->mft_na->data_size >>
|
||||
vol->mft_record_size_bits;
|
||||
/* Read all extents from the $DATA attribute in $MFT. */
|
||||
ntfs_reinit_attr_search_ctx(ctx);
|
||||
ntfs_attr_reinit_search_ctx(ctx);
|
||||
last_vcn = vol->mft_na->allocated_size >> vol->cluster_size_bits;
|
||||
highest_vcn = next_vcn = 0;
|
||||
a = NULL;
|
||||
while (!ntfs_lookup_attr(AT_DATA, AT_UNNAMED, 0, 0, next_vcn, NULL, 0, ctx)) {
|
||||
while (!ntfs_attr_lookup(AT_DATA, AT_UNNAMED, 0, 0, next_vcn, NULL, 0,
|
||||
ctx)) {
|
||||
runlist_element *nrl;
|
||||
|
||||
a = ctx->attr;
|
||||
|
@ -225,9 +227,9 @@ mft_has_no_attr_list:
|
|||
* as we have exclusive access to the inode at this time and we
|
||||
* are a mount in progress task, too.
|
||||
*/
|
||||
nrl = ntfs_decompress_mapping_pairs(vol, a, vol->mft_na->rl);
|
||||
nrl = ntfs_mapping_pairs_decompress(vol, a, vol->mft_na->rl);
|
||||
if (!nrl) {
|
||||
Dperror("decompress_mapping_pairs() failed");
|
||||
Dperror("ntfs_mapping_pairs_decompress() failed");
|
||||
goto error_exit;
|
||||
}
|
||||
vol->mft_na->rl = nrl;
|
||||
|
@ -261,7 +263,7 @@ mft_has_no_attr_list:
|
|||
goto io_error_exit;
|
||||
}
|
||||
/* Done with the $Mft mft record. */
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
ctx = NULL;
|
||||
/*
|
||||
* The volume is now setup so we can use all read access functions.
|
||||
|
@ -277,13 +279,13 @@ io_error_exit:
|
|||
error_exit:
|
||||
eo = errno;
|
||||
if (ctx)
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
if (vol->mft_na) {
|
||||
ntfs_attr_close(vol->mft_na);
|
||||
vol->mft_na = NULL;
|
||||
}
|
||||
if (vol->mft_ni) {
|
||||
ntfs_close_inode(vol->mft_ni);
|
||||
ntfs_inode_close(vol->mft_ni);
|
||||
vol->mft_ni = NULL;
|
||||
}
|
||||
errno = eo;
|
||||
|
@ -293,22 +295,22 @@ error_exit:
|
|||
/**
|
||||
* Internal:
|
||||
*
|
||||
* ntfs_load_mftmirr - load the $MFTMirr and setup the ntfs volume with it
|
||||
* ntfs_mftmirr_load - load the $MFTMirr and setup the ntfs volume with it
|
||||
* @vol: ntfs volume whose $MFTMirr to load
|
||||
*
|
||||
* Load $MFTMirr from @vol and setup @vol with it. After calling this function
|
||||
* the volume @vol is ready for use by all write access functions provided by
|
||||
* the ntfs library (assuming ntfs_load_mft() has been called successfully
|
||||
* the ntfs library (assuming ntfs_mft_load() has been called successfully
|
||||
* beforehand).
|
||||
*
|
||||
* Return 0 on success and -1 on error with errno set to the error code.
|
||||
*/
|
||||
static int ntfs_load_mftmirr(ntfs_volume *vol)
|
||||
static int ntfs_mftmirr_load(ntfs_volume *vol)
|
||||
{
|
||||
int i;
|
||||
runlist_element rl[2];
|
||||
|
||||
vol->mftmirr_ni = ntfs_open_inode(vol, FILE_MFTMirr);
|
||||
vol->mftmirr_ni = ntfs_inode_open(vol, FILE_MFTMirr);
|
||||
if (!vol->mftmirr_ni) {
|
||||
Dperror("Failed to open inode $MFTMirr");
|
||||
return -1;
|
||||
|
@ -349,14 +351,14 @@ error_exit:
|
|||
ntfs_attr_close(vol->mftmirr_na);
|
||||
vol->mftmirr_na = NULL;
|
||||
}
|
||||
ntfs_close_inode(vol->mftmirr_ni);
|
||||
ntfs_inode_close(vol->mftmirr_ni);
|
||||
vol->mftmirr_ni = NULL;
|
||||
errno = i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_startup_volume - allocate and setup an ntfs volume
|
||||
* ntfs_volume_startup - allocate and setup an ntfs volume
|
||||
* @name: name of device/file to open
|
||||
* @rwflag: optional mount flags
|
||||
*
|
||||
|
@ -367,7 +369,7 @@ error_exit:
|
|||
* Return the allocated volume structure on success and NULL on error with
|
||||
* errno set to the error code.
|
||||
*/
|
||||
ntfs_volume *ntfs_startup_volume(const char *name, unsigned long rwflag)
|
||||
ntfs_volume *ntfs_volume_startup(const char *name, unsigned long rwflag)
|
||||
{
|
||||
s64 br;
|
||||
const char *OK = "OK";
|
||||
|
@ -382,7 +384,7 @@ ntfs_volume *ntfs_startup_volume(const char *name, unsigned long rwflag)
|
|||
#endif
|
||||
|
||||
/* Allocate the volume structure. */
|
||||
vol = __allocate_ntfs_volume();
|
||||
vol = __ntfs_volume_allocate();
|
||||
if (!vol)
|
||||
return NULL;
|
||||
/* Make a copy of the partition name. */
|
||||
|
@ -413,12 +415,12 @@ ntfs_volume *ntfs_startup_volume(const char *name, unsigned long rwflag)
|
|||
goto error_exit;
|
||||
}
|
||||
Dputs(OK);
|
||||
if (!is_boot_sector_ntfs(bs, !debug)) {
|
||||
if (!ntfs_boot_sector_is_ntfs(bs, !debug)) {
|
||||
Dprintf("Error: %s is not a valid NTFS partition!\n", name);
|
||||
errno = EINVAL;
|
||||
goto error_exit;
|
||||
}
|
||||
if (parse_ntfs_boot_sector(vol, bs) < 0) {
|
||||
if (ntfs_boot_sector_parse(vol, bs) < 0) {
|
||||
Dperror("Failed to parse ntfs bootsector");
|
||||
goto error_exit;
|
||||
}
|
||||
|
@ -427,7 +429,7 @@ ntfs_volume *ntfs_startup_volume(const char *name, unsigned long rwflag)
|
|||
|
||||
/* Need to setup $MFT so we can use the library read functions. */
|
||||
Dprintf("Loading $MFT... ");
|
||||
if (ntfs_load_mft(vol) < 0) {
|
||||
if (ntfs_mft_load(vol) < 0) {
|
||||
Dputs(FAILED);
|
||||
Dperror("Failed to load $MFT");
|
||||
goto error_exit;
|
||||
|
@ -436,7 +438,7 @@ ntfs_volume *ntfs_startup_volume(const char *name, unsigned long rwflag)
|
|||
|
||||
/* Need to setup $MFTMirr so we can use the write functions, too. */
|
||||
Dprintf("Loading $MFTMirr... ");
|
||||
if (ntfs_load_mftmirr(vol) < 0) {
|
||||
if (ntfs_mftmirr_load(vol) < 0) {
|
||||
Dputs(FAILED);
|
||||
Dperror("Failed to load $MFTMirr");
|
||||
goto error_exit;
|
||||
|
@ -448,7 +450,7 @@ error_exit:
|
|||
if (bs)
|
||||
free(bs);
|
||||
if (vol)
|
||||
__release_ntfs_volume(vol);
|
||||
__ntfs_volume_release(vol);
|
||||
errno = eo;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -499,7 +501,7 @@ ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
vol = ntfs_startup_volume(name, rwflag);
|
||||
vol = ntfs_volume_startup(name, rwflag);
|
||||
if (!vol) {
|
||||
Dperror("Failed to startup volume");
|
||||
return NULL;
|
||||
|
@ -549,24 +551,24 @@ ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag)
|
|||
else
|
||||
s = "mft record";
|
||||
|
||||
if (is_baad_recordp(m + i * vol->mft_record_size)) {
|
||||
if (ntfs_is_baad_recordp(m + i * vol->mft_record_size)) {
|
||||
Dputs("FAILED");
|
||||
Dprintf("$MFT error: Incomplete multi sector transfer "
|
||||
"detected in %s.\n", s);
|
||||
goto io_error_exit;
|
||||
}
|
||||
if (!is_mft_recordp(m + i * vol->mft_record_size)) {
|
||||
if (!ntfs_is_mft_recordp(m + i * vol->mft_record_size)) {
|
||||
Dputs("FAILED");
|
||||
Dprintf("$MFT error: Invalid mft record for %s.\n", s);
|
||||
goto io_error_exit;
|
||||
}
|
||||
if (is_baad_recordp(m2 + i * vol->mft_record_size)) {
|
||||
if (ntfs_is_baad_recordp(m2 + i * vol->mft_record_size)) {
|
||||
Dputs("FAILED");
|
||||
Dprintf("$MFTMirr error: Incomplete multi sector "
|
||||
"transfer detected in %s.\n", s);
|
||||
goto io_error_exit;
|
||||
}
|
||||
if (!is_mft_recordp(m2 + i * vol->mft_record_size)) {
|
||||
if (!ntfs_is_mft_recordp(m2 + i * vol->mft_record_size)) {
|
||||
Dputs("FAILED");
|
||||
Dprintf("$MFTMirr error: Invalid mft record for %s.\n",
|
||||
s);
|
||||
|
@ -574,7 +576,7 @@ ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag)
|
|||
}
|
||||
if (memcmp((u8*)m + i * vol->mft_record_size, (u8*)m2 +
|
||||
i * vol->mft_record_size,
|
||||
ntfs_get_mft_record_data_size((MFT_RECORD*)(
|
||||
ntfs_mft_record_get_data_size((MFT_RECORD*)(
|
||||
(u8*)m + i * vol->mft_record_size)))) {
|
||||
Dputs(FAILED);
|
||||
Dputs("$MFTMirr does not match $MFT. Run chkdsk.");
|
||||
|
@ -589,7 +591,7 @@ ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag)
|
|||
|
||||
/* Now load the bitmap from $Bitmap. */
|
||||
Dprintf("Loading $Bitmap... ");
|
||||
vol->lcnbmp_ni = ntfs_open_inode(vol, FILE_Bitmap);
|
||||
vol->lcnbmp_ni = ntfs_inode_open(vol, FILE_Bitmap);
|
||||
if (!vol->lcnbmp_ni) {
|
||||
Dputs(FAILED);
|
||||
Dperror("Failed to open inode");
|
||||
|
@ -607,7 +609,7 @@ ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag)
|
|||
|
||||
/* Now load the upcase table from $UpCase. */
|
||||
Dprintf("Loading $UpCase... ");
|
||||
ni = ntfs_open_inode(vol, FILE_UpCase);
|
||||
ni = ntfs_inode_open(vol, FILE_UpCase);
|
||||
if (!ni) {
|
||||
Dputs(FAILED);
|
||||
Dperror("Failed to open inode");
|
||||
|
@ -651,7 +653,7 @@ ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag)
|
|||
/* Done with the $UpCase mft record. */
|
||||
Dputs(OK);
|
||||
ntfs_attr_close(na);
|
||||
if (ntfs_close_inode(ni))
|
||||
if (ntfs_inode_close(ni))
|
||||
Dperror("Failed to close inode, leaking memory");
|
||||
|
||||
/*
|
||||
|
@ -659,22 +661,22 @@ ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag)
|
|||
* vol structure accordingly.
|
||||
*/
|
||||
Dprintf("Loading $Volume... ");
|
||||
ni = ntfs_open_inode(vol, FILE_Volume);
|
||||
ni = ntfs_inode_open(vol, FILE_Volume);
|
||||
if (!ni) {
|
||||
Dputs(FAILED);
|
||||
Dperror("Failed to open inode");
|
||||
goto error_exit;
|
||||
}
|
||||
/* Get an ntfs attribute for $UpCase/$DATA. */
|
||||
ctx = ntfs_get_attr_search_ctx(ni, NULL);
|
||||
ctx = ntfs_attr_get_search_ctx(ni, NULL);
|
||||
if (!ctx) {
|
||||
Dputs(FAILED);
|
||||
Dperror("Failed to allocate attribute search context");
|
||||
goto error_exit;
|
||||
}
|
||||
/* Find the $VOLUME_INFORMATION attribute. */
|
||||
if (ntfs_lookup_attr(AT_VOLUME_INFORMATION, AT_UNNAMED, 0, 0, 0, NULL, 0,
|
||||
ctx)) {
|
||||
if (ntfs_attr_lookup(AT_VOLUME_INFORMATION, AT_UNNAMED, 0, 0, 0, NULL,
|
||||
0, ctx)) {
|
||||
Dputs(FAILED);
|
||||
Dputs("$VOLUME_INFORMATION attribute not found in "
|
||||
"$Volume?!?");
|
||||
|
@ -709,8 +711,9 @@ ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag)
|
|||
defined using cpu_to_le16() macro and hence are consistent. */
|
||||
vol->flags = vinf->flags;
|
||||
/* Find the $VOLUME_NAME attribute. */
|
||||
ntfs_reinit_attr_search_ctx(ctx);
|
||||
if (ntfs_lookup_attr(AT_VOLUME_NAME, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
ntfs_attr_reinit_search_ctx(ctx);
|
||||
if (ntfs_attr_lookup(AT_VOLUME_NAME, AT_UNNAMED, 0, 0, 0, NULL, 0,
|
||||
ctx)) {
|
||||
Dputs(FAILED);
|
||||
Dputs("$VOLUME_NAME attribute not found in $Volume?!?");
|
||||
goto error_exit;
|
||||
|
@ -749,9 +752,9 @@ ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag)
|
|||
vol->vol_name[u] = '\0';
|
||||
}
|
||||
Dputs(OK);
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
ctx = NULL;
|
||||
if (ntfs_close_inode(ni))
|
||||
if (ntfs_inode_close(ni))
|
||||
Dperror("Failed to close inode, leaking memory");
|
||||
|
||||
/* FIXME: Need to deal with FILE_AttrDef. (AIA) */
|
||||
|
@ -762,13 +765,13 @@ io_error_exit:
|
|||
error_exit:
|
||||
eo = errno;
|
||||
if (ctx)
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
if (m)
|
||||
free(m);
|
||||
if (m2)
|
||||
free(m2);
|
||||
if (vol)
|
||||
__release_ntfs_volume(vol);
|
||||
__ntfs_volume_release(vol);
|
||||
errno = eo;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -801,7 +804,7 @@ int ntfs_umount(ntfs_volume *vol, const BOOL force)
|
|||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
__release_ntfs_volume(vol);
|
||||
__ntfs_volume_release(vol);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -809,14 +812,14 @@ int ntfs_umount(ntfs_volume *vol, const BOOL force)
|
|||
/**
|
||||
* Internal:
|
||||
*
|
||||
* ntfs_check_mntent - desc
|
||||
* ntfs_mntent_check - desc
|
||||
*
|
||||
* If you are wanting to use this, you actually wanted to use
|
||||
* ntfs_check_if_mounted(), you just didn't realize. (-:
|
||||
*
|
||||
* See description of ntfs_check_if_mounted(), below.
|
||||
*/
|
||||
static int ntfs_check_mntent(const char *file, unsigned long *mnt_flags)
|
||||
static int ntfs_mntent_check(const char *file, unsigned long *mnt_flags)
|
||||
{
|
||||
struct mntent *mnt;
|
||||
FILE *f;
|
||||
|
@ -868,14 +871,14 @@ int ntfs_check_if_mounted(const char *file, unsigned long *mnt_flags)
|
|||
{
|
||||
*mnt_flags = 0;
|
||||
#ifdef HAVE_MNTENT_H
|
||||
return ntfs_check_mntent(file, mnt_flags);
|
||||
return ntfs_mntent_check(file, mnt_flags);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_version_supported - check if NTFS version is supported.
|
||||
* ntfs_version_is_supported - check if NTFS version is supported.
|
||||
* @vol: ntfs volume whose version we're interested in.
|
||||
*
|
||||
* The function checks if the NTFS volume version is known or not.
|
||||
|
@ -890,7 +893,7 @@ int ntfs_check_if_mounted(const char *file, unsigned long *mnt_flags)
|
|||
* ENOTSUP Unknown NTFS versions
|
||||
* EINVAL Invalid argument
|
||||
*/
|
||||
int ntfs_is_version_supported(ntfs_volume *vol)
|
||||
int ntfs_version_is_supported(ntfs_volume *vol)
|
||||
{
|
||||
u8 major, minor;
|
||||
|
||||
|
@ -916,7 +919,7 @@ int ntfs_is_version_supported(ntfs_volume *vol)
|
|||
}
|
||||
|
||||
/**
|
||||
* ntfs_reset_logfile - "empty" $LogFile data attribute value
|
||||
* ntfs_logfile_reset - "empty" $LogFile data attribute value
|
||||
* @vol: ntfs volume whose $LogFile we intend to reset.
|
||||
*
|
||||
* Fill the value of the $LogFile data attribute, i.e. the contents of
|
||||
|
@ -929,7 +932,7 @@ int ntfs_is_version_supported(ntfs_volume *vol)
|
|||
*
|
||||
* On error, return -1 with errno set to the error code.
|
||||
*/
|
||||
int ntfs_reset_logfile(ntfs_volume *vol)
|
||||
int ntfs_logfile_reset(ntfs_volume *vol)
|
||||
{
|
||||
ntfs_inode *ni;
|
||||
ntfs_attr *na;
|
||||
|
@ -942,7 +945,7 @@ int ntfs_reset_logfile(ntfs_volume *vol)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if ((ni = ntfs_open_inode(vol, FILE_LogFile)) == NULL) {
|
||||
if ((ni = ntfs_inode_open(vol, FILE_LogFile)) == NULL) {
|
||||
Dperror("Failed to open inode FILE_LogFile.\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -1000,7 +1003,7 @@ int ntfs_reset_logfile(ntfs_volume *vol)
|
|||
}
|
||||
|
||||
ntfs_attr_close(na);
|
||||
return ntfs_close_inode(ni);
|
||||
return ntfs_inode_close(ni);
|
||||
|
||||
io_error_exit:
|
||||
eo = errno;
|
||||
|
@ -1008,13 +1011,13 @@ io_error_exit:
|
|||
errno = eo;
|
||||
error_exit:
|
||||
eo = errno;
|
||||
ntfs_close_inode(ni);
|
||||
ntfs_inode_close(ni);
|
||||
errno = eo;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_set_volume_flags - set the flags of an ntfs volume
|
||||
* ntfs_volume_set_flags - set the flags of an ntfs volume
|
||||
* @vol: ntfs volume where we set the volume flags
|
||||
* @flags: new flags
|
||||
*
|
||||
|
@ -1023,7 +1026,7 @@ error_exit:
|
|||
*
|
||||
* Return 0 on successful and -1 if not, with errno set to the error code.
|
||||
*/
|
||||
int ntfs_set_volume_flags(ntfs_volume *vol, const u16 flags)
|
||||
int ntfs_volume_set_flags(ntfs_volume *vol, const u16 flags)
|
||||
{
|
||||
MFT_RECORD *m = NULL;
|
||||
ATTR_RECORD *r;
|
||||
|
@ -1050,13 +1053,13 @@ int ntfs_set_volume_flags(ntfs_volume *vol, const u16 flags)
|
|||
}
|
||||
|
||||
/* Get a pointer to the volume information attribute. */
|
||||
ctx = ntfs_get_attr_search_ctx(NULL, m);
|
||||
ctx = ntfs_attr_get_search_ctx(NULL, m);
|
||||
if (!ctx) {
|
||||
Dperror("Failed to allocate attribute search context");
|
||||
goto err_exit;
|
||||
}
|
||||
if (ntfs_lookup_attr(AT_VOLUME_INFORMATION, AT_UNNAMED, 0, 0, 0, NULL, 0,
|
||||
ctx)) {
|
||||
if (ntfs_attr_lookup(AT_VOLUME_INFORMATION, AT_UNNAMED, 0, 0, 0, NULL,
|
||||
0, ctx)) {
|
||||
Dputs("Error: Attribute $VOLUME_INFORMATION was not found in "
|
||||
"$Volume!");
|
||||
goto err_out;
|
||||
|
@ -1091,7 +1094,7 @@ int ntfs_set_volume_flags(ntfs_volume *vol, const u16 flags)
|
|||
|
||||
ret = 0; /* success */
|
||||
err_out:
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
err_exit:
|
||||
if (m)
|
||||
free(m);
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
const char *EXEC_NAME = "dumplog";
|
||||
const char *EXEC_VERSION = "1.0";
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* DumpLog - Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000,2001 Anton Altaparmakov.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
*
|
||||
* This utility will interpret the contents of the journal ($LogFile) specified
|
||||
* on the command line and display the results on stdout. Errors will be output
|
||||
|
@ -111,7 +109,7 @@ int main(int argc, char **argv)
|
|||
/* Valid data length in buffer. */
|
||||
l = min(br, l);
|
||||
/* Check restart area. */
|
||||
if (!is_rstr_recordp(lfd)) {
|
||||
if (!ntfs_is_rstr_recordp(lfd)) {
|
||||
s64 _l;
|
||||
|
||||
for (_l = 0LL; _l < l; _l++)
|
||||
|
@ -128,8 +126,8 @@ int main(int argc, char **argv)
|
|||
rph = (RESTART_PAGE_HEADER*)lfd;
|
||||
lps = le32_to_cpu(rph->log_page_size);
|
||||
pass_loc:
|
||||
if (ntfs_post_read_mst_fixup((NTFS_RECORD*)rph, lps) ||
|
||||
is_baad_record(rph->magic)) {
|
||||
if (ntfs_mst_post_read_fixup((NTFS_RECORD*)rph, lps) ||
|
||||
ntfs_is_baad_record(rph->magic)) {
|
||||
puts("Logfile incomplete multi sector transfer detected! "
|
||||
"Cannot handle this yet!");
|
||||
goto log_file_error;
|
||||
|
@ -212,7 +210,7 @@ rcrd_pass_loc:
|
|||
if ((char*)rcrd_ph + lps > (char*)lfd + l)
|
||||
goto end_of_rcrd_passes;
|
||||
printf("\nLog record page number %i", pass);
|
||||
if (!is_rcrd_record(rcrd_ph->magic)) {
|
||||
if (!ntfs_is_rcrd_record(rcrd_ph->magic)) {
|
||||
for (i = 0; i < lps; i++)
|
||||
if (((char*)rcrd_ph)[i] != (char)-1)
|
||||
break;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* mkntfs - Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
* Copyright (C) 2001-2002 Richard Russon.
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov
|
||||
* Copyright (C) 2001-2002 Richard Russon
|
||||
*
|
||||
* This utility will create an NTFS 1.2 (Windows NT 4.0) volume on a user
|
||||
* specified (block) device.
|
||||
|
@ -925,7 +923,7 @@ void deallocate_scattered_clusters(const runlist *rl)
|
|||
continue;
|
||||
/* Deallocate the current run. */
|
||||
for (j = rl[i].lcn; j < rl[i].lcn + rl[i].length; j++)
|
||||
ntfs_set_bit(lcn_bitmap, j, 0);
|
||||
ntfs_bit_set(lcn_bitmap, j, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -955,7 +953,7 @@ runlist *allocate_scattered_clusters(s64 clusters)
|
|||
while (clusters) {
|
||||
/* Loop in current zone until we run out of free clusters. */
|
||||
for (lcn = opt.mft_zone_end; lcn < end; lcn++) {
|
||||
bit = ntfs_get_and_set_bit(lcn_bitmap, lcn, 1);
|
||||
bit = ntfs_bit_get_and_set(lcn_bitmap, lcn, 1);
|
||||
if (bit)
|
||||
continue;
|
||||
/*
|
||||
|
@ -1031,7 +1029,7 @@ int insert_positioned_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
uchar_t *uname;
|
||||
/*
|
||||
if (base record)
|
||||
lookup_attr();
|
||||
attr_lookup();
|
||||
else
|
||||
*/
|
||||
if (name_len) {
|
||||
|
@ -1047,7 +1045,7 @@ int insert_positioned_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
} else
|
||||
uname = NULL;
|
||||
/* Check if the attribute is already there. */
|
||||
ctx = ntfs_get_attr_search_ctx(NULL, m);
|
||||
ctx = ntfs_attr_get_search_ctx(NULL, m);
|
||||
if (!ctx) {
|
||||
Eprintf("Failed to allocate attribute search context.\n");
|
||||
err = -ENOMEM;
|
||||
|
@ -1058,7 +1056,7 @@ int insert_positioned_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
err = -ENOTSUP;
|
||||
goto err_out;
|
||||
}
|
||||
if (!ntfs_lookup_attr(type, uname, name_len, ic, 0, NULL, 0, ctx)) {
|
||||
if (!ntfs_attr_lookup(type, uname, name_len, ic, 0, NULL, 0, ctx)) {
|
||||
err = -EEXIST;
|
||||
goto err_out;
|
||||
}
|
||||
|
@ -1177,7 +1175,7 @@ int insert_positioned_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
if (bw != val_len)
|
||||
Eprintf("Error writing non-resident attribute value."
|
||||
"\n");
|
||||
err = ntfs_build_mapping_pairs(vol, (s8*)a + hdr_size +
|
||||
err = ntfs_mapping_pairs_build(vol, (s8*)a + hdr_size +
|
||||
((name_len + 7) & ~7), mpa_size, rl);
|
||||
}
|
||||
a->initialized_size = cpu_to_le64(inited_size);
|
||||
|
@ -1192,7 +1190,7 @@ int insert_positioned_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
}
|
||||
err_out:
|
||||
if (ctx)
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
if (uname)
|
||||
free(uname);
|
||||
return err;
|
||||
|
@ -1212,7 +1210,7 @@ int insert_non_resident_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
uchar_t *uname;
|
||||
/*
|
||||
if (base record)
|
||||
lookup_attr();
|
||||
attr_lookup();
|
||||
else
|
||||
*/
|
||||
if (name_len) {
|
||||
|
@ -1228,7 +1226,7 @@ int insert_non_resident_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
} else
|
||||
uname = AT_UNNAMED;
|
||||
/* Check if the attribute is already there. */
|
||||
ctx = ntfs_get_attr_search_ctx(NULL, m);
|
||||
ctx = ntfs_attr_get_search_ctx(NULL, m);
|
||||
if (!ctx) {
|
||||
Eprintf("Failed to allocate attribute search context.\n");
|
||||
err = -ENOMEM;
|
||||
|
@ -1239,7 +1237,7 @@ int insert_non_resident_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
err = -ENOTSUP;
|
||||
goto err_out;
|
||||
}
|
||||
if (!ntfs_lookup_attr(type, uname, name_len, ic, 0, NULL, 0, ctx)) {
|
||||
if (!ntfs_attr_lookup(type, uname, name_len, ic, 0, NULL, 0, ctx)) {
|
||||
err = -EEXIST;
|
||||
goto err_out;
|
||||
}
|
||||
|
@ -1363,7 +1361,7 @@ int insert_non_resident_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
if (bw != val_len)
|
||||
Eprintf("Error writing non-resident attribute value."
|
||||
"\n");
|
||||
err = ntfs_build_mapping_pairs(vol, (s8*)a + hdr_size +
|
||||
err = ntfs_mapping_pairs_build(vol, (s8*)a + hdr_size +
|
||||
((name_len + 7) & ~7), mpa_size, rl);
|
||||
}
|
||||
if (err < 0 || bw != val_len) {
|
||||
|
@ -1377,7 +1375,7 @@ int insert_non_resident_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
}
|
||||
err_out:
|
||||
if (ctx)
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
if (uname && (uname != AT_UNNAMED))
|
||||
free(uname);
|
||||
if (rl)
|
||||
|
@ -1397,7 +1395,7 @@ int insert_resident_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
uchar_t *uname;
|
||||
/*
|
||||
if (base record)
|
||||
lookup_attr();
|
||||
ntfs_attr_lookup();
|
||||
else
|
||||
*/
|
||||
if (name_len) {
|
||||
|
@ -1409,7 +1407,7 @@ int insert_resident_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
} else
|
||||
uname = AT_UNNAMED;
|
||||
/* Check if the attribute is already there. */
|
||||
ctx = ntfs_get_attr_search_ctx(NULL, m);
|
||||
ctx = ntfs_attr_get_search_ctx(NULL, m);
|
||||
if (!ctx) {
|
||||
Eprintf("Failed to allocate attribute search context.\n");
|
||||
err = -ENOMEM;
|
||||
|
@ -1420,7 +1418,7 @@ int insert_resident_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
err = -ENOTSUP;
|
||||
goto err_out;
|
||||
}
|
||||
if (!ntfs_lookup_attr(type, uname, name_len, ic, 0, val, val_len,
|
||||
if (!ntfs_attr_lookup(type, uname, name_len, ic, 0, val, val_len,
|
||||
ctx)) {
|
||||
err = -EEXIST;
|
||||
goto err_out;
|
||||
|
@ -1479,7 +1477,7 @@ int insert_resident_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
memcpy((char*)a + le16_to_cpu(a->value_offset), val, val_len);
|
||||
err_out:
|
||||
if (ctx)
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
if (uname && (uname != AT_UNNAMED))
|
||||
free(uname);
|
||||
return err;
|
||||
|
@ -1538,17 +1536,17 @@ int add_attr_file_name(MFT_RECORD *m, const MFT_REF parent_dir,
|
|||
int i, fn_size;
|
||||
|
||||
/* Check if the attribute is already there. */
|
||||
ctx = ntfs_get_attr_search_ctx(NULL, m);
|
||||
ctx = ntfs_attr_get_search_ctx(NULL, m);
|
||||
if (!ctx) {
|
||||
Eprintf("Failed to allocate attribute search context.\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (ntfs_lookup_attr(AT_STANDARD_INFORMATION, AT_UNNAMED, 0, 0, 0, NULL, 0,
|
||||
if (ntfs_attr_lookup(AT_STANDARD_INFORMATION, AT_UNNAMED, 0, 0, 0, NULL, 0,
|
||||
ctx)) {
|
||||
int eo = errno;
|
||||
Eprintf("BUG: Standard information attribute not present in "
|
||||
"file record\n");
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return -eo;
|
||||
}
|
||||
si = (STANDARD_INFORMATION*)((char*)ctx->attr +
|
||||
|
@ -1557,7 +1555,7 @@ int add_attr_file_name(MFT_RECORD *m, const MFT_REF parent_dir,
|
|||
fn_size = sizeof(FILE_NAME_ATTR) + i;
|
||||
fn = (FILE_NAME_ATTR*)malloc(fn_size);
|
||||
if (!fn) {
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return -errno;
|
||||
}
|
||||
fn->parent_directory = parent_dir;
|
||||
|
@ -1566,7 +1564,7 @@ int add_attr_file_name(MFT_RECORD *m, const MFT_REF parent_dir,
|
|||
fn->last_data_change_time = si->last_data_change_time;
|
||||
fn->last_mft_change_time = si->last_mft_change_time;
|
||||
fn->last_access_time = si->last_access_time;
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
|
||||
fn->allocated_size = cpu_to_le64(allocated_size);
|
||||
fn->data_size = cpu_to_le64(data_size);
|
||||
|
@ -1908,7 +1906,7 @@ int upgrade_to_large_index(MFT_RECORD *m, const char *name,
|
|||
} else
|
||||
uname = NULL;
|
||||
/* Find the index root attribute. */
|
||||
ctx = ntfs_get_attr_search_ctx(NULL, m);
|
||||
ctx = ntfs_attr_get_search_ctx(NULL, m);
|
||||
if (!ctx) {
|
||||
Eprintf("Failed to allocate attribute search context.\n");
|
||||
return -ENOMEM;
|
||||
|
@ -1918,7 +1916,7 @@ int upgrade_to_large_index(MFT_RECORD *m, const char *name,
|
|||
err = -ENOTSUP;
|
||||
goto err_out;
|
||||
}
|
||||
err = ntfs_lookup_attr(AT_INDEX_ROOT, uname, name_len, ic, 0, NULL, 0,
|
||||
err = ntfs_attr_lookup(AT_INDEX_ROOT, uname, name_len, ic, 0, NULL, 0,
|
||||
ctx);
|
||||
if (uname)
|
||||
free(uname);
|
||||
|
@ -1937,7 +1935,7 @@ int upgrade_to_large_index(MFT_RECORD *m, const char *name,
|
|||
re = (INDEX_ENTRY*)re_start;
|
||||
index_block_size = le32_to_cpu(r->index_block_size);
|
||||
memset(bmp, 0, sizeof(bmp));
|
||||
ntfs_set_bit(bmp, 0ULL, 1);
|
||||
ntfs_bit_set(bmp, 0ULL, 1);
|
||||
/* Bitmap has to be at least 8 bytes in size. */
|
||||
err = add_attr_bitmap(m, name, name_len, ic, (char*)&bmp, sizeof(bmp));
|
||||
if (err)
|
||||
|
@ -2009,16 +2007,16 @@ int upgrade_to_large_index(MFT_RECORD *m, const char *name,
|
|||
/* Set VCN pointer to 0LL. */
|
||||
*(VCN*)((char*)re + cpu_to_le16(re->length) - sizeof(VCN)) =
|
||||
cpu_to_le64(0);
|
||||
err = ntfs_pre_write_mst_fixup((NTFS_RECORD*)ia_val, index_block_size);
|
||||
err = ntfs_mst_pre_write_fixup((NTFS_RECORD*)ia_val, index_block_size);
|
||||
if (err) {
|
||||
err = -errno;
|
||||
Eprintf("ntfs_pre_write_mst_fixup() failed in "
|
||||
Eprintf("ntfs_mst_pre_write_fixup() failed in "
|
||||
"upgrade_to_large_index.\n");
|
||||
goto err_out;
|
||||
}
|
||||
err = add_attr_index_alloc(m, name, name_len, ic, (char*)ia_val,
|
||||
index_block_size);
|
||||
ntfs_post_write_mst_fixup((NTFS_RECORD*)ia_val);
|
||||
ntfs_mst_post_write_fixup((NTFS_RECORD*)ia_val);
|
||||
if (err) {
|
||||
// TODO: Remove the added bitmap!
|
||||
// Revert index root from index allocation.
|
||||
|
@ -2028,7 +2026,7 @@ int upgrade_to_large_index(MFT_RECORD *m, const char *name,
|
|||
return 0;
|
||||
err_out:
|
||||
if (ctx)
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
if (ia_val)
|
||||
free(ia_val);
|
||||
return err;
|
||||
|
@ -2759,7 +2757,7 @@ int main(int argc, char **argv)
|
|||
* must be set. This region also encompasses the backup boot sector.
|
||||
*/
|
||||
for (i = opt.nr_clusters; i < lcn_bitmap_byte_size << 3; i++)
|
||||
ntfs_set_bit(lcn_bitmap, (u64)i, 1);
|
||||
ntfs_bit_set(lcn_bitmap, (u64)i, 1);
|
||||
/*
|
||||
* Determine mft_size: 16 mft records or 1 cluster, which ever is
|
||||
* bigger, rounded to multiples of cluster size.
|
||||
|
@ -2796,7 +2794,7 @@ int main(int argc, char **argv)
|
|||
rl_mft_bmp[1].lcn = -1LL;
|
||||
rl_mft_bmp[1].length = 0LL;
|
||||
/* Allocate cluster for mft bitmap. */
|
||||
ntfs_set_bit(lcn_bitmap, (s64)j, 1);
|
||||
ntfs_bit_set(lcn_bitmap, (s64)j, 1);
|
||||
/* If user didn't specify the mft lcn, determine it now. */
|
||||
if (!opt.mft_lcn) {
|
||||
/*
|
||||
|
@ -2846,7 +2844,7 @@ int main(int argc, char **argv)
|
|||
rl_mft[1].length = 0LL;
|
||||
/* Allocate clusters for mft. */
|
||||
for (i = 0; i < j; i++)
|
||||
ntfs_set_bit(lcn_bitmap, opt.mft_lcn + i, 1);
|
||||
ntfs_bit_set(lcn_bitmap, opt.mft_lcn + i, 1);
|
||||
/* Determine mftmirr_lcn (middle of volume). */
|
||||
opt.mftmirr_lcn = (opt.nr_sectors * opt.sector_size >> 1)
|
||||
/ vol->cluster_size;
|
||||
|
@ -2871,7 +2869,7 @@ int main(int argc, char **argv)
|
|||
rl_mftmirr[1].length = 0LL;
|
||||
/* Allocate clusters for mft mirror. */
|
||||
for (i = 0; i < j; i++)
|
||||
ntfs_set_bit(lcn_bitmap, opt.mftmirr_lcn + i, 1);
|
||||
ntfs_bit_set(lcn_bitmap, opt.mftmirr_lcn + i, 1);
|
||||
opt.logfile_lcn = opt.mftmirr_lcn + j;
|
||||
Dprintf("$LogFile logical cluster number = 0x%x\n", opt.logfile_lcn);
|
||||
/* Create runlist for log file. */
|
||||
|
@ -2922,7 +2920,7 @@ int main(int argc, char **argv)
|
|||
rl_logfile[1].length = 0LL;
|
||||
/* Allocate clusters for log file. */
|
||||
for (i = 0; i < j; i++)
|
||||
ntfs_set_bit(lcn_bitmap, opt.logfile_lcn + i, 1);
|
||||
ntfs_bit_set(lcn_bitmap, opt.logfile_lcn + i, 1);
|
||||
/* Create runlist for $Boot. */
|
||||
rl_boot = (runlist *)malloc(2 * sizeof(runlist));
|
||||
if (!rl_boot)
|
||||
|
@ -2940,7 +2938,7 @@ int main(int argc, char **argv)
|
|||
rl_boot[1].length = 0LL;
|
||||
/* Allocate clusters for $Boot. */
|
||||
for (i = 0; i < j; i++)
|
||||
ntfs_set_bit(lcn_bitmap, 0LL + i, 1);
|
||||
ntfs_bit_set(lcn_bitmap, 0LL + i, 1);
|
||||
/* Allocate a buffer large enough to hold the mft. */
|
||||
buf = calloc(1, opt.mft_size);
|
||||
if (!buf)
|
||||
|
@ -3059,7 +3057,7 @@ int main(int argc, char **argv)
|
|||
|
||||
m = (MFT_RECORD*)(buf + i * vol->mft_record_size);
|
||||
m->flags |= MFT_RECORD_IN_USE;
|
||||
ntfs_set_bit(mft_bitmap, 0LL + i, 1);
|
||||
ntfs_bit_set(mft_bitmap, 0LL + i, 1);
|
||||
file_attrs = FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM;
|
||||
if (i == FILE_root) {
|
||||
if (opt.disable_indexing)
|
||||
|
@ -3092,14 +3090,14 @@ int main(int argc, char **argv)
|
|||
if (!err)
|
||||
err = upgrade_to_large_index(m, "$I30", 4, 0, &index_block);
|
||||
if (!err) {
|
||||
ctx = ntfs_get_attr_search_ctx(NULL, m);
|
||||
ctx = ntfs_attr_get_search_ctx(NULL, m);
|
||||
if (!ctx)
|
||||
err_exit("Failed to allocate attribute search "
|
||||
"context: %s\n", strerror(errno));
|
||||
/* There is exactly one file name so this is ok. */
|
||||
if (ntfs_lookup_attr(AT_FILE_NAME, AT_UNNAMED, 0, 0, 0, NULL, 0,
|
||||
if (ntfs_attr_lookup(AT_FILE_NAME, AT_UNNAMED, 0, 0, 0, NULL, 0,
|
||||
ctx)) {
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
err_exit("BUG: $FILE_NAME attribute not found.\n");
|
||||
}
|
||||
a = ctx->attr;
|
||||
|
@ -3107,7 +3105,7 @@ int main(int argc, char **argv)
|
|||
(FILE_NAME_ATTR*)((char*)a +
|
||||
le16_to_cpu(a->value_offset)),
|
||||
le32_to_cpu(a->value_length));
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
}
|
||||
if (err)
|
||||
err_exit("Couldn't create root directory: %s\n",
|
||||
|
@ -3308,7 +3306,7 @@ int main(int argc, char **argv)
|
|||
*/
|
||||
bs->checksum = cpu_to_le32(0);
|
||||
/* Make sure the bootsector is ok. */
|
||||
if (!is_boot_sector_ntfs(bs, opt.verbose > 0 ? 0 : 1))
|
||||
if (!ntfs_boot_sector_is_ntfs(bs, opt.verbose > 0 ? 0 : 1))
|
||||
err_exit("FATAL: Generated boot sector is invalid!\n");
|
||||
err = add_attr_data_positioned(m, NULL, 0, 0, 0, rl_boot, buf2, 8192);
|
||||
if (!err)
|
||||
|
@ -3438,55 +3436,55 @@ bb_err:
|
|||
Vprintf("Syncing root directory index record.\n");
|
||||
m = (MFT_RECORD*)(buf + 5 * vol->mft_record_size);
|
||||
i = 5 * sizeof(uchar_t);
|
||||
ctx = ntfs_get_attr_search_ctx(NULL, m);
|
||||
ctx = ntfs_attr_get_search_ctx(NULL, m);
|
||||
if (!ctx)
|
||||
err_exit("Failed to allocate attribute search context: %s\n",
|
||||
strerror(errno));
|
||||
// FIXME: This should be IGNORE_CASE!
|
||||
if (ntfs_lookup_attr(AT_INDEX_ALLOCATION, I30, 4, 0, 0,
|
||||
if (ntfs_attr_lookup(AT_INDEX_ALLOCATION, I30, 4, 0, 0,
|
||||
NULL, 0, ctx)) {
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
err_exit("BUG: $INDEX_ALLOCATION attribute not found.\n");
|
||||
}
|
||||
a = ctx->attr;
|
||||
rl_index = ntfs_decompress_mapping_pairs(vol, a, NULL);
|
||||
rl_index = ntfs_mapping_pairs_decompress(vol, a, NULL);
|
||||
if (!rl_index) {
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
err_exit("Failed to decompress runlist of $INDEX_ALLOCATION "
|
||||
"attribute.\n");
|
||||
}
|
||||
if (sle64_to_cpu(a->initialized_size) < i) {
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
err_exit("BUG: $INDEX_ALLOCATION attribute too short.\n");
|
||||
}
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
i = sizeof(INDEX_BLOCK) - sizeof(INDEX_HEADER) +
|
||||
le32_to_cpu(index_block->index.allocated_size);
|
||||
err = ntfs_pre_write_mst_fixup((NTFS_RECORD*)index_block, i);
|
||||
err = ntfs_mst_pre_write_fixup((NTFS_RECORD*)index_block, i);
|
||||
if (err)
|
||||
err_exit("ntfs_pre_write_mst_fixup() failed while syncing "
|
||||
err_exit("ntfs_mst_pre_write_fixup() failed while syncing "
|
||||
"root directory index block.\n");
|
||||
lw = ntfs_rlwrite(vol->fd, rl_index, (char*)index_block, i, NULL);
|
||||
if (lw != i)
|
||||
err_exit("Error writing $INDEX_ALLOCATION.\n");
|
||||
/* No more changes to @index_block below here so no need for fixup: */
|
||||
// ntfs_post_write_mst_fixup((NTFS_RECORD*)index_block);
|
||||
// ntfs_mst_post_write_fixup((NTFS_RECORD*)index_block);
|
||||
Vprintf("Syncing $Bitmap.\n");
|
||||
m = (MFT_RECORD*)(buf + 6 * vol->mft_record_size);
|
||||
ctx = ntfs_get_attr_search_ctx(NULL, m);
|
||||
ctx = ntfs_attr_get_search_ctx(NULL, m);
|
||||
if (!ctx)
|
||||
err_exit("Failed to allocate attribute search context: %s\n",
|
||||
strerror(errno));
|
||||
if (ntfs_lookup_attr(AT_DATA, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
if (ntfs_attr_lookup(AT_DATA, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
err_exit("BUG: $DATA attribute not found.\n");
|
||||
}
|
||||
a = ctx->attr;
|
||||
if (a->non_resident) {
|
||||
rl = ntfs_decompress_mapping_pairs(vol, a, NULL);
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
rl = ntfs_mapping_pairs_decompress(vol, a, NULL);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
if (!rl)
|
||||
err_exit("ntfs_decompress_mapping_pairs() failed\n");
|
||||
err_exit("ntfs_mapping_pairs_decompress() failed\n");
|
||||
lw = ntfs_rlwrite(vol->fd, rl, lcn_bitmap,
|
||||
lcn_bitmap_byte_size, NULL);
|
||||
if (lw != lcn_bitmap_byte_size)
|
||||
|
@ -3495,7 +3493,7 @@ bb_err:
|
|||
} else {
|
||||
memcpy((char*)a + le16_to_cpu(a->value_offset), lcn_bitmap,
|
||||
le32_to_cpu(a->value_length));
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
}
|
||||
/*
|
||||
* No need to sync $MFT/$BITMAP as that has never been modified since
|
||||
|
|
|
@ -127,20 +127,20 @@ version_error:
|
|||
"to fix this.\n");
|
||||
goto error_exit;
|
||||
}
|
||||
ctx = ntfs_get_attr_search_ctx(NULL, m);
|
||||
ctx = ntfs_attr_get_search_ctx(NULL, m);
|
||||
if (!ctx) {
|
||||
perror("Failed to allocate attribute search context");
|
||||
goto error_exit;
|
||||
}
|
||||
/* Find the $DATA attribute of the $LogFile. */
|
||||
if (ntfs_lookup_attr(AT_DATA, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
if (ntfs_attr_lookup(AT_DATA, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
fprintf(stderr, "Error: Attribute $DATA was not found in" \
|
||||
"$LogFile!\n");
|
||||
goto log_file_error;
|
||||
}
|
||||
a = ctx->attr;
|
||||
/* Get length of $LogFile contents. */
|
||||
l = get_attribute_value_length(a);
|
||||
l = ntfs_get_attribute_value_length(a);
|
||||
if (!l) {
|
||||
puts("$LogFile has zero length, no need to write to disk.");
|
||||
goto log_file_error;
|
||||
|
@ -152,14 +152,14 @@ version_error:
|
|||
goto log_file_error;
|
||||
}
|
||||
/* Read in the $LogFile into the buffer. */
|
||||
if (l != get_attribute_value(vol, m, a, lfd)) {
|
||||
if (l != ntfs_get_attribute_value(vol, m, a, lfd)) {
|
||||
puts("Amount of data read does not correspond to expected "
|
||||
"length!");
|
||||
free(lfd);
|
||||
goto log_file_error;
|
||||
}
|
||||
/* Check restart area. */
|
||||
if (!is_rstr_recordp(lfd)) {
|
||||
if (!ntfs_is_rstr_recordp(lfd)) {
|
||||
s64 _l;
|
||||
|
||||
for (_l = 0LL; _l < l; _l++)
|
||||
|
@ -176,8 +176,8 @@ version_error:
|
|||
rph = (RESTART_PAGE_HEADER*)lfd;
|
||||
lps = le32_to_cpu(rph->log_page_size);
|
||||
pass_loc:
|
||||
if (ntfs_post_read_mst_fixup((NTFS_RECORD*)rph, lps) ||
|
||||
is_baad_record(rph->magic)) {
|
||||
if (ntfs_mst_post_read_fixup((NTFS_RECORD*)rph, lps) ||
|
||||
ntfs_is_baad_record(rph->magic)) {
|
||||
puts("$LogFile incomplete multi sector transfer detected! "
|
||||
"Cannot handle this yet!");
|
||||
goto log_file_error;
|
||||
|
@ -263,7 +263,7 @@ rcrd_pass_loc:
|
|||
if ((char*)rcrd_ph + lps > (char*)lfd + l)
|
||||
goto end_of_rcrd_passes;
|
||||
printf("\nLog record page number %i", pass);
|
||||
if (!is_rcrd_record(rcrd_ph->magic)) {
|
||||
if (!ntfs_is_rcrd_record(rcrd_ph->magic)) {
|
||||
for (i = 0; i < lps; i++)
|
||||
if (((char*)rcrd_ph)[i] != (char)-1)
|
||||
break;
|
||||
|
@ -356,7 +356,7 @@ final_exit:
|
|||
if (lfd)
|
||||
free(lfd);
|
||||
if (ctx)
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
if (m)
|
||||
free(m);
|
||||
if (vol && ntfs_umount(vol, 0))
|
||||
|
|
|
@ -121,7 +121,7 @@ int main(int argc, char **argv)
|
|||
|
||||
puts("Attempting to correct errors.");
|
||||
|
||||
vol = ntfs_startup_volume(argv[1], 0);
|
||||
vol = ntfs_volume_startup(argv[1], 0);
|
||||
if (!vol) {
|
||||
puts(FAILED);
|
||||
perror("Failed to startup volume");
|
||||
|
@ -190,27 +190,27 @@ int main(int argc, char **argv)
|
|||
else
|
||||
s = "mft record";
|
||||
|
||||
if (is_baad_recordp(m + i * vol->mft_record_size)) {
|
||||
if (ntfs_is_baad_recordp(m + i * vol->mft_record_size)) {
|
||||
puts("FAILED");
|
||||
fprintf(stderr, "$MFT error: Incomplete multi sector "
|
||||
"transfer detected in %s.\nCannot "
|
||||
"handle this yet. )-:\n", s);
|
||||
goto error_exit;
|
||||
}
|
||||
if (!is_mft_recordp(m + i * vol->mft_record_size)) {
|
||||
if (!ntfs_is_mft_recordp(m + i * vol->mft_record_size)) {
|
||||
puts("FAILED");
|
||||
fprintf(stderr, "$MFT error: Invalid mft record for "
|
||||
"%s.\nCannot handle this yet. )-:\n",
|
||||
s);
|
||||
goto error_exit;
|
||||
}
|
||||
if (is_baad_recordp(m2 + i * vol->mft_record_size)) {
|
||||
if (ntfs_is_baad_recordp(m2 + i * vol->mft_record_size)) {
|
||||
puts("FAILED");
|
||||
fprintf(stderr, "$MFTMirr error: Incomplete multi "
|
||||
"sector transfer detected in %s.\n", s);
|
||||
goto error_exit;
|
||||
}
|
||||
if (!is_mft_recordp(m2 + i * vol->mft_record_size)) {
|
||||
if (!ntfs_is_mft_recordp(m2 + i * vol->mft_record_size)) {
|
||||
puts("FAILED");
|
||||
fprintf(stderr, "$MFTMirr error: Invalid mft record "
|
||||
"for %s.\n", s);
|
||||
|
@ -218,7 +218,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
if (memcmp((u8*)m + i * vol->mft_record_size, (u8*)m2 +
|
||||
i * vol->mft_record_size,
|
||||
ntfs_get_mft_record_data_size((MFT_RECORD*)(
|
||||
ntfs_mft_record_get_data_size((MFT_RECORD*)(
|
||||
(u8*)m + i * vol->mft_record_size)))) {
|
||||
if (!done) {
|
||||
done = TRUE;
|
||||
|
@ -255,7 +255,7 @@ mount_ok:
|
|||
/* Check NTFS version is ok for us (in $Volume) */
|
||||
printf("NTFS volume version is %i.%i.\n\n", vol->major_ver,
|
||||
vol->minor_ver);
|
||||
if (ntfs_is_version_supported(vol)) {
|
||||
if (ntfs_version_is_supported(vol)) {
|
||||
fprintf(stderr, "Error: Unknown NTFS version.\n");
|
||||
goto error_exit;
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ mount_ok:
|
|||
/* If NTFS volume version >= 2.0 then set mounted on NT4 flag. */
|
||||
if (vol->major_ver >= 2)
|
||||
flags |= VOLUME_MOUNTED_ON_NT4;
|
||||
if (ntfs_set_volume_flags(vol, flags)) {
|
||||
if (ntfs_volume_set_flags(vol, flags)) {
|
||||
puts(FAILED);
|
||||
fprintf(stderr, "Error setting volume flags.\n");
|
||||
goto error_exit;
|
||||
|
@ -278,7 +278,7 @@ mount_ok:
|
|||
printf("\n");
|
||||
|
||||
printf("Going to empty the journal ($LogFile)... ");
|
||||
if (ntfs_reset_logfile(vol)) {
|
||||
if (ntfs_logfile_reset(vol)) {
|
||||
puts(FAILED);
|
||||
perror("Failed to reset $LogFile");
|
||||
goto error_exit;
|
||||
|
|
|
@ -89,14 +89,14 @@ void get_file_attribute_value(const char *dev, long int i)
|
|||
vol = ntfs_mount(dev, 0);
|
||||
|
||||
mref = (MFT_REF) i;
|
||||
inode = ntfs_open_inode(vol, mref);
|
||||
inode = ntfs_inode_open(vol, mref);
|
||||
|
||||
if (ntfs_file_record_read(vol, mref, &mrec, NULL)) {
|
||||
perror("Error reading file record!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ctx = ntfs_get_attr_search_ctx(inode, mrec);
|
||||
ctx = ntfs_attr_get_search_ctx(inode, mrec);
|
||||
|
||||
// print_file_name_attr(ctx);
|
||||
|
||||
|
@ -122,7 +122,7 @@ void print_standard_information_attr(ntfs_attr_search_ctx *ctx)
|
|||
ATTR_RECORD *attr = NULL;
|
||||
STANDARD_INFORMATION *standard_information_attr = NULL;
|
||||
|
||||
if (ntfs_lookup_attr
|
||||
if (ntfs_attr_lookup
|
||||
(AT_STANDARD_INFORMATION, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
perror("Error looking up $STANDARD_INFORMATION!\n");
|
||||
exit(1);
|
||||
|
@ -163,7 +163,7 @@ void print_file_name_attr(ntfs_attr_search_ctx *ctx)
|
|||
FILE_NAME_ATTR *file_name_attr = NULL;
|
||||
char *file_name;
|
||||
|
||||
if (ntfs_lookup_attr(AT_FILE_NAME, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
if (ntfs_attr_lookup(AT_FILE_NAME, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
perror("Error looking up $FILE_NAME_ATTR!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -154,12 +154,12 @@ void change_label(const char *dev, const unsigned long mnt_flags,
|
|||
"chkdsk to fix this.\n");
|
||||
goto err_out;
|
||||
}
|
||||
ctx = ntfs_get_attr_search_ctx(NULL, mrec);
|
||||
ctx = ntfs_attr_get_search_ctx(NULL, mrec);
|
||||
if (!ctx) {
|
||||
perror("Failed to get attribute search context");
|
||||
goto err_out;
|
||||
}
|
||||
if (ntfs_lookup_attr(AT_VOLUME_NAME, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
if (ntfs_attr_lookup(AT_VOLUME_NAME, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
perror("Lookup of $VOLUME_NAME attribute failed");
|
||||
goto err_out;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* ntfsresize - Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2002 Szabolcs Szakacsits
|
||||
|
@ -312,7 +312,7 @@ void build_lcn_usage_bitmap(ATTR_RECORD *a)
|
|||
if (!a->non_resident)
|
||||
return;
|
||||
|
||||
if (!(rl = ntfs_decompress_mapping_pairs(vol, a, NULL)))
|
||||
if (!(rl = ntfs_mapping_pairs_decompress(vol, a, NULL)))
|
||||
perr_exit("ntfs_decompress_mapping_pairs");
|
||||
|
||||
for (i = 0; rl[i].length; i++) {
|
||||
|
@ -320,7 +320,7 @@ void build_lcn_usage_bitmap(ATTR_RECORD *a)
|
|||
continue;
|
||||
for (j = 0; j < rl[i].length; j++) {
|
||||
u64 k = (u64)rl[i].lcn + j;
|
||||
if (ntfs_get_and_set_bit(lcn_bitmap.bm, k, 1))
|
||||
if (ntfs_bit_get_and_set(lcn_bitmap.bm, k, 1))
|
||||
err_exit("Cluster %lu referenced twice!\n"
|
||||
"You didn't shutdown your Windows"
|
||||
"properly?", k);
|
||||
|
@ -334,16 +334,16 @@ void walk_attributes(MFT_RECORD *mr)
|
|||
{
|
||||
ntfs_attr_search_ctx *ctx;
|
||||
|
||||
if (!(ctx = ntfs_get_attr_search_ctx(NULL, mr)))
|
||||
if (!(ctx = ntfs_attr_get_search_ctx(NULL, mr)))
|
||||
perr_exit("ntfs_get_attr_search_ctx");
|
||||
|
||||
while (!ntfs_walk_attrs(ctx)) {
|
||||
while (!ntfs_attrs_walk(ctx)) {
|
||||
if (ctx->attr->type == AT_END)
|
||||
break;
|
||||
build_lcn_usage_bitmap(ctx->attr);
|
||||
}
|
||||
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
}
|
||||
|
||||
|
||||
|
@ -352,26 +352,26 @@ void get_bitmap_data(ntfs_volume *vol, struct bitmap *bm)
|
|||
ntfs_inode *ni;
|
||||
ntfs_attr_search_ctx *ctx;
|
||||
|
||||
if (!(ni = ntfs_open_inode(vol, (MFT_REF)FILE_Bitmap)))
|
||||
if (!(ni = ntfs_inode_open(vol, (MFT_REF)FILE_Bitmap)))
|
||||
perr_exit("ntfs_open_inode");
|
||||
|
||||
if (!(ctx = ntfs_get_attr_search_ctx(ni, NULL)))
|
||||
if (!(ctx = ntfs_attr_get_search_ctx(ni, NULL)))
|
||||
perr_exit("ntfs_get_attr_search_ctx");
|
||||
|
||||
if (ntfs_lookup_attr(AT_DATA, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx))
|
||||
if (ntfs_attr_lookup(AT_DATA, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx))
|
||||
perr_exit("ntfs_lookup_attr");
|
||||
|
||||
/* FIXME: get_attribute_value_length() can't handle extents */
|
||||
bm->size = get_attribute_value_length(ctx->attr);
|
||||
bm->size = ntfs_get_attribute_value_length(ctx->attr);
|
||||
|
||||
if (!(bm->bm = (u8 *)malloc(bm->size)))
|
||||
perr_exit("get_bitmap_data");
|
||||
|
||||
if (get_attribute_value(vol, ni->mrec, ctx->attr, bm->bm) != bm->size)
|
||||
if (ntfs_get_attribute_value(vol, ni->mrec, ctx->attr, bm->bm) != bm->size)
|
||||
perr_exit("Couldn't get $Bitmap $DATA\n");
|
||||
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_close_inode(ni);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
ntfs_inode_close(ni);
|
||||
}
|
||||
|
||||
|
||||
|
@ -453,7 +453,7 @@ void advise_on_resize()
|
|||
int fragmanted_end;
|
||||
|
||||
for (i = vol->nr_clusters - 1; i > 0; i--)
|
||||
if (ntfs_get_bit(lcn_bitmap.bm, i))
|
||||
if (ntfs_bit_get(lcn_bitmap.bm, i))
|
||||
break;
|
||||
|
||||
i += 2; /* first free + we reserve one for the backup boot sector */
|
||||
|
@ -495,9 +495,9 @@ void look_for_bad_sector(ATTR_RECORD *a)
|
|||
runlist *rl;
|
||||
int i;
|
||||
|
||||
rl = ntfs_decompress_mapping_pairs(vol, a, NULL);
|
||||
rl = ntfs_mapping_pairs_decompress(vol, a, NULL);
|
||||
if (!rl)
|
||||
perr_exit("ntfs_decompress_mapping_pairs");
|
||||
perr_exit("ntfs_mapping_pairs_decompress");
|
||||
|
||||
for (i = 0; rl[i].length; i++)
|
||||
if (rl[i].lcn != LCN_HOLE)
|
||||
|
@ -522,7 +522,7 @@ void rl_set(runlist *rl, VCN vcn, LCN lcn, s64 len)
|
|||
void bitmap_file_data_fixup(s64 cluster, struct bitmap *bm)
|
||||
{
|
||||
for (; cluster < bm->size << 3; cluster++)
|
||||
ntfs_set_bit(bm->bm, (u64)cluster, 1);
|
||||
ntfs_bit_set(bm->bm, (u64)cluster, 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -551,7 +551,7 @@ void truncate_badclust_bad_attr(ATTR_RECORD *a, s64 nr_clusters)
|
|||
if (!(mp = (char *)calloc(1, mp_size)))
|
||||
perr_exit("Couldn't get memory");
|
||||
|
||||
if (ntfs_build_mapping_pairs(vol, mp, mp_size, rl_bad))
|
||||
if (ntfs_mapping_pairs_build(vol, mp, mp_size, rl_bad))
|
||||
exit(1);
|
||||
|
||||
memcpy((char *)a + a->mapping_pairs_offset, mp, mp_size);
|
||||
|
@ -581,8 +581,8 @@ void truncate_bitmap_unnamed_attr(ATTR_RECORD *a, s64 nr_clusters)
|
|||
bm_bsize = nr_clusters_to_bitmap_byte_size(nr_clusters);
|
||||
nr_bm_clusters = rounded_up_division(bm_bsize, vol->cluster_size);
|
||||
|
||||
if (!(rl = ntfs_decompress_mapping_pairs(vol, a, NULL)))
|
||||
perr_exit("ntfs_decompress_mapping_pairs");
|
||||
if (!(rl = ntfs_mapping_pairs_decompress(vol, a, NULL)))
|
||||
perr_exit("ntfs_mapping_pairs_decompress");
|
||||
|
||||
/* Unallocate truncated clusters in $Bitmap */
|
||||
for (i = 0; rl[i].length; i++) {
|
||||
|
@ -595,7 +595,7 @@ void truncate_bitmap_unnamed_attr(ATTR_RECORD *a, s64 nr_clusters)
|
|||
for (j = 0; j < rl[i].length; j++)
|
||||
if (rl[i].vcn + j >= nr_bm_clusters) {
|
||||
u64 k = (u64)rl[i].lcn + j;
|
||||
ntfs_set_bit(lcn_bitmap.bm, k, 0);
|
||||
ntfs_bit_set(lcn_bitmap.bm, k, 0);
|
||||
Dprintf("Unallocate cluster: "
|
||||
"%llu (%llx)\n", k, k);
|
||||
}
|
||||
|
@ -631,7 +631,7 @@ void truncate_bitmap_unnamed_attr(ATTR_RECORD *a, s64 nr_clusters)
|
|||
if (!(mp = (char *)calloc(1, mp_size)))
|
||||
perr_exit("Couldn't get memory");
|
||||
|
||||
if (ntfs_build_mapping_pairs(vol, mp, mp_size, rl))
|
||||
if (ntfs_mapping_pairs_build(vol, mp, mp_size, rl))
|
||||
exit(1);
|
||||
|
||||
memcpy((char *)a + a->mapping_pairs_offset, mp, mp_size);
|
||||
|
@ -651,13 +651,13 @@ void lookup_data_attr(MFT_REF mref, char *aname, ntfs_attr_search_ctx **ctx)
|
|||
uchar_t *ustr = NULL;
|
||||
int len = 0;
|
||||
|
||||
if (!(ni = ntfs_open_inode(vol, mref)))
|
||||
if (!(ni = ntfs_inode_open(vol, mref)))
|
||||
perr_exit("ntfs_open_inode");
|
||||
|
||||
if (NInoAttrList(ni))
|
||||
perr_exit("Attribute list attribute not yet supported");
|
||||
|
||||
if (!(*ctx = ntfs_get_attr_search_ctx(ni, NULL)))
|
||||
if (!(*ctx = ntfs_attr_get_search_ctx(ni, NULL)))
|
||||
perr_exit("ntfs_get_attr_search_ctx");
|
||||
|
||||
if (aname && ((len = ntfs_mbstoucs(aname, &ustr, 0)) == -1))
|
||||
|
@ -668,7 +668,7 @@ void lookup_data_attr(MFT_REF mref, char *aname, ntfs_attr_search_ctx **ctx)
|
|||
len = 0;
|
||||
}
|
||||
|
||||
if (ntfs_lookup_attr(AT_DATA, ustr, len, 0, 0, NULL, 0, *ctx))
|
||||
if (ntfs_attr_lookup(AT_DATA, ustr, len, 0, 0, NULL, 0, *ctx))
|
||||
perr_exit("ntfs_lookup_attr");
|
||||
|
||||
if (ustr != AT_UNNAMED)
|
||||
|
@ -701,7 +701,7 @@ void truncate_badclust_file(s64 nr_clusters)
|
|||
perr_exit("Couldn't update $BadClust");
|
||||
|
||||
/* FIXME: clean up API => ntfs_put_attr_search_ctx() also closes ni */
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
}
|
||||
|
||||
|
||||
|
@ -718,7 +718,7 @@ void truncate_bitmap_file(s64 nr_clusters)
|
|||
if (write_mft_record(ctx))
|
||||
perr_exit("Couldn't update $Bitmap");
|
||||
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
}
|
||||
|
||||
|
||||
|
@ -805,7 +805,7 @@ void mount_volume()
|
|||
"please try again (or see -f option).\n");
|
||||
|
||||
printf("NTFS volume version: %d.%d\n", vol->major_ver, vol->minor_ver);
|
||||
if (ntfs_is_version_supported(vol))
|
||||
if (ntfs_version_is_supported(vol))
|
||||
perr_exit("Unknown NTFS version");
|
||||
|
||||
Dprintf("Cluster size : %u\n", vol->cluster_size);
|
||||
|
@ -823,12 +823,12 @@ void prepare_volume_fixup()
|
|||
flags |= VOLUME_MOUNTED_ON_NT4;
|
||||
|
||||
printf("Schedule chkdsk NTFS consistency check at Windows boot time ...\n");
|
||||
if (ntfs_set_volume_flags(vol, flags))
|
||||
if (ntfs_volume_set_flags(vol, flags))
|
||||
perr_exit("Failed to set $Volume dirty");
|
||||
|
||||
printf("Resetting $LogFile ... "
|
||||
"(this might take a while)\n");
|
||||
if (ntfs_reset_logfile(vol))
|
||||
if (ntfs_logfile_reset(vol))
|
||||
perr_exit("Failed to reset $LogFile");
|
||||
}
|
||||
}
|
||||
|
@ -880,7 +880,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
for (i = new_volume_size; i < vol->nr_clusters; i++)
|
||||
if (ntfs_get_bit(lcn_bitmap.bm, (u64)i)) {
|
||||
if (ntfs_bit_get(lcn_bitmap.bm, (u64)i)) {
|
||||
/* FIXME: relocate cluster */
|
||||
advise_on_resize();
|
||||
}
|
||||
|
|
|
@ -736,7 +736,7 @@ ATTR_RECORD * find_attribute (const ATTR_TYPES type, ntfs_attr_search_ctx *ctx)
|
|||
if (!ctx)
|
||||
return NULL;
|
||||
|
||||
if (ntfs_lookup_attr (type, NULL, 0, 0, 0, NULL, 0, ctx) != 0) {
|
||||
if (ntfs_attr_lookup(type, NULL, 0, 0, 0, NULL, 0, ctx) != 0) {
|
||||
Dprintf ("find_attribute didn't find an attribute of type: 0x%02x.\n", type);
|
||||
return NULL; /* None / no more of that type */
|
||||
}
|
||||
|
@ -767,14 +767,14 @@ ATTR_RECORD * find_first_attribute (const ATTR_TYPES type, MFT_RECORD *mft)
|
|||
if (!mft)
|
||||
return NULL;
|
||||
|
||||
ctx = ntfs_get_attr_search_ctx (NULL, mft);
|
||||
ctx = ntfs_attr_get_search_ctx(NULL, mft);
|
||||
if (!ctx) {
|
||||
Eprintf ("Couldn't create a search context.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rec = find_attribute (type, ctx);
|
||||
ntfs_put_attr_search_ctx (ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
if (rec)
|
||||
Dprintf ("find_first_attribute: found attr of type 0x%02x.\n", type);
|
||||
else
|
||||
|
@ -813,7 +813,7 @@ int get_filenames (struct ufile *file)
|
|||
if (!file)
|
||||
return -1;
|
||||
|
||||
ctx = ntfs_get_attr_search_ctx (NULL, file->mft);
|
||||
ctx = ntfs_attr_get_search_ctx (NULL, file->mft);
|
||||
if (!ctx)
|
||||
return -1;
|
||||
|
||||
|
@ -857,7 +857,7 @@ int get_filenames (struct ufile *file)
|
|||
count++;
|
||||
}
|
||||
|
||||
ntfs_put_attr_search_ctx (ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
Dprintf ("File has %d names.\n", count);
|
||||
return count;
|
||||
}
|
||||
|
@ -887,7 +887,7 @@ int get_data (struct ufile *file, ntfs_volume *vol)
|
|||
if (!file)
|
||||
return -1;
|
||||
|
||||
ctx = ntfs_get_attr_search_ctx (NULL, file->mft);
|
||||
ctx = ntfs_attr_get_search_ctx (NULL, file->mft);
|
||||
if (!ctx)
|
||||
return -1;
|
||||
|
||||
|
@ -923,7 +923,7 @@ int get_data (struct ufile *file, ntfs_volume *vol)
|
|||
data->size_vcn = sle64_to_cpu (rec->highest_vcn) + 1;
|
||||
}
|
||||
|
||||
data->runlist = ntfs_decompress_mapping_pairs (vol, rec, NULL);
|
||||
data->runlist = ntfs_mapping_pairs_decompress(vol, rec, NULL);
|
||||
if (!data->runlist) {
|
||||
Dprintf ("Couldn't decompress the data runs\n");
|
||||
}
|
||||
|
@ -935,7 +935,7 @@ int get_data (struct ufile *file, ntfs_volume *vol)
|
|||
count++;
|
||||
}
|
||||
|
||||
ntfs_put_attr_search_ctx (ctx);
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
Dprintf ("File has %d data streams.\n", count);
|
||||
return count;
|
||||
}
|
||||
|
@ -1823,7 +1823,7 @@ int undelete_file (ntfs_volume *vol, long long inode)
|
|||
goto free;
|
||||
}
|
||||
} else {
|
||||
if (ntfs_read_clusters (vol, j, 1, buffer) < 1) {
|
||||
if (ntfs_clusters_read(vol, j, 1, buffer) < 1) {
|
||||
Eprintf ("Read failed: %s\n", strerror (errno));
|
||||
close (fd);
|
||||
goto free;
|
||||
|
|
Loading…
Reference in New Issue