Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/include
In directory usw-pr-cvs1:/tmp/cvs-serv13537/include
Modified Files:
Makefile.am Makefile.in attrib.h bitmap.h bootsect.h disk_io.h
endians.h layout.h list.h logfile.h mft.h ntfs_rec.h ntfsd.h
types.h unistr.h volume.h
Added Files:
mft_old.h
Log Message:
It has been a long time since last commit. At moment have done a lot of work
on mkntfs but also at the moment ntfsfix and ntfsdump_logfile and libntfs are
broken. Basically only mkntfs works and that is not complete either.
--- NEW FILE ---
/*
* $Id: mft_old.h,v 1.1 2001/06/01 02:07:24 antona Exp $
*
* mft.h - Exports for MFT record handling. Part of the Linux-NTFS project.
*
* Copyright (c) 2000,2001 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 MFT_H
#define MFT_H
#include "types.h"
#include "list.h"
#include "support.h"
/**
* get_mft_record_data_size - return number of bytes used in mft record @b
* @b: mft record to get the data size of
*
* Takes the mft record @b and returns the number of bytes used in the record
* or 0 on error (i.e. b is not a valid mft record). Zero is not a valid size
* for an mft record as it at least has to have the MFT_RECORD, thus making the
* minimum size:
* (sizeof(MFT_RECORD) + 7) & ~7 + sizeof(ATTR_TYPES) = 52 bytes
* Aside: The 8-byte alignment and the 4 bytes for the attribute type are needed
* as each mft record has to have a list of attributes even if it only contains
* the attribute $END which doesn't contain anything else apart from it's type.
* Also, you would expect every mft record to contain an update sequence array
* as well but that could in theory be non-existent (don't know if Windows NTFS
* wouldn't view this as corruption in itself though!).
*/
extern __inline__ __u32 get_mft_record_data_size(const MFT_RECORD *b);
/* Mft entry flag bit values */
#define ME_mapped 0
#define ME_dirty 1
#define ME_error 2
#define ME_is_base_record 3
#define ME_attr_list_present 4
#define ME_attr_list_mapped 5
/* bits 6-31 reserved for future use */
#define MftEntryMapped(me) test_bit(ME_mapped, &(me)->m_flags)
#define SetMftEntryMapped(me) set_bit(ME_mapped, &(me)->m_flags)
#define ClearMftEntryMapped(me) clear_bit(ME_mapped, &(me)->m_flags)
#define MftEntryDirty(me) test_bit(ME_dirty, &(me)->m_flags)
#define SetMftEntryDirty(me) set_bit(ME_dirty, &(me)->m_flags)
#define ClearMftEntryDirty(me) clear_bit(ME_dirty, &(me)->m_flags)
#define MftEntryError(me) test_bit(ME_error, &(me)->m_flags)
#define SetMftEntryError(me) set_bit(ME_error, &(me)->m_flags)
#define ClearMftEntryError(me) clear_bit(ME_error, &(me)->m_flags)
#define MftEntryIsBaseRecord(me) test_bit(ME_is_base_record, \
&(me)->m_flags)
#define SetMftEntryIsBaseRecord(me) set_bit(ME_is_base_record, \
&(me)->m_flags)
#define ClearMftEntryIsBaseRecord(me) clear_bit(ME_is_base_record, \
&(me)->m_flags)
#define MftEntryAttrListPresent(me) test_bit(ME_attr_list_present, \
&(me)->m_flags)
#define SetMftEntryAttrListPresent(me) set_bit(ME_attr_list_present, \
&(me)->m_flags)
#define ClearMftEntryAttrListPresent(me) clear_bit(ME_attr_list_present, \
&(me)->m_flags)
#define MftEntryAttrListMapped(me) test_bit(ME_attr_list_mapped, \
&(me)->m_flags)
#define SetMftEntryAttrListMapped(me) set_bit(ME_attr_list_mapped, \
&(me)->m_flags)
#define ClearMftEntryAttrListMapped(me) clear_bit(ME_attr_list_mapped, \
&(me)->m_flags)
/**
* flush_mft_entry - flush a mft_entry to disk
* @me: mft_entry to flush
*
* The mft entry is written to disk (if dirty) and marked clean. It is also
* removed from the dirty list of the volume (if it is on the list).
*
* Return 0 on success and -ERRNO on error. Following failure return values
* are defined:
* -EBADF Mft_entry is corrupt (error flag set).
* -EIO Writing to disk failed.
* -ENOTSUP Tried to write to a sparse mft record. Should never
* happen but if it does there is a bug. See implementation
* of flush_mft_entry() in mft.c for details.
* -EPERM Tried to write to cluster 0, which would overwrite the
* bootsector. There must be a bug somewhere...
* others Error codes returned by vcn_to_lcn() function; meaning
* we couldn't locate the position on disk for the entry.
*/
int flush_mft_entry(mft_entry *me);
/* Internal use only. Use set_mft_entry_dirty() instead. */
void __set_mft_entry_dirty(mft_entry *m);
/**
* set_mft_entry_dirty - set an mft entry dirty
* @m: mft entry to set dirty
*
* If the mft entry @m is not dirty it is added to the dirty_mft_entries list
* of the volume to which @m belongs and the dirty flag of the entry is set.
*
* Return true on success or false on error.
*
* If setting the mft entry dirty fails, we try to flush it to disk and make
* it clean to avoid problems. If this succeeds, return true, and not false.
*
* If false is returned, this means that we couldn't set the mft entry dirty
* and we also couldn't flush it to disk to make it clean again. This means
* that the caller has to make sure that the contents are not lost, which they
* would be normally, unless a subsequent call to set_mft_entry_dirty() or
* flush_mft_entry() succeeds.
*/
static __inline__ BOOL set_mft_entry_dirty(mft_entry *m)
{
if (test_and_set_bit(ME_dirty, &m->m_flags) ||
__set_mft_entry_dirty(m))
return TRUE;
return flush_mft_entry(m) == 0;
}
/**
* map_mft_entry - map an mft entry into memory
* @me: mft entry to map
*
* Increase the use count of the entry @me and map it into memory (if it is not
* mapped).
*
* Return 0 on success or -ERRNO on error. See __map_mft_entry() for more
* details on the returned error codes.
*/
static __inline__ int map_mft_entry(mft_entry *me)
{
me->m_count++;
if (MftEntryMapped(me))
return 0;
return __map_mft_entry(me);
}
/**
* unmap_mft_entry - unmap an mft entry
* @me: mft entry to unmap
*
* Decrease the use count of the mft entry (only if it is above 0). Do not
* actually unmap it. We always keep it cached in memory. However, when we
* have unmapped it and the count has reached zero, the entry can be safely
* unmapped if it is necessary but that happens elsewhere.
*/
static __inline__ void unmap_mft_entry(mft_entry *me)
{
if (MftEntryMapped(me) && me->m_count > 0)
me->m_count--;
}
/**
* __unmap_mft_entry - unmap an mft entry
* @me: mft entry to unmap
*
* Unmap the mft entry (only if use count is 0) and free all used memory.
*
* Return zero on success or -ERRNO on error. On error, the following values
* are returned:
* -EBUSY Use count is above zero or couldn't sync dirty entry.
* others Values returned by flush_mft_entry().
*/
int __unmap_mft_entry(mft_entry *me);
/**
* insert_mft_entry - insert a mft_entry into a volume
* @vol: volume to insert into
* @me: mft_entry to insert (see notes)
* @mref: mft reference the mft_entry will have
* @mrec: loaded MFT_RECORD corresponding to @mref (optional)
* @dirty: true if @mrec is dirty, false otherwise (only if @mrec present)
* @f: file associated with the mft_entry (optional)
*
* Initialize the mft_entry with the values of @mref, @f, @mrec and @dirty and
* insert it into the volume @vol. If @mrec is not present, the mft record
* corresponding to @mref is loaded from the volume.
*
* If *@me is NULL, a new mft_entry will be allocated and returned in *@me.
*
* Return 0 on success and -ERRNO on error. On error, the following values are
* returned:
* -EEXIST Entry alread exists in the volume. There must be a bug
* somewhere. This should _really_ never happen.
* others Values returned by flush_mft_entry.
*/
int insert_mft_entry(ntfs_volume *vol, mft_entry **me, const MFT_REF mref,
MFT_RECORD *mrec, const BOOL dirty, ntfs_file *f);
/**
* remove_mft_entry - remove a mft_entry from its volume and free it
* @me: mft_entry to remove and free
*
* Remove the mft entry @me from its volume, flush it to disk if necessary,
* and finally free all memory that was used by the entry including the entry
* itself. Note, the mft entry must have a use count of zero.
*
* Return 0 on success and -ERRNO on error. The defined error codes are:
* -EBUSY The use count of the entry is above 0.
* others Values returned by flush_mft_entry.
*/
int remove_mft_entry(mft_entry *me);
/**
* __remove_all_extension_records_from_ntfs_file - as name
* @f: ntfs_file on which to operate
*
* Remove all extension records from ntfs_file @f. Return 0 on success and
* -errno on error.
*/
int __remove_all_extension_records_from_ntfs_file(ntfs_file *f);
/**
* __add_mtf_entry_to_ntfs_file - as name
* @f: ntfs_file to which to add the mft_entry
* @m: mft_entry to add
*
* Add @me to @f. Return 0 on success and -errno on error.
*/
int __add_mtf_entry_to_ntfs_file(ntfs_file *f, mft_entry *me);
/**
* __remove_mft_entry_from_ntfs_file - as name
* @me: mft_entry to remove from its associated file
*
* Remove @me from @me->m_file. This will also remove the file if @me is the
* base mft record of @me->m_file. The file has to be closed for anything to
* happen. Return 0 on success and -errno on error.
*/
int __remove_mft_entry_from_ntfs_file(mft_entry *me);
/**
* remove_closed_ntfs_file - remove closed ntfs_file from its volume
* @f: file to remove
*
* Remove @f from @f->f_vol. @f has to be closed. Return 0 on success and
* -errno on error.
*/
int remove_closed_ntfs_file(ntfs_file *f);
/**
* __insert_open_ntfs_file - insert ntfs_file into volume opening it
* @v: volume to insert the ntfs_file into
* @f: ntfs_file to insert
* @m: base mft record to associate with the ntfs_file
*
* Adds @f to @v (as an open file) and vice versa. Same for @f and @m. Makes
* sure @m is mapped. Return 0 on success and -errno on error.
*/
int __insert_open_ntfs_file(ntfs_volume *v, ntfs_file *f, mft_entry *m);
int ntfs_close(ntfs_file *f);
#endif /* defined MFT_H */
Index: Makefile.am
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -U2 -r1.5 -r1.6
--- Makefile.am 2001/04/11 11:49:15 1.5
+++ Makefile.am 2001/06/01 02:07:24 1.6
@@ -1,3 +1,10 @@
+# Need this to enable 64-bit (device) file access functions and parameters.
+if DEBUG
+AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -g -DDEBUG
+else
+AM_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
linux_ntfsincludedir = $(includedir)/ntfs
linux_ntfsinclude_HEADERS = \
@@ -10,6 +17,14 @@
mft.h \
ntfs_rec.h \
+ volume.h \
unistr.h \
support.h \
- ntfsd.h
+ ntfsd.h \
+ layout.h \
+ types.h \
+ list.h
+
+EXTRA_DIST = \
+ attrib_RE.h \
+ mft_old.h
Index: Makefile.in
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/Makefile.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -U2 -r1.4 -r1.5
--- Makefile.in 2001/04/11 11:49:15 1.4
+++ Makefile.in 2001/06/01 02:07:24 1.5
@@ -1,3 +1,3 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p1 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
@@ -11,5 +11,7 @@
# PARTICULAR PURPOSE.
+# Need this to enable 64-bit (device) file access functions and parameters.
+
SHELL = @SHELL@
@@ -71,18 +73,28 @@
CXX = @CXX@
DLLTOOL = @DLLTOOL@
+ECHO = @ECHO@
+EXEEXT = @EXEEXT@
LDFLAGS = @LDFLAGS@
LIBTOOL = @LIBTOOL@
+LIBTOOL_DEPS = @LIBTOOL_DEPS@
LN_S = @LN_S@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
+STRIP = @STRIP@
VERSION = @VERSION@
all_includes = @all_includes@
all_libraries = @all_libraries@
+@DEBUG_TRUE@AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -g -DDEBUG
+@DEBUG_FALSE@AM_CFLAGS = -D_FILE_OFFSET_BITS=64
linux_ntfsincludedir = $(includedir)/ntfs
-linux_ntfsinclude_HEADERS = attrib.h bitmap.h bootsect.h disk_io.h endians.h logfile.h mft.h ntfs_rec.h unistr.h support.h ntfsd.h
+linux_ntfsinclude_HEADERS = attrib.h bitmap.h bootsect.h disk_io.h endians.h logfile.h mft.h ntfs_rec.h volume.h unistr.h support.h ntfsd.h layout.h types.h list.h
+
+
+EXTRA_DIST = attrib_RE.h mft_old.h
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
Index: attrib.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/attrib.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -U2 -r1.24 -r1.25
--- attrib.h 2001/04/11 11:49:16 1.24
+++ attrib.h 2001/06/01 02:07:24 1.25
@@ -25,10 +25,87 @@
#define ATTRIB_H
-#include "layout.h"
+#include <asm/atomic.h>
+
#include "types.h"
#include "support.h"
#include "unistr.h"
+/* Attr flag bit values */
+#define AT_mapped 0
+#define AT_dirty 1
+#define AT_error 2
+#define AT_nonresident 3
+#define AT_in_attr_list 4
+#define AT_in_ext_record 5
+ /* bits 6-31 reserved for future use */
+
+#define AttrMapped(a) test_bit(AT_mapped, &(a)->a_flags)
+#define SetAttrMapped(a) set_bit(AT_mapped, &(a)->a_flags)
+#define ClearAttrMapped(a) clear_bit(AT_mapped, &(a)->a_flags)
+
+#define AttrDirty(a) test_bit(AT_dirty, &(a)->a_flags)
+#define SetAttrDirty(a) set_bit(AT_dirty, &(a)->a_flags)
+#define ClearAttrDirty(a) clear_bit(AT_dirty, &(a)->a_flags)
+
+#define AttrError(a) test_bit(AT_error, &(a)->a_flags)
+#define SetAttrError(a) set_bit(AT_error, &(a)->a_flags)
+#define ClearAttrError(a) clear_bit(AT_error, &(a)->a_flags)
+
+#define AttrNonResident(a) test_bit(AT_nonresident, &(a)->a_flags)
+#define SetAttrNonResident(a) set_bit(AT_nonresident, &(a)->a_flags)
+#define ClearAttrNonResident(a) clear_bit(AT_nonresident, &(a)->a_flags)
+
+#define AttrInAttrList(a) test_bit(AT_in_attr_list, &(a)->a_flags)
+#define SetAttrInAttrList(a) set_bit(AT_in_attr_list, &(a)->a_flags)
+#define ClearAttrInAttrList(a) clear_bit(AT_in_attr_list, &(a)->a_flags)
+
+#define AttrInExtRecord(a) test_bit(AT_in_ext_record, &(a)->a_flags)
+#define SetAttrInExtRecord(a) set_bit(AT_in_ext_record, &(a)->a_flags)
+#define ClearAttrInExtRecord(a) clear_bit(AT_in_ext_record, &(a)->a_flags)
+
+int write_non_resident_attr(attr *a);
+
+int flush_attr(attr *a);
+
+BOOL __set_attr_dirty(attr *a);
+
+static __inline__ BOOL set_attr_dirty(attr *a)
+{
+ if (test_and_set_bit(AT_dirty, &a->a_flags) || __set_attr_dirty(a))
+ return TRUE;
+ return flush_attr(a) == 0;
+}
+
+extern __inline__ attr *__allocate_attr(void);
+
+extern __inline__ int __free_attr(attr *a);
+
+int __map_attr_value(attr *me);
+
+static __inline__ int map_attr_value(attr *a)
+{
+ a->a_count++;
+ if (AttrMapped(a))
+ return 0;
+ return __map_attr_val(a);
+}
+
+static __inline__ void unmap_attr_value(attr *a)
+{
+ if (AttrMapped(a) && a->a_count > 0)
+ a->a_count--;
+}
+
+int __unmap_attr_value(attr *a);
+
/**
+ *
+ * Into mft_entry.
+ */
+int insert_attr_in_mft_entry(mft_entry *me, attr **a, const BOOL dirty);
+
+int remove_attr(attr *a);
+
+/**
* decompress_run_list - decompress a mapping pairs array into a run list
* @attr: non-resident attribute whose mapping pairs array to decompress
@@ -40,5 +117,5 @@
* Notes: caller has to free the run_list array when finished.
*/
-run_list decompress_run_list(const ATTR_RECORD *attr);
+run_list *decompress_run_list(const ATTR_RECORD *attr);
/**
@@ -62,7 +139,5 @@
* space allocated for it.
*/
-LCN vcn_to_lcn(const run_list rl, const VCN vcn);
-
-//#include "volume.h"
+LCN vcn_to_lcn(const run_list *rl, const VCN vcn);
/**
@@ -105,12 +180,14 @@
*/
-extern __inline__ BOOL find_first_attr(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,
- attr_search_context *ctx);
-
-BOOL find_attr(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, attr_search_context *ctx);
+extern __inline__ BOOL find_first_attr(const ATTR_TYPES type,
+ const uchar_t *name, const __u32 name_len,
+ const IGNORE_CASE_BOOL ic, const uchar_t *upcase,
+ const __u32 upcase_len, const __u8 *val, const __u32 val_len,
+ attr_search_context *ctx);
+
+BOOL find_attr(const ATTR_TYPES type, const uchar_t *name, const __u32 name_len,
+ const IGNORE_CASE_BOOL ic, const uchar_t *upcase,
+ const __u32 upcase_len, const __u8 *val, const __u32 val_len,
+ attr_search_context *ctx);
/**
Index: bitmap.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/bitmap.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -U2 -r1.6 -r1.7
--- bitmap.h 2001/04/10 22:20:19 1.6
+++ bitmap.h 2001/06/01 02:07:24 1.7
@@ -25,5 +25,5 @@
#define BITMAP_H
-#include <linux/types.h>
+#include "types.h"
/*
@@ -45,6 +45,6 @@
* Set the bit @bit in the @bitmap to @new_value. Ignore all errors.
*/
-extern __inline__ void ntfs_set_bit(__u8 *bitmap, const __u64 bit,
- const __u8 new_value);
+__inline__ void ntfs_set_bit(__u8 *bitmap, const __u64 bit,
+ const __u8 new_value);
/**
@@ -57,4 +57,6 @@
*/
extern __inline__ char ntfs_get_bit(const __u8 *bitmap, const __u64 bit);
+
+extern __inline__ void ntfs_change_bit(__u8 *bitmap, const __u64 bit);
/**
Index: bootsect.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/bootsect.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -U2 -r1.6 -r1.7
--- bootsect.h 2001/04/11 11:49:16 1.6
+++ bootsect.h 2001/06/01 02:07:24 1.7
@@ -26,4 +26,6 @@
#define BOOTSECT_H
+#include "types.h"
+
/* The NTFS oem_id */
#define magicNTFS cpu_to_le64(0x202020205346544e) /* "NTFS " */
@@ -52,8 +54,9 @@
__u8 media_type; /* 0xf8 = hard disk */
__u16 sectors_per_fat; /* zero */
- __u16 sectors_per_track; /* irrelevant */
- __u16 heads; /* irrelevant */
+ __u16 sectors_per_track; /* irrelevant, we set to zero */
+ __u16 heads; /* irrelevant, we set to zero */
__u32 hidden_sectors; /* zero */
__u32 large_sectors; /* zero */
+/* sizeof() = 25 (0x19) bytes */
} __attribute__ ((__packed__)) BIOS_PARAMETER_BLOCK;
@@ -65,6 +68,13 @@
__u64 oem_id; /* Magic "NTFS ". */
BIOS_PARAMETER_BLOCK bpb; /* See BIOS_PARAMETER_BLOCK. */
- __u8 unused[4]; /* zero */
- __s64 number_of_sectors; /* Number of sectors in volume. Gives
+ __u8 unused[4]; /* zero, NTFS diskedit.exe states that
+ this is actually:
+ __u8 physical_drive; // 0x80
+ __u8 current_head; // zero
+ __u8 extended_boot_signature;
+ // 0x80
+ __u8 unused; // zero
+ */
+/*0x28*/__s64 number_of_sectors; /* Number of sectors in volume. Gives
maximum volume size of 2^63 sectors.
Assuming standard sector size of 512
@@ -79,7 +89,8 @@
__s64 volume_serial_number; /* Irrelevant (serial number). */
__u32 checksum; /* Boot sector checksum. */
- __u8 bootstrap[426]; /* Irrelevant (boot up code). */
+/*0x54*/__u8 bootstrap[426]; /* Irrelevant (boot up code). */
__u16 end_of_sector_marker; /* End of bootsector magic. Always is
0xaa55 in little endian. */
+/* sizeof() = 512 (0x200) bytes */
} __attribute__ ((__packed__)) NTFS_BOOT_SECTOR;
Index: disk_io.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/disk_io.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -U2 -r1.8 -r1.9
--- disk_io.h 2001/04/11 14:29:11 1.8
+++ disk_io.h 2001/06/01 02:07:24 1.9
@@ -25,7 +25,4 @@
#define DISK_IO_H
-#include <linux/types.h>
-
-#include "layout.h"
#include "types.h"
@@ -44,5 +41,5 @@
* either lseek, malloc, write or fdatasync. Or errno is EINVAL if b is null.
*/
-__u64 ntfs_pwrite(int fd, const void *b, __u64 count, const __u64 pos);
+__s64 ntfs_pwrite(int fd, const void *b, __s64 count, const __s64 pos);
/**
@@ -60,5 +57,5 @@
* either lseek, malloc, write or fdatasync. Or errno is EINVAL if b is null.
*/
-__u64 mst_pwrite(int fd, const void *b, __u64 count, const __u64 pos);
+__s64 mst_pwrite(int fd, const void *b, __s64 count, const __s64 pos);
/**
@@ -83,6 +80,6 @@
* read some blocks successfully (this is subject to change!!!).
*/
-__u64 ntfs_pread(const int fd, void *b, const __u32 bksize, __u64 count,
- const __u64 pos);
+__s64 ntfs_pread(const int fd, void *b, const __u32 bksize, __s64 count,
+ const __s64 pos);
/**
@@ -115,6 +112,6 @@
* read some blocks successfully (this is subject to change!!!).
*/
-__u64 mst_pread(const int fd, void *b, const __u32 bksize, __u64 count,
- const __u64 pos);
+__s64 mst_pread(const int fd, void *b, const __u32 bksize, __s64 count,
+ const __s64 pos);
/**
@@ -157,6 +154,6 @@
const MFT_REF *mref);
-int read_file_record(const ntfs_volume *vol, const MFT_REF *mref,
- MFT_RECORD **mrec, ATTR_RECORD **attr);
+int __read_file_record(const ntfs_volume *vol, const MFT_REF *mref,
+ MFT_RECORD **mrec, ATTR_RECORD **attr);
/**
Index: endians.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/endians.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -U2 -r1.2 -r1.3
--- endians.h 2001/04/08 03:02:55 1.2
+++ endians.h 2001/06/01 02:07:24 1.3
@@ -38,4 +38,6 @@
#include <asm/byteorder.h>
+#include "types.h"
+
/* Unsigned from LE to CPU conversion. */
Index: layout.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/layout.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -U2 -r1.1 -r1.2
--- layout.h 2001/04/11 11:50:24 1.1
+++ layout.h 2001/06/01 02:07:24 1.2
@@ -25,4 +25,6 @@
#define LAYOUT_H
+#include <sys/types.h>
+#include <linux/types.h>
#include <linux/bitops.h>
@@ -117,18 +119,18 @@
*/
typedef enum {
- FILE_$Mft = 0, /* Master file table (mft). Data attribute
+ FILE_$MFT = 0, /* Master file table (mft). Data attribute
contains the entries and bitmap attribute
records which ones are in use (bit==1). */
- FILE_$MftMirr = 1, /* Mft mirror (copy of first four mft records)
+ FILE_$MFTMirr = 1, /* Mft mirror (copy of first four mft records)
in data attribute. */
FILE_$LogFile = 2, /* Journalling log in data attribute. */
FILE_$Volume = 3, /* Volume name attribute and volume information
attribute (flags and ntfs version). Windows
- refers to this file as volume DASD, no idea
- what that stands for though. */
+ refers to this file as volume DASD (Direct
+ Access Storage Device). */
FILE_$AttrDef = 4, /* Array of attribute definitions in data
attribute. */
FILE_$root = 5, /* Root directory. */
- FILE_$BitMap = 6, /* Allocation bitmap of all clusters (lcns) in
+ FILE_$Bitmap = 6, /* Allocation bitmap of all clusters (lcns) in
data attribute. */
FILE_$Boot = 7, /* Boot sector (always at cluster 0) in data
@@ -138,5 +140,6 @@
FILE_$Secure = 9, /* Shared security descriptors in data attribute
and two indexes into the descriptors.
- Appeared in Windows NT4 SP4 (I think). */
+ Appeared in Windows 2000. Before that, this
+ file was named $Quota but was unused. */
FILE_$UpCase = 10, /* Uppercase equivalents of all 65536 Unicode
characters in data attribute. */
@@ -226,5 +229,5 @@
/*Ofs*/
/* 0*/ NTFS_RECORD; /* Usually the magic is "FILE". */
-/* 8*/ __s64 lsn; /* $LogFile sequence number for this record.
+/* 8*/ __u64 lsn; /* $LogFile sequence number for this record.
Changed every time the record is modified. */
/* 16*/ __u16 sequence_number; /* Number of times this mft record has been
@@ -239,5 +242,5 @@
check the link_count and if it is 1 we
delete the file. Otherwise we delete the
- FILENAME_ATTR being referenced by the
+ FILE_NAME_ATTR being referenced by the
directory entry from the mft record and
decrement the link_count.
@@ -295,22 +298,22 @@
typedef enum {
$UNUSED = cpu_to_le32( 0),
- $STANDARD_INFORMATION = cpu_to_le32( 0x10),
- $ATTRIBUTE_LIST = cpu_to_le32( 0x20),
- $FILENAME = cpu_to_le32( 0x30),
- $OBJECT_ID = cpu_to_le32( 0x40),
- $SECURITY_DESCRIPTOR = cpu_to_le32( 0x50),
- $VOLUME_NAME = cpu_to_le32( 0x60),
+ $STANDARD_INFORMATION = cpu_to_le32( 0x10),
+ $ATTRIBUTE_LIST = cpu_to_le32( 0x20),
+ $FILE_NAME = cpu_to_le32( 0x30),
+ $OBJECT_ID = cpu_to_le32( 0x40),
+ $SECURITY_DESCRIPTOR = cpu_to_le32( 0x50),
+ $VOLUME_NAME = cpu_to_le32( 0x60),
$VOLUME_INFORMATION = cpu_to_le32( 0x70),
$DATA = cpu_to_le32( 0x80),
- $INDEX_ROOT = cpu_to_le32( 0x90),
- $INDEX_ALLOCATION = cpu_to_le32( 0xa0),
- $BITMAP = cpu_to_le32( 0xb0),
+ $INDEX_ROOT = cpu_to_le32( 0x90),
+ $INDEX_ALLOCATION = cpu_to_le32( 0xa0),
+ $BITMAP = cpu_to_le32( 0xb0),
$REPARSE_POINT = cpu_to_le32( 0xc0),
- $EA_INFORMATION = cpu_to_le32( 0xd0),
+ $EA_INFORMATION = cpu_to_le32( 0xd0),
$EA = cpu_to_le32( 0xe0),
- $PROPERTY_SET = cpu_to_le32( 0xf0),
- $LOGGED_UTILITY_STREAM = cpu_to_le32( 0x100),
- $FIRST_USER_DEFINED_ATTRIBUTE = cpu_to_le32( 0x1000),
- $END = cpu_to_le32(0xffffffff),
+ $PROPERTY_SET = cpu_to_le32( 0xf0),
+ $LOGGED_UTILITY_STREAM = cpu_to_le32( 0x100),
+ $FIRST_USER_DEFINED_ATTRIBUTE = cpu_to_le32( 0x1000),
+ $END = cpu_to_le32(0xffffffff),
} ATTR_TYPES;
@@ -345,5 +348,5 @@
where the first byte is
most significant. */
- COLLATION_FILENAME = cpu_to_le32(1), /* Collate file names as
+ COLLATION_FILE_NAME = cpu_to_le32(1), /* Collate file names as
Unicode strings. */
COLLATION_UNICODE_STRING = cpu_to_le32(2), /* Collate Unicode strings
@@ -364,10 +367,9 @@
* definition structure. FIXME: This information is from Regis's information
* and, according to him, it is not certain and probably incomplete.
- * Empirically, it would seem that 0x40 means that it must be resident,
- * 0x01 is never encountered on NT4/W2k, 0x2 would be indexable as only
- * $FILENAME has 0x2 set and no idea what 0x80 means. (AIA)
+ * The INDEXABLE flag is fairly certainly correct as only the file name
+ * attribute has this flag set and this is the only attribute indexed in NT4.
*/
typedef enum {
- INDEXABLE = cpu_to_le32(0x01), /* Attribute can be
+ INDEXABLE = cpu_to_le32(0x02), /* Attribute can be
indexed. */
NEED_TO_REGENERATE = cpu_to_le32(0x40), /* Need to regenerate
@@ -389,5 +391,5 @@
typedef struct {
/*hex ofs*/
-/* 0*/ wchar_t name[64]; /* Unicode name of the attribute. Zero
+/* 0*/ uchar_t name[0x40]; /* Unicode name of the attribute. Zero
terminated. */
/* 80*/ ATTR_TYPES type; /* Type of the attribute. */
@@ -502,5 +504,10 @@
beginning of the name from the attribute
record. Note that the name is stored as a
- Unicode string. */
+ Unicode string. When creating, place offset
+ just at the end of the record header. Then,
+ follow with attribute value or mapping pairs
+ array, resident and non-resident attributes
+ respectively, aligning to an 8-byte
+ boundary. */
/* 12*/ ATTR_FLAGS flags; /* Flags describing the attribute. */
/* 14*/ __u16 instance; /* The instance of this attribute record. This
@@ -514,7 +521,11 @@
/* 20 */ __u16 value_offset; /* Byte offset of the attribute
value from the start of the
- attribute record. */
+ attribute record. When creating,
+ align to 8-byte boundary if we
+ have a name present as this might
+ not have a length of a multiple
+ of 8-bytes. */
/* 22 */ RESIDENT_ATTR_FLAGS resident_flags; /* See above. */
-/* 23 */ __s8 reserved1; /* Reserved/alignment to 8-byte
+/* 23 */ __s8 reservedR; /* Reserved/alignment to 8-byte
boundary. */
} __attribute__ ((__packed__));
@@ -529,6 +540,6 @@
the attribute value. - Usually there is only one
portion, so this usually equals the attribute
- value size in clusters. Can be -1 for zero
- length files. Can be 0 for "single extent"
+ value size in clusters minus 1. Can be -1 for
+ zero length files. Can be 0 for "single extent"
attributes. */
/* 32*/ __u16 mapping_pairs_offset; /* Byte offset from the
@@ -544,5 +555,5 @@
compression unit size to be a power of two
clusters.) WinNT4 only uses a value of 4. */
-/* 35*/ __u8 reserved2[5]; /* Align to 8-byte boundary. */
+/* 35*/ __u8 reserved1[5]; /* Align to 8-byte boundary. */
/* The sizes below are only used when lowest_vcn is zero, as otherwise it would
be difficult to keep them up-to-date.*/
@@ -561,9 +572,11 @@
portion of the attribute value. Usually equals
data_size. */
+/* sizeof(uncompressed attr) = 64*/
/* 64*/ __s64 compressed_size; /* Byte size of the attribute
value after compression. Only present when
- compressed. Always is a multiple of the cluster
- size. Represents the actual amount of disk space
- being used on the disk. */
+ compressed. Always is a multiple of the
+ cluster size. Represents the actual amount of
+ disk space being used on the disk. */
+/* sizeof(compressed attr) = 72*/
} __attribute__ ((__packed__));
} __attribute__ ((__packed__));
@@ -607,5 +620,5 @@
is used to to obtain all flags that are valid for setting. */
- FILE_ATTR_DUP_FILENAME_INDEX_PRESENT = cpu_to_le32(0x10000000),
+ FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT = cpu_to_le32(0x10000000),
/* This is a copy of the corresponding bit from the mft record, telling
us whether this is a directory or not, i.e. whether it has an
@@ -622,5 +635,5 @@
* are the number of 100-nanosecond intervals since 1st January 1601, 00:00:00
* universal coordinated time (UTC). (In Linux time starts 1st January 1970,
- * 00:00:00 UTC and is stored as the numer of 1-second intervals since then.)
+ * 00:00:00 UTC and is stored as the number of 1-second intervals since then.)
*/
@@ -648,13 +661,21 @@
Windows this is only updated when
accessed if some time delta has
- passed since the last update. */
+ passed since the last update. Also,
+ last access times updates can be
+ disabled altogether for speed. */
/* 30*/ FILE_ATTR_FLAGS file_attributes; /* Flags describing the file. */
+/* 34*/ union {
+ /* NTFS 1.2 (and previous, presumably) */
+/* 34 */ __u8 reserved12[14]; /* Reserved/alignment to 8-byte
+ boundary. */
+/* sizeof() = 48 bytes */
+ /* NTFS 3.0 */
+ struct {
/*
- * Following fields are only present in NTFS v3.0+ (i.e. Win2k+). If a volume
- * has been upgraded from a previous NTFS version, then these fields are
- * present only if the file has been accessed since the upgrade. Recognize
- * the difference by comparing the length of the resident attribute value. If
- * it is 48, then the following fields are missing. If it is 72 then the fields
- * are present. Maybe just check like this:
+ * If a volume has been upgraded from a previous NTFS version, then these
+ * fields are present only if the file has been accessed since the upgrade.
+ * Recognize the difference by comparing the length of the resident attribute
+ * value. If it is 48, then the following fields are missing. If it is 72 then
+ * the fields are present. Maybe just check like this:
* if (resident.ValueLength < sizeof(STANDARD_INFORMATION)) {
* Assume NTFS 1.2- format.
@@ -670,36 +691,38 @@
* attributes.
*/
-/* 34*/ __u32 maximum_versions; /* Maximum allowed versions for file. Zero
- means that version numbering is disabled. */
-/* 38*/ __u32 version_number; /* This file's version (if any). Should make
- this zero if maximum_versions is zero. */
-/* 42*/ __u32 class_id; /* Class id from bidirectional class id
- index (?). */
-/* 46*/ __u32 owner_id; /* Owner_id of the user owning the file.
- Translate via $Q index in FILE_$Extend/
- $Quota to the quota control entry for the
- user owning the file. Note: Is zero if
- quotas are disabled. */
-/* 50*/ __u32 security_id; /* Security_id for the file. Translate via
- $SII index and $SDS data stream in
- FILE_$Secure to the security descriptor. */
-/* 54*/ __u64 quota_charged; /* Byte size of the charge to the quota for
- all streams of the file. Note: Is zero if
- quotas are disabled. */
-/* 62*/ __u64 usn; /* Last update sequence number of the file. This
- is a direct index into the change (aka usn)
- journal file. It is zero if the usn journal
- is disabled.
- NOTE: To disable the journal need to delete
- the journal file itself and to then walk the
- whole mft and set all Usn entries in all mft
- records to zero! (This can take a while!)
- The journal is FILE_$Extend/$UsnJrnl. Win2k
- will recreate the journal and initiate
- logging if necessary when mounting the
- partition. This, in contrast to disabling the
- journal is a very fast process, so the user
- won't even notice it. */
-/* sizeof() = 70 bytes */
+ /* 34*/ __u32 maximum_versions; /* Maximum allowed versions for
+ file. Zero if version numbering is disabled. */
+ /* 38*/ __u32 version_number; /* This file's version (if any).
+ Set to zero if maximum_versions is zero. */
+ /* 42*/ __u32 class_id; /* Class id from bidirectional
+ class id index (?). */
+ /* 46*/ __u32 owner_id; /* Owner_id of the user owning
+ the file. Translate via $Q index in FILE_$Extend
+ /$Quota to the quota control entry for the user
+ owning the file. Zero if quotas are disabled. */
+ /* 50*/ __u32 security_id; /* Security_id for the file.
+ Translate via $SII index and $SDS data stream
+ in FILE_$Secure to the security descriptor. */
+ /* 54*/ __u64 quota_charged; /* Byte size of the charge to
+ the quota for all streams of the file. Note: Is
+ zero if quotas are disabled. */
+ /* 62*/ __u64 usn; /* Last update sequence number
+ of the file. This is a direct index into the
+ change (aka usn) journal file. It is zero if
+ the usn journal is disabled.
+ NOTE: To disable the journal need to delete
+ the journal file itself and to then walk the
+ whole mft and set all Usn entries in all mft
+ records to zero! (This can take a while!)
+ The journal is FILE_$Extend/$UsnJrnl. Win2k
+ will recreate the journal and initiate
+ logging if necessary when mounting the
+ partition. This, in contrast to disabling the
+ journal is a very fast process, so the user
+ won't even notice it. */
+ /* 70*/ __u16 reserved30; /* Align to 8-byte boundary. */
+ };
+ };
+/* sizeof() = 72 bytes (NTFS 3.0) */
} __attribute__ ((__packed__)) STANDARD_INFORMATION;
@@ -759,5 +782,5 @@
/* 24*/ __u16 instance; /* If lowest_vcn = 0, the instance of the
attribute being referenced; otherwise 0. */
-/* 26*/ wchar_t name[0]; /* Use when creating only. When reading use
+/* 26*/ uchar_t name[0]; /* Use when creating only. When reading use
name_offset to determine the location of the
name. */
@@ -768,5 +791,5 @@
* The maximum allowed length for a file name.
*/
-#define MAXIMUM_FILENAME_LENGTH 255
+#define MAXIMUM_FILE_NAME_LENGTH 255
/*
@@ -774,5 +797,5 @@
*/
typedef enum {
- FILENAME_POSIX = 0x00,
+ FILE_NAME_POSIX = 0x00,
/* This is the largest namespace. It is case sensitive and
allows all Unicode characters except for: '\0' and '/'.
@@ -781,18 +804,18 @@
standard utilities and thus a "del filename" will delete
both "filename" and "fileName" without warning. */
- FILENAME_WIN32 = 0x01,
+ FILE_NAME_WIN32 = 0x01,
/* The standard WinNT/2k NTFS long filenames. Case insensitive.
All Unicode chars except: '\0', '"', '*', '/', ':', '<',
'>', '?', '\' and '|'. Further, names cannot end with a '.'
or a space. */
- FILENAME_DOS = 0x02,
+ FILE_NAME_DOS = 0x02,
/* The standard DOS filenames (8.3 format). Uppercase only.
All 8-bit characters greater space, except: '"', '*', '+',
',', '/', ':', ';', '<', '=', '>', '?' and '\'. */
- FILENAME_WIN32_AND_DOS = 0x03,
+ FILE_NAME_WIN32_AND_DOS = 0x03,
/* 3 means that both the Win32 and the DOS filenames are
identical and hence have been saved in this single filename
record. */
-} __attribute__ ((__packed__)) FILENAME_TYPE_FLAGS;
+} __attribute__ ((__packed__)) FILE_NAME_TYPE_FLAGS;
/*
@@ -838,9 +861,9 @@
no EAs. */
} __attribute__ ((__packed__));
- __u8 filename_length; /* Length of filename in
+ __u8 file_name_length; /* Length of file name in
(Unicode) characters. */
- FILENAME_TYPE_FLAGS filename_type; /* Namespace of the filename. */
- wchar_t filename[0]; /* Filename in Unicode. */
-} __attribute__ ((__packed__)) FILENAME_ATTR;
+ FILE_NAME_TYPE_FLAGS file_name_type; /* Namespace of the file name.*/
+ uchar_t file_name[0]; /* File name in Unicode. */
+} __attribute__ ((__packed__)) FILE_NAME_ATTR;
/*
@@ -1164,27 +1187,130 @@
*/
typedef enum {
- /* The standard rights. */
+ /*
+ * The specific rights (bits 0 to 15). Depend on the type of the
+ * object being secured by the ACE.
+ */
+
+ /* Specific rights for files and directories are as follows: */
+
+ /* Right to read data from the file. (FILE) */
+ FILE_READ_DATA = cpu_to_le32(0x00000001),
+ /* Right to list contents of a directory. (DIRECTORY) */
+ FILE_LIST_DIRECTORY = cpu_to_le32(0x00000001),
+
+ /* Right to write data to the file. (FILE) */
+ FILE_WRITE_DATA = cpu_to_le32(0x00000002),
+ /* Right to create a file in the directory. (DIRECTORY) */
+ FILE_ADD_FILE = cpu_to_le32(0x00000002),
+
+ /* Right to append data to the file. (FILE) */
+ FILE_APPEND_DATA = cpu_to_le32(0x00000004),
+ /* Right to create a subdirectory. (DIRECTORY) */
+ FILE_ADD_SUBDIRECTORY = cpu_to_le32(0x00000004),
+
+ /* Right to read extended attributes. (FILE/DIRECTORY) */
+ FILE_READ_EA = cpu_to_le32(0x00000008),
+
+ /* Right to write extended attributes. (FILE/DIRECTORY) */
+ FILE_WRITE_EA = cpu_to_le32(0x00000010),
+
+ /* Right to execute a file. (FILE) */
+ FILE_EXECUTE = cpu_to_le32(0x00000020),
+ /* Right to traverse the directory. (DIRECTORY) */
+ FILE_TRAVERSE = cpu_to_le32(0x00000020),
+
+ /*
+ * Right to delete a directory and all the files it contains (its
+ * children), even if the files are read-only. (DIRECTORY)
+ */
+ FILE_DELETE_CHILD = cpu_to_le32(0x00000040),
+
+ /* Right to read file attributes. (FILE/DIRECTORY) */
+ FILE_READ_ATTRIBUTES = cpu_to_le32(0x00000080),
+
+ /* Right to change file attributes. (FILE/DIRECTORY) */
+ FILE_WRITE_ATTRIBUTES = cpu_to_le32(0x00000100),
+
+ /*
+ * The standard rights (bits 16 to 23). Are independent of the type of
+ * object being secured.
+ */
+
+ /* Right to delete the object. */
DELETE = cpu_to_le32(0x00010000),
+
+ /*
+ * Right to read the information in the object's security descriptor,
+ * not including the information in the SACL. I.e. right to read the
+ * security descriptor and owner.
+ */
READ_CONTROL = cpu_to_le32(0x00020000),
+
+ /* Right to modify the DACL in the object's security descriptor. */
WRITE_DAC = cpu_to_le32(0x00040000),
+
+ /* Right to change the owner in the object's security descriptor. */
WRITE_OWNER = cpu_to_le32(0x00080000),
- SYNCHRONIZE = cpu_to_le32(0x00100000),
- STANDARD_RIGHTS_REQUIRED = cpu_to_le32(0x000f0000),
+ /*
+ * Right to use the object for synchronization. Enables a process to
+ * wait until the object is in the signalled state. Some object types
+ * do not support this access right.
+ */
+ SYNCHRONIZE = cpu_to_le32(0x00100000),
+ /*
+ * The following STANDARD_RIGHTS_* are combinations of the above for
+ * convenience and are defined by the Win32 API.
+ */
+
+ /* These are currently defined to READ_CONTROL. */
STANDARD_RIGHTS_READ = cpu_to_le32(0x00020000),
STANDARD_RIGHTS_WRITE = cpu_to_le32(0x00020000),
STANDARD_RIGHTS_EXECUTE = cpu_to_le32(0x00020000),
-
+
+ /* Combines DELETE, READ_CONTROL, WRITE_DAC, and WRITE_OWNER access. */
+ STANDARD_RIGHTS_REQUIRED = cpu_to_le32(0x000f0000),
+
+ /*
+ * Combines DELETE, READ_CONTROL, WRITE_DAC, WRITE_OWNER, and
+ * SYNCHRONIZE access.
+ */
STANDARD_RIGHTS_ALL = cpu_to_le32(0x001f0000),
- /* The access system ACL and maximum allowed access types. */
+ /*
+ * The access system ACL and maximum allowed access types (bits 24 to
+ * 25, bits 26 to 27 are reserved).
+ */
ACCESS_SYSTEM_SECURITY = cpu_to_le32(0x01000000),
MAXIMUM_ALLOWED = cpu_to_le32(0x02000000),
+
+ /*
+ * The generic rights (bits 28 to 31). These map onto the standard and
+ * specific rights.
+ */
- /* The generic rights. */
+ /* Read, write, and execute access. */
GENERIC_ALL = cpu_to_le32(0x10000000),
+
+ /* Execute access. */
GENERIC_EXECUTE = cpu_to_le32(0x20000000),
+
+ /*
+ * Write access. For files, this maps onto:
+ * FILE_APPEND_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_DATA |
+ * FILE_WRITE_EA | STANDARD_RIGHTS_WRITE | SYNCHRONIZE
+ * For directories, the mapping has the same numberical value. See
+ * above for the descriptions of the rights granted.
+ */
GENERIC_WRITE = cpu_to_le32(0x40000000),
+
+ /*
+ * Read access. For files, this maps onto:
+ * FILE_READ_ATTRIBUTES | FILE_READ_DATA | FILE_READ_EA |
+ * STANDARD_RIGHTS_READ | SYNCHRONIZE
+ * For directories, the mapping has the same numberical value. See
+ * above for the descriptions of the rights granted.
+ */
GENERIC_READ = cpu_to_le32(0x80000000),
} ACCESS_MASK;
@@ -1251,4 +1377,5 @@
__u16 ace_count;/* Number of ACEs in the ACL. */
__u16 alignment2;
+/* sizeof() = 8 bytes */
} __attribute__ ((__packed__)) ACL;
@@ -1357,4 +1484,5 @@
SE_DACL_PRESENT is set but dacl is NULL, a NULL ACL
(unconditionally granting access) is specified. */
+/* sizeof() = 0x14 bytes */
} __attribute__ ((__packed__)) SECURITY_DESCRIPTOR_RELATIVE;
@@ -1503,5 +1631,5 @@
*/
typedef struct {
- wchar_t name[0]; /* The name of the volume in Unicode. */
+ uchar_t name[0]; /* The name of the volume in Unicode. */
} __attribute__ ((__packed__)) VOLUME_NAME;
@@ -1603,10 +1731,10 @@
typedef struct {
ATTR_TYPES type; /* Type of the indexed attribute. Is
- $FILENAME for directories, zero
+ $FILE_NAME for directories, zero
for view indexes. No other values
allowed. */
COLLATION_RULES collation_rule; /* Collation rule used to sort the
- index entries. If type is $FILENAME,
- this must be COLLATION_FILENAME. */
+ index entries. If type is $FILE_NAME,
+ this must be COLLATION_FILE_NAME. */
__u32 bytes_per_index_block; /* Byte size of each index block (in
the index allocation attribute). */
@@ -1776,7 +1904,7 @@
if INDEX_ENTRY_END bit in flags is not set. NOTE: On
NTFS versions before 3.0 the only valid key is the
- FILENAME_ATTR. On NTFS 3.0+ the following
+ FILE_NAME_ATTR. On NTFS 3.0+ the following
additional index keys are defined: */
- FILENAME_ATTR filename; /* $I30 index in directories. */
+ FILE_NAME_ATTR filename;/* $I30 index in directories. */
SII_INDEX_KEY sii; /* $SII index in $Secure. */
SDH_INDEX_KEY sdh; /* $SDH index in $Secure. */
Index: list.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/list.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -U2 -r1.2 -r1.3
--- list.h 2001/04/11 15:48:20 1.2
+++ list.h 2001/06/01 02:07:24 1.3
@@ -1,8 +1,8 @@
-#ifndef LIST_H
-#define LIST_H
+#ifndef _NTFS_LIST_H
+#define _NTFS_LIST_H
/*
* Simple doubly linked list implementation. - Copied from Linux kernel
- * 2.4.2-ac18 into Linux-NTFS.
+ * 2.4.2-ac18 into Linux-NTFS (with minor modifications). - AIA
*
* Some of the internal functions ("__xxx") are useful when
Index: logfile.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/logfile.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -U2 -r1.7 -r1.8
--- logfile.h 2001/04/11 11:49:16 1.7
+++ logfile.h 2001/06/01 02:07:24 1.8
@@ -26,5 +26,5 @@
#include "endians.h"
-#include "layout.h"
+#include "types.h"
typedef enum {
Index: mft.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/mft.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -U2 -r1.22 -r1.23
--- mft.h 2001/04/11 14:29:11 1.22
+++ mft.h 2001/06/01 02:07:24 1.23
@@ -25,7 +25,4 @@
#define MFT_H
-#include <linux/bitops.h>
-
-#include "layout.h"
#include "types.h"
#include "list.h"
@@ -51,8 +48,11 @@
/* Mft entry flag bit values */
-#define ME_mapped 0
-#define ME_dirty 1
-#define ME_error 2
- /* bits 3-31 reserved for future use */
+#define ME_mapped 0
+#define ME_dirty 1
+#define ME_error 2
+#define ME_is_base_record 3
+#define ME_attr_list_present 4
+#define ME_attr_list_mapped 5
+ /* bits 6-31 reserved for future use */
#define MftEntryMapped(me) test_bit(ME_mapped, &(me)->m_flags)
@@ -68,281 +68,104 @@
#define ClearMftEntryError(me) clear_bit(ME_error, &(me)->m_flags)
-/**
- * flush_mft_entry - flush a mft_entry to disk
- * @me: mft_entry to flush
- *
- * The mft entry is written to disk (if dirty) and marked clean. It is also
- * removed from the dirty list of the volume (if it is on the list).
- *
- * Return 0 on success and -ERRNO on error. Following failure return values
- * are defined:
- * -EBADF Mft_entry is corrupt (error flag set).
- * -EIO Writing to disk failed.
- * -ENOTSUP Tried to write to a sparse mft record. Should never
- * happen but if it does there is a bug. See implementation
- * of flush_mft_entry() in mft.c for details.
- * -EPERM Tried to write to cluster 0, which would overwrite the
- * bootsector. There must be a bug somewhere...
- * others Error codes returned by vcn_to_lcn() function; meaning
- * we couldn't locate the position on disk for the entry.
- */
-int flush_mft_entry(mft_entry *me);
+#define MftEntryIsBaseRecord(me) test_bit(ME_is_base_record, \
+ &(me)->m_flags)
+#define SetMftEntryIsBaseRecord(me) set_bit(ME_is_base_record, \
+ &(me)->m_flags)
+#define ClearMftEntryIsBaseRecord(me) clear_bit(ME_is_base_record, \
+ &(me)->m_flags)
+
+#define MftEntryAttrListPresent(me) test_bit(ME_attr_list_present, \
+ &(me)->m_flags)
+#define SetMftEntryAttrListPresent(me) set_bit(ME_attr_list_present, \
+ &(me)->m_flags)
+#define ClearMftEntryAttrListPresent(me) clear_bit(ME_attr_list_present, \
+ &(me)->m_flags)
+
+#define MftEntryAttrListMapped(me) test_bit(ME_attr_list_mapped, \
+ &(me)->m_flags)
+#define SetMftEntryAttrListMapped(me) set_bit(ME_attr_list_mapped, \
+ &(me)->m_flags)
+#define ClearMftEntryAttrListMapped(me) clear_bit(ME_attr_list_mapped, \
+ &(me)->m_flags)
+
+extern int ntfs_flush_mft_entry(mft_entry *m);
+
+/* Internal use only. Use ntfs_set_mft_entry_dirty() instead. */
+extern void __ntfs_set_mft_entry_dirty(mft_entry *m);
/**
- * __set_mft_entry_dirty - internal use only, use set_mft_entry_dirty instead
- * @me: mft entry to set dirty
+ * ntfs_set_mft_entry_dirty - set an mft entry dirty
+ * @m: mft entry to set dirty
*
- * Return true on success or false if one of the locks couldn't be acquired.
- *
- * See set_mft_entry_dirty().
+ * If the mft entry @m is not dirty it is added to the dirty_mft_entries list
+ * of the volume to which @m belongs and the dirty flag of the entry is set.
*/
-BOOL __set_mft_entry_dirty(mft_entry *me);
-
-/**
- * set_mft_entry_dirty - set an mft entry dirty
- * @me: mft entry to set dirty
- *
- * If the mft entry @me is not dirty it is added to the dirty_mft_entries list
- * of the volume to which @me belongs and the dirty flag of the entry is set.
- *
- * Return true on success or false on error.
- *
- * If setting the mft entry dirty fails, we try to flush it to disk and make
- * it clean to avoid problems. If this succeeds, return true, and not false.
- *
- * If false is returned, this means that we couldn't set the mft entry dirty
- * and we also couldn't flush it to disk to make it clean again. This means
- * that the caller has to make sure that the contents are not lost, which they
- * would be normally, unless a subsequent call to set_mft_entry_dirty() or
- * flush_mft_entry() succeeds.
- */
-static __inline__ BOOL set_mft_entry_dirty(mft_entry *me)
+static __inline__ void ntfs_set_mft_entry_dirty(mft_entry *m)
{
- if (test_and_set_bit(ME_dirty, &me->m_flags) ||
- __set_mft_entry_dirty(me))
- return TRUE;
- return flush_mft_entry(me) == 0;
+ if (!test_and_set_bit(ME_dirty, &m->m_flags))
+ __ntfs_set_mft_entry_dirty(m);
}
-
-/**
- * __allocate_mft_entry - allocate a new mft_entry and initialize it
- *
- * Return the new mft_entry on success or NULL with errno set to the error
- * code returned from malloc().
- */
-extern __inline__ mft_entry *__allocate_mft_entry(void);
-/**
- * __free_mft_entry - free a mft_entry
- * @me: mft_entry to free
- *
- * Return 0 on success and -EBUSY on error.
- *
- * To succeed, the entry must be unlocked, clean, have a use count of 0, and
- * it must not be mapped. If any of these are false, return -EBUSY.
- */
-extern __inline__ int __free_mft_entry(mft_entry *me);
+/* Internal use only. Use ntfs_map_mft_entry() instead. */
+extern int __ntfs_map_mft_entry(mft_entry *m);
/**
- * __map_mft_entry - map an mft entry into memory
- * @me: mft entry to map
+ * ntfs_map_mft_entry - map an mft entry into memory
+ * @m: mft entry to map
*
- * Map mft entry @me into memory (if unmapped) not increasing the use count.
- *
- * Return 0 on success or -ERRNO on error. If an I/O error of any kind occurs,
- * including multi sector transfer (mst) errors being detected, the error flag
- * is set on the entry.
- *
- * Following failure return values are defined:
- * -EIO Reading from disk failed (or mst error detected). Error
- * flag has been set.
- * -ENOTSUP Tried to read a sparse mft record. Currently not
- * implemented as I am not sure whether this can ever
- * occur.
- * -EPERM Tried to read cluster 0, which would return the
- * bootsector data. There must be a bug somewhere...
- * others Error codes returned by vcn_to_lcn() function; meaning
- * we couldn't locate the position on disk for the entry.
- */
-int __map_mft_entry(mft_entry *me);
-
-/**
- * map_mft_entry - map an mft entry into memory
- * @me: mft entry to map
- *
- * Increase the use count of the entry @me and map it into memory (if it is not
- * mapped).
+ * Increase the use count of the entry @m and map it into memory (if it is not
+ * mapped). This function operates on an already existing mft_entry which has
+ * been inserted in a volume already. It doesn't need to be associated with a
+ * file though. Note that no setting up of the mft_entry is performed or stuff
+ * like that. If you need this kind of stuff chances are you should be using
+ * ntfs_map_file_entry() instead and your probably don't have the mft_entry
+ * yet.
*
- * Return 0 on success or -ERRNO on error. See __map_mft_entry() for more
+ * Return 0 on success and -ERRNO on error. See __map_mft_entry() for more
* details on the returned error codes.
*/
-static __inline__ int map_mft_entry(mft_entry *me)
+static __inline__ int ntfs_map_mft_entry(mft_entry *m)
{
- me->m_count++;
- if (MftEntryMapped(me))
+ int err;
+
+ m->m_count++;
+ if (MftEntryMapped(m))
return 0;
- return __map_mft_entry(me);
+ if ((err = __ntfs_map_mft_entry(m)) < 0)
+ m->m_count--;
+ return err;
}
+extern mft_entry *ntfs_map_file_entry(ntfs_volume *v, const MFT_REF mref);
+
/**
- * unmap_mft_entry - unmap an mft entry
- * @me: mft entry to unmap
+ * ntfs_unmap_mft_entry - unmap an mft entry
+ * @m: mft entry to unmap
*
- * Decrease the use count of the mft entry (only if it is above 0). Do not
+ * Decrease the use count of the mft entry (only if it is above 1). Do not
* actually unmap it. We always keep it cached in memory. However, when we
* have unmapped it and the count has reached zero, the entry can be safely
- * unmapped if it is necessary but that happens elsewhere.
+ * unmapped if it is necessary, but that happens elsewhere.
*/
-static __inline__ void unmap_mft_entry(mft_entry *me)
+static __inline__ void ntfs_unmap_mft_entry(mft_entry *m)
{
- if (MftEntryMapped(me) && me->m_count > 0)
- me->m_count--;
+ if (MftEntryMapped(m) && m->m_count > 1)
+ m->m_count--;
}
-/**
- * __unmap_mft_entry - unmap an mft entry
- * @me: mft entry to unmap
- *
- * Unmap the mft entry (only if use count is 0) and free all used memory.
- *
- * Return zero on success or -ERRNO on error. On error, the following values
- * are returned:
- * -EBUSY Use count is above zero or couldn't sync dirty entry.
- * others Values returned by flush_mft_entry().
- */
-int __unmap_mft_entry(mft_entry *me);
-
-/**
- * insert_mft_entry - insert a mft_entry into a volume
- * @vol: volume to insert into
- * @me: mft_entry to insert (see notes)
- * @mref: mft reference the mft_entry will have
- * @mrec: loaded MFT_RECORD corresponding to @mref (optional)
- * @dirty: true if @mrec is dirty, false otherwise (only if @mrec present)
- * @f: file associated with the mft_entry (optional)
- *
- * Initialize the mft_entry with the values of @mref, @f, @mrec and @dirty and
- * insert it into the volume @vol. If @mrec is not present, the mft record
- * corresponding to @mref is loaded from the volume.
- *
- * If *@me is NULL, a new mft_entry will be allocated and returned in *@me.
- *
- * Return 0 on success and -ERRNO on error. On error, the following values are
- * returned:
- * -EEXIST Entry alread exists in the volume. There must be a bug
- * somewhere. This should _really_ never happen.
- * others Values returned by flush_mft_entry.
- */
-int insert_mft_entry(ntfs_volume *vol, mft_entry **me, const MFT_REF mref,
- MFT_RECORD *mrec, const BOOL dirty, ntfs_file *f);
-
-/**
- * remove_mft_entry - remove a mft_entry from its volume and free it
- * @me: mft_entry to remove and free
- *
- * Remove the mft entry @me from its volume, flush it to disk if necessary,
- * and finally free all memory that was used by the entry including the entry
- * itself. Note, the mft entry must have a use count of zero.
- *
- * Return 0 on success and -ERRNO on error. The defined error codes are:
- * -EBUSY The use count of the entry is above 0.
- * others Values returned by flush_mft_entry.
- */
-int remove_mft_entry(mft_entry *me);
-
/**
- * __allocate_ntfs_file - allocate a new ntfs_file and initialize it
+ * ntfs_unmap_file_entry - unmap a file mft entry
+ * @m: file mft entry to unmap
*
- * Return the new ntfs_file on success or NULL with errno set to the error
- * code returned from malloc().
+ * Same as ntfs_unmap_mft_entry(), so we just wrap it.
*/
-extern __inline__ ntfs_file *__allocate_ntfs_file(void);
-
-/**
- * __free_ntfs_file - free a ntfs_file
- * @f: ntfs_file to free
- *
- * Return 0 on success and -EBUSY on error.
- *
- * To succeed, the file must have a use count of 0, as well as a nr_m_ref of
- * zero. If any of these are false, return -EBUSY.
- */
-extern __inline__ int __free_ntfs_file(ntfs_file *f);
-
-/**
- * __remove_all_extension_records_from_ntfs_file - as name
- * @f: ntfs_file on which to operate
- *
- * Remove all extension records from ntfs_file @f. Return 0 on success and
- * -errno on error.
- */
-int __remove_all_extension_records_from_ntfs_file(ntfs_file *f);
-
-/**
- * __add_mtf_entry_to_ntfs_file - as name
- * @f: ntfs_file to which to add the mft_entry
- * @m: mft_entry to add
- *
- * Add @me to @f. Return 0 on success and -errno on error.
- */
-int __add_mtf_entry_to_ntfs_file(ntfs_file *f, mft_entry *me);
-
-/**
- * __remove_mft_entry_from_ntfs_file - as name
- * @me: mft_entry to remove from its associated file
- *
- * Remove @me from @me->m_file. This will also remove the file if @me is the
- * base mft record of @me->m_file. The file has to be closed for anything to
- * happen. Return 0 on success and -errno on error.
- */
-int __remove_mft_entry_from_ntfs_file(mft_entry *me);
-
-/**
- * remove_closed_ntfs_file - remove closed ntfs_file from its volume
- * @f: file to remove
- *
- * Remove @f from @f->f_vol. @f has to be closed. Return 0 on success and
- * -errno on error.
- */
-int remove_closed_ntfs_file(ntfs_file *f);
-
-/**
- * __insert_open_ntfs_file - insert ntfs_file into volume opening it
- * @v: volume to insert the ntfs_file into
- * @f: ntfs_file to insert
- * @m: base mft record to associate with the ntfs_file
- *
- * Adds @f to @v (as an open file) and vice versa. Same for @f and @m. Makes
- * sure @m is mapped. Return 0 on success and -errno on error.
- */
-int __insert_open_ntfs_file(ntfs_volume *v, ntfs_file *f, mft_entry *m);
+static __inline__ void ntfs_unmap_file_entry(mft_entry *m)
+{
+ ntfs_unmap_mft_entry(m);
+}
-/**
- * ntfs_open_by_mref - open an ntfs file (mft record), given its mft reference
- * @vol: ntfs volume to operate on
- * @mref: mft_reference of base mft record to open
- *
- * Open an ntfs_file (using file to mean any base mft record) given the mft
- * reference of the mft record (i.e. the inode number). To do this, allocate an
- * ntfs_file structure (adding it to the vol->open_files array), or if the file
- * is already loaded, just return that, incrementing the use count.
- *
- * Return a pointer to the ntfs_file structure or NULL on error with errno
- * set to the appropriate error code.
- *
- * This pointer should be treated completely opaquely by the user! Never
- * use it for anything except as a parameter to functions taking a ntfs_file
- * pointer as a parameter.
- */
-ntfs_file *ntfs_open_by_mref(ntfs_volume *vol, const MFT_REF mref);
+extern ntfs_file *ntfs_open_by_mref(ntfs_volume *vol, const MFT_REF mref);
-/**
- * ntfs_close - close an ntfs_file
- * @f: ntfs_file to close
- *
- * Close a previously opened ntfs file. Return zero on success or -errno on
- * error.
- */
-int ntfs_close(ntfs_file *f);
+extern int ntfs_close(ntfs_file *f);
#endif /* defined MFT_H */
Index: ntfs_rec.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/ntfs_rec.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -U2 -r1.6 -r1.7
--- ntfs_rec.h 2001/04/11 11:49:16 1.6
+++ ntfs_rec.h 2001/06/01 02:07:24 1.7
@@ -26,4 +26,5 @@
#define NTFS_REC_H
+#include "types.h"
...
[truncated message content] |