Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/include
In directory usw-pr-cvs1:/tmp/cvs-serv17030
Modified Files:
Makefile.am Makefile.in attrib.h bitmap.h bootsect.h debug.h
disk_io.h layout.h list.h mft.h mst.h support.h types.h
unistr.h volume.h
Removed Files:
mft_old.h
Log Message:
cleanup header files.
Index: Makefile.am
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/Makefile.am,v
retrieving revision 1.8
retrieving revision 1.9
diff -U2 -r1.8 -r1.9
--- Makefile.am 12 Apr 2002 15:23:47 -0000 1.8
+++ Makefile.am 14 Apr 2002 13:56:44 -0000 1.9
@@ -16,13 +16,13 @@
logfile.h \
mft.h \
- ntfs_rec.h \
+ mst.h \
volume.h \
unistr.h \
support.h \
- ntfsd.h \
layout.h \
types.h \
list.h \
- debug.h
+ debug.h \
+ inode.h
# Don't need these distributed.
Index: Makefile.in
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/Makefile.in,v
retrieving revision 1.12
retrieving revision 1.13
diff -U2 -r1.12 -r1.13
--- Makefile.in 12 Apr 2002 15:23:47 -0000 1.12
+++ Makefile.in 14 Apr 2002 13:56:45 -0000 1.13
@@ -109,5 +109,6 @@
types.h \
list.h \
- debug.h
+ debug.h \
+ inode.h
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
Index: attrib.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/attrib.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -U2 -r1.26 -r1.27
--- attrib.h 15 Dec 2001 05:13:08 -0000 1.26
+++ attrib.h 14 Apr 2002 13:56:45 -0000 1.27
@@ -4,5 +4,5 @@
* attrib.h - Exports for attribute 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
@@ -28,80 +28,47 @@
#include "support.h"
#include "unistr.h"
+#include "inode.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) ((a)->a_flags |= 1 << AT_mapped)
-#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);
+typedef enum {
+ LCN_HOLE = -1, /* Keep this as highest value or die! */
+ LCN_RL_NOT_MAPPED = -2,
+ LCN_ENOENT = -3,
+ LCN_EINVAL = -4,
+} LCN_SPECIAL_VALUES;
/**
+ * attr_search_context - used in attribute search functions
+ * @mrec: buffer containing mft record to search
+ * @attr: attribute record in @mrec where to begin/continue search
+ * @is_first: if true lookup_attr() begins search with @attr, else after @attr
*
- * Into mft_entry.
+ * Structure must be initialized to zero before the first call to one of the
+ * attribute search functions. Initialize @mrec to point to the mft record to
+ * search, and @attr to point to the first attribute within @mrec (not necessary
+ * if calling the _first() functions), and set @is_first to TRUE (not necessary
+ * if calling the _first() functions).
+ *
+ * If @is_first is TRUE, the search begins with @attr. If @is_first is FALSE,
+ * the search begins after @attr. This is so that, after the first call to one
+ * of the search attribute functions, we can call the function again, without
+ * any modification of the search context, to automagically get the next
+ * matching attribute.
*/
-int insert_attr_in_mft_entry(mft_entry *me, attr **a, const BOOL dirty);
+typedef struct {
+ MFT_RECORD *mrec;
+ ATTR_RECORD *attr;
+ BOOL is_first;
+ ntfs_inode *ntfs_ino;
+ ATTR_LIST_ENTRY *al_entry;
+ ntfs_inode *base_ntfs_ino;
+ MFT_RECORD *base_mrec;
+ ATTR_RECORD *base_attr;
+} attr_search_context;
+
+extern void reinit_attr_search_ctx(attr_search_context *ctx);
+extern attr_search_context *get_attr_search_ctx(ntfs_inode *ni,
+ MFT_RECORD *mrec);
+extern void put_attr_search_ctx(attr_search_context *ctx);
-int remove_attr(attr *a);
/**
@@ -150,38 +117,8 @@
int set_ntfs_volume_flags(ntfs_volume *v, MFT_RECORD *b, const __u16 flags);
-/**
- * attr_search_context - used in attribute search functions
- * @mrec: buffer containing mft record to search
- * @attr: attribute record in @mrec where to begin/continue search
- * @is_first: if true lookup_attr() begins search with @attr, else after @attr
- *
- * Structure must be initialized to zero before the first call to one of the
- * attribute search functions. If the mft record in which to search has already
- * been loaded into memory, then initialize @mrec to point to it, @attr to
- * point to the first attribute within @mrec, and set @is_first to TRUE.
- *
- * @is_first is only honoured when @mrec is not NULL. Then, if @is_first is
- * TRUE, the search begins with @attr. If @is_first is FALSE, the search begins
- * after @attr. This is so that, after the first call to one of the search
- * attribute functions, we can call the function again, without any
- * modification of the search context, to automagically get the next matching
- * attribute.
- */
-typedef struct {
- MFT_RECORD *mrec;
- ATTR_RECORD *attr;
- BOOL is_first;
-} attr_search_context;
-
/*
* See attrib.c for descriptions of the below functions.
*/
-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,
@@ -217,5 +154,5 @@
*/
__s64 get_attribute_value(const ntfs_volume *vol, const MFT_RECORD *m,
- const ATTR_RECORD *a, __u8 *b);
+ const ATTR_RECORD *a, __u8 *b);
/**
@@ -238,5 +175,5 @@
*/
int set_attribute_value(ntfs_volume *vol, ATTR_RECORD *a,
- const __u8 *b, __s64 l);
+ const __u8 *b, __s64 l);
#endif /* defined ATTRIB_H */
Index: bitmap.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/bitmap.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -U2 -r1.7 -r1.8
--- bitmap.h 1 Jun 2001 02:07:24 -0000 1.7
+++ bitmap.h 14 Apr 2002 13:56:45 -0000 1.8
@@ -4,5 +4,5 @@
* bitmap.h - Exports for bitmap 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
@@ -45,6 +45,15 @@
* Set the bit @bit in the @bitmap to @new_value. Ignore all errors.
*/
-__inline__ void ntfs_set_bit(__u8 *bitmap, const __u64 bit,
- const __u8 new_value);
+static __inline__ void ntfs_set_bit(__u8 *bitmap, const __u64 bit,
+ const __u8 new_value);
+{
+// Dprintf("bitmap %p, bit 0x%Lx, new_value %i\n", bitmap, bit, new_value);
+ if (!bitmap || new_value > 1)
+ return;
+ if (!new_value)
+ bitmap[bit >> 3] &= ~(1 << (bit & 7));
+ else
+ bitmap[bit >> 3] |= (1 << (bit & 7));
+}
/**
@@ -56,7 +65,17 @@
* Return -1 on error.
*/
-extern __inline__ char ntfs_get_bit(const __u8 *bitmap, const __u64 bit);
-
-extern __inline__ void ntfs_change_bit(__u8 *bitmap, const __u64 bit);
+static __inline__ char ntfs_get_bit(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)
+{
+ if (!bitmap)
+ return;
+ bitmap[bit >> 3] ^= 1 << (bit & 7);
+}
/**
@@ -69,6 +88,17 @@
* Return -1 on error.
*/
-extern __inline__ char ntfs_get_and_set_bit(__u8 *bitmap, const __u64 bit,
- const __u8 new_value);
+static __inline__ char ntfs_get_and_set_bit(__u8 *bitmap, const __u64 bit,
+ const __u8 new_value)
+{
+ register __u8 old_bit, shift;
+
+ if (!bitmap || new_value > 1)
+ return -1;
+ shift = bit & 7;
+ old_bit = (bitmap[bit >> 3] >> shift) & 1;
+ if (new_value != old_bit)
+ bitmap[bit >> 3] ^= 1 << shift;
+ return old_bit;
+}
#endif /* defined BITMAP_H */
Index: bootsect.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/bootsect.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -U2 -r1.7 -r1.8
--- bootsect.h 1 Jun 2001 02:07:24 -0000 1.7
+++ bootsect.h 14 Apr 2002 13:56:45 -0000 1.8
@@ -5,5 +5,5 @@
* 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
@@ -106,5 +106,5 @@
* disregarding the value of silent.
*/
-int is_boot_sector_ntfs(const NTFS_BOOT_SECTOR *b, const int silent);
+extern int is_boot_sector_ntfs(const NTFS_BOOT_SECTOR *b, const int silent);
#endif /* defined BOOTSECT_H */
Index: debug.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/debug.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -U2 -r1.1 -r1.2
--- debug.h 12 Apr 2002 15:24:30 -0000 1.1
+++ debug.h 14 Apr 2002 13:56:45 -0000 1.2
@@ -36,28 +36,44 @@
#endif
-/* Verbose output. Currently just same as debug output. */
+/* Debug output to stderr. To get it run ./configure --enable-debug. */
-static inline void Vprintf(const char *fmt, ...)
+static __inline__ void Dprintf(const char *fmt, ...)
{
+ int eo = errno;
va_list ap;
va_start(ap, fmt);
- vprintf(fmt, ap);
+ vfprintf(stderr, fmt, ap);
va_end(ap);
+ errno = eo;
}
-static inline void Vputs(const char *s)
+static __inline__ void Dputs(const char *s)
{
- puts(s);
+ int eo = errno;
+ fprintf(stderr, "%s\n", s);
+ errno = eo;
+}
+
+static __inline__ void Dperror(const char *s)
+{
+ int eo = errno;
+ perror(s);
+ errno = eo;
}
#else
-static inline void Vprintf(const char *fmt, ...)
+static __inline__ void Dprintf(const char *fmt, ...)
+{
+ return;
+}
+
+static __inline__ void Dputs(const char *s)
{
return;
}
-static inline void Vputs(const char *s)
+static __inline__ void Dperror(const char *s)
{
return;
Index: disk_io.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/disk_io.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -U2 -r1.9 -r1.10
--- disk_io.h 1 Jun 2001 02:07:24 -0000 1.9
+++ disk_io.h 14 Apr 2002 13:56:45 -0000 1.10
@@ -4,5 +4,5 @@
* disk_io.h - Exports for disk io. 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
Index: layout.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/layout.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -U2 -r1.16 -r1.17
--- layout.h 15 Dec 2001 05:13:08 -0000 1.16
+++ layout.h 14 Apr 2002 13:56:45 -0000 1.17
@@ -4,5 +4,5 @@
* layout.h - Ntfs on-disk layout structures. 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
@@ -34,4 +34,5 @@
/* 2-byte Unicode character type. */
typedef __u16 uchar_t;
+#define UCHAR_T_SIZE_BITS 1
/*
Index: list.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/list.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -U2 -r1.3 -r1.4
--- list.h 1 Jun 2001 02:07:24 -0000 1.3
+++ list.h 14 Apr 2002 13:56:45 -0000 1.4
@@ -29,10 +29,9 @@
* Insert a new entry between two known consecutive entries.
*
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
+ * This is only for internal list manipulation where we know the prev/next
+ * entries already!
*/
static __inline__ void __list_add(struct list_head * new,
- struct list_head * prev,
- struct list_head * next)
+ struct list_head * prev, struct list_head * next)
{
next->prev = new;
@@ -44,6 +43,6 @@
/**
* list_add - add a new entry
- * @new: new entry to be added
- * @head: list head to add it after
+ * @new: new entry to be added
+ * @head: list head to add it after
*
* Insert a new entry after the specified head.
@@ -57,6 +56,6 @@
/**
* list_add_tail - add a new entry
- * @new: new entry to be added
- * @head: list head to add it before
+ * @new: new entry to be added
+ * @head: list head to add it before
*
* Insert a new entry before the specified head.
@@ -69,12 +68,11 @@
/*
- * Delete a list entry by making the prev/next entries
- * point to each other.
+ * Delete a list entry by making the prev/next entries point to each other.
*
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
+ * This is only for internal list manipulation where we know the prev/next
+ * entries already!
*/
static __inline__ void __list_del(struct list_head * prev,
- struct list_head * next)
+ struct list_head * next)
{
next->prev = prev;
@@ -84,6 +82,8 @@
/**
* list_del - deletes entry from list.
- * @entry: the element to delete from the list.
- * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
+ * @entry: the element to delete from the list.
+ *
+ * Note: list_empty on entry does not return true after this, the entry is in
+ * an undefined state.
*/
static __inline__ void list_del(struct list_head *entry)
@@ -94,5 +94,5 @@
/**
* list_del_init - deletes entry from list and reinitialize it.
- * @entry: the element to delete from the list.
+ * @entry: the element to delete from the list.
*/
static __inline__ void list_del_init(struct list_head *entry)
@@ -104,5 +104,5 @@
/**
* list_empty - tests whether a list is empty
- * @head: the list to test.
+ * @head: the list to test.
*/
static __inline__ int list_empty(struct list_head *head)
@@ -113,8 +113,9 @@
/**
* list_splice - join two lists
- * @list: the new list to add.
- * @head: the place to add it in the first list.
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
*/
-static __inline__ void list_splice(struct list_head *list, struct list_head *head)
+static __inline__ void list_splice(struct list_head *list,
+ struct list_head *head)
{
struct list_head *first = list->next;
@@ -142,5 +143,5 @@
/**
- * list_for_each - iterate over a list
+ * list_for_each - iterate over a list
* @pos: the &struct list_head to use as a loop counter.
* @head: the head for your list.
@@ -148,5 +149,6 @@
#define list_for_each(pos, head) \
for (pos = (head)->next, pos->next; pos != (head); \
- pos = pos->next, pos->next)
+ pos = pos->next, pos->next)
#endif
+
Index: mft.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/mft.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -U2 -r1.25 -r1.26
--- mft.h 14 Apr 2002 13:34:50 -0000 1.25
+++ mft.h 14 Apr 2002 13:56:45 -0000 1.26
@@ -4,5 +4,5 @@
* mft.h - Exports for MFT record 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
Index: mst.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/mst.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -U2 -r1.1 -r1.2
--- mst.h 14 Apr 2002 13:29:42 -0000 1.1
+++ mst.h 14 Apr 2002 13:56:45 -0000 1.2
@@ -2,8 +2,8 @@
* $Id$
*
- * ntfs_rec.h - Exports for NTFS record handling. Part of the Linux-NTFS
- * project.
+ * mst.h - Exports for multi sector transfer fixup functions. 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
@@ -23,6 +23,6 @@
*/
-#ifndef NTFS_REC_H
-#define NTFS_REC_H
+#ifndef MST_H
+#define MST_H
#include "types.h"
@@ -30,9 +30,7 @@
extern int post_read_mst_fixup(NTFS_RECORD *b, const __u32 size);
-
extern int pre_write_mst_fixup(NTFS_RECORD *b, const __u32 size);
-
extern void post_write_mst_fixup(NTFS_RECORD *b);
-#endif /* defined NTFS_REC_H */
+#endif /* defined MST_H */
Index: support.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/support.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -U2 -r1.4 -r1.5
--- support.h 15 Dec 2001 05:13:08 -0000 1.4
+++ support.h 14 Apr 2002 13:56:45 -0000 1.5
@@ -4,5 +4,5 @@
* support.h - Useful definitions and macros. 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
@@ -26,16 +26,4 @@
#include <stddef.h>
-
-/*
- * These are just to make the code more readable...
- */
-typedef enum {
- FALSE = 0,
- NO = 0,
- ZERO = 0,
- TRUE = 1,
- YES = 1,
- ONE = 1,
-} BOOL;
/*
Index: types.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/types.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -U2 -r1.6 -r1.7
--- types.h 15 Dec 2001 05:13:08 -0000 1.6
+++ types.h 14 Apr 2002 13:56:45 -0000 1.7
@@ -5,5 +5,5 @@
* 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
@@ -26,11 +26,12 @@
#define NTFS_TYPES_H
-#include "layout.h"
#include "list.h"
-#include "unistr.h"
+#include "layout.h"
-/*
- * run_list
- * ========
+/**
+ * run_list_element - in memory vcn to lcn mapping array element
+ * @vcn: starting vcn of the current array element
+ * @lcn: starting lcn of the current array element
+ * @length: length in clusters of the current array element
*
* The last vcn (in fact the last vcn + 1) is reached when length == 0.
@@ -38,13 +39,9 @@
* When lcn == -1 this means that the count vcns starting at vcn are not
* physically allocated (i.e. this is a hole / data is sparse).
- *
- * For attribute extents which have the previous_extents flag set, the first
- * entry is a sparse entry (lcn == -1). It is used to get the vcn count up to
- * lowest_vcn for that extent.
*/
typedef struct { /* In memory vcn to lcn mapping structure element. */
VCN vcn; /* vcn = Starting virtual cluster number. */
LCN lcn; /* lcn = Starting logical cluster number. */
- __u64 length; /* Run length in clusters. */
+ __s64 length; /* Run length in clusters. */
} run_list_element;
@@ -52,4 +49,21 @@
/*
+ * These are just to make the code more readable...
+ */
+typedef enum {
+ FALSE = 0,
+ NO = 0,
+ ZERO = 0,
+ TRUE = 1,
+ YES = 1,
+ ONE = 1,
+} BOOL;
+
+typedef enum {
+ CASE_SENSITIVE = 0,
+ IGNORE_CASE = 1,
+} IGNORE_CASE_BOOL;
+
+/*
* Union of all known attribute values. For convenience. Used in the attr
* structure.
@@ -78,338 +92,10 @@
/*
- * Necessary forward definitions and typedefs.
- */
-struct _ntfs_attr;
-typedef struct _ntfs_attr attr;
-
-struct _mft_entry;
-typedef struct _mft_entry mft_entry;
-
-struct _ntfs_file;
-typedef struct _ntfs_file ntfs_file;
-
-struct _ntfs_volume;
-typedef struct _ntfs_volume ntfs_volume;
-
-/**
- * attr - structure describing a mapped attribute
- * @a_rec: attribute record of the attribute
- * @a_flags: flags describing the attribute
- * @a_val: attribute value
- * @a_run_list: run list of the attribute value
- * @a_count: usage count of the attribute
- * @a_dirty_list: anchor for the @a_vol->dirty_attrs linked list
- * @a_vol: volume the attribute belongs to
- * @a_m_entry: mft entry @a_rec is contained in
- * @a_base_m_entry: base mft entry holding the attribute list attribute
- * @a_attr_list_entry: attribute list entry of this attribute
- *
- * @a_rec is the attribute record (ATTR_REC *) of the attribute (and is always
- * valid).
- *
- * The following flags are defined for @a_flags:
- * dirty - Attribute value is dirty. Needs to be written to disk.
- * Only for non_resident attributes. For resident ones
- * the mft entry is set dirty. Note: when the meta data
- * part of the attribute is dirtied the mft record is
- * marked dirty directly. No flag reflects this in the
- * attr structure as it is unnecessary.
- * val_mapped - Attribute value is mapped. If not mapped @a_val and
- * @a_dirty_list are not defined.
- * error - There was some kind of error on I/O so it is possible
- * that one or more of the other fields are corrupt.
- * non_resident - Attribute is not resident. If resident, @a_run_list
- * and @a_dirty_list are not defined.
- * in_attr_list - Attribute is described by the attribute list attribute
- * @a_base_m_entry->m_attr_list, the entry in this is
- * @a_attr_list_entry.
- * in_ext_record - Attribute is described by the attribute list
- * attribute and it is stored in an extension record
- * (pointed to by @a_m_entry) rather than in the base mft
- * record (pointed to by @a_base_m_entry). This only
- * makes sense if in_attr_list is set.
- * previous_extents - Attribute is not the first extent. Only makes sense
- * if in_attr_list is set. Also, if previous_extents is
- * set, this implies in_ext_record is also set.
- * last_extent - Attribute is the last extent. So if there are no
- * previous_extents and this is the last_extent, we know
- * there are no extents at all. Only make sense if
- * in_attr_list is set. Note, we don't keep pointers to
- * the prev/next extents as their attributes are not
- * necessarily mapped.
- *
- * @a_val points to the attribute value of the attribute and will either point
- * into @a_rec (resident attribute) or it will point to a especially for it
- * allocated memory which has to be free()d when the attribute is unmapped.
- * @a_val is only valid when the val_mapped flag is set in @a_flags.
- *
- * It is important to note that @a_val contains only the mapped portion of this
- * extent of the attribute value which is indicated by a lcn >= 0 in the run
- * list.
- *
- * If lcn is -1, @a_val does contain this portion of the value, but it is all
- * zero, and there is no storage allocated for it (it is a sparse run). When
- * writing it to disk, it is checked for being zero again and if it is, the
- * (zero) data is not written to disk, but a sparse entry is saved in the
- * mapping pairs array. If it is not zero, storage is allocated on disk and the
- * data is written. The run list and mapping pairs array is then updated to
- * reflect this and lcn is no longer -1.
- *
- * @a_run_list is only valid if the non_resident flag is set. It will only hold
- * the part of the run list belonging to this extent. If previous_extents is
- * zero and last_extent is set, this is the full run_list as there are no more
- * extents. Should the vcn being looked for not be present in @a_run_list, it
- * should be checked for other extents before returning out of bounds error
- * (check previous_extents/last_extent flags first).
- *
- * Note: If previous_extents is set then the first entry of @a_run_list has a
- * vcn equal to lowest_vcn of this extent. We do NOT have a virtual sparse
- * entry (vcn = 0, lcn = -1, and length = lowest_vcn) at the beginning, unlike
- * the WinNT/2k NTFS drivers. IMO this only makes things more complex instead
- * of easier. If you are familiar with Win NTFS driver this is something to
- * watch out for... (AIA)
- *
- * Note, that @a_run_list may be NULL which means that the run list has not
- * been extracted from @a_rec (yet). This can only happen when the attribute
- * value is not mapped. If val_mapped is set, @a_run_list must be valid.
- *
- * @a_count is the number of times the attribute value has been mapped. When it
- * reaches zero the value may be safely unmapped (after being synced if dirty
- * and hence also non_resident). This can be done at any point in time. Remember
- * we only free() the memory if the attribute is non resident! Once the value is
- * unmapped, it is also safe to free() @a_run_list AND set it to NULL.
- *
- * @a_dirty_list anchors the attribute entry into the dirty_attrs list of
- * @a_vol. Used when syncing the volume to be able to quickly walk all dirty
- * attributes and sync them as well. Only applies to non_resident attributes
- * as resident ones are covered by virtue of being contained inside their
- * mft entries (@a_m_entry) which are dirty and synced to disk, already.
- *
- * @a_vol is the volume the attribute belongs to. This is just so lookups are
- * quicker. Otherwise it could be obtained from @m_entry->m_vol.
- *
- * @a_m_entry points to the mft entry in which the attribute is held. If the
- * attribute is in the base mft record, @a_m_entry is also the base mft record
- * and @a_base_m_entry equals @m_entry (in_ext_record flag is zero). If the
- * attribute is located in an extension mft record, @a_base_m_entry points to
- * the mft entry of the base mft record and the in_ext_record flag is set in
- * @a_flags (implies in_attr_list flag is also set).
- *
- * If in_attr_list is set, @a_base_m_entry points to the mft entry containing
- * the attribute list attribute describing this attribute. The attribute list is
- * obtained from @a_base_m_entry->m_attr_list.
- *
- * If in_attr_list is set, @a_attr_list_entry points to the attribute list entry
- * within the attribute list attribute which describes this attribute.
- *
- * Note, we don't store the file this attribute belongs to, as this information
- * is irrelevant for all intents and purposes and can be obtained from
- * @m_entry->m_file should it be needed at some point.
- */
-struct _ntfs_attr {
- ATTR_RECORD *a_rec;
- unsigned long a_flags;
- attr_val *a_val;
- run_list *a_run_list;
- unsigned int a_count;
- struct list_head a_dirty_list;
- ntfs_volume *a_vol;
- mft_entry *a_m_entry;
- mft_entry *a_base_m_entry;
- ATTR_LIST_ENTRY *a_attr_list_entry;
-};
-
-/**
- * mft_entry - structure describing a loaded mft record
- * @m_rec: mft record of this mft entry
- * @m_flags: flags describing the mft entry
- * @m_ref: mft reference of this mft entry (includes sequence no.)
- * @m_count: usage count of the mft entry
- * @m_mapped_attrs: array of all mapped attributes of this mft entry
- * @nr_mapped_attrs: number of mapped attributes in the @m_mapped_attrs array
- * @m_file: file this mft entry belongs to (or NULL if none)
- * @m_list: anchor for the @m_vol->mft_entries linked list
- * @m_dirty_list: anchor for the @m_vol->dirty_mft_entries linked list
- * @m_vol: volume the mft entry belongs to
- * @m_attr_list: the attribute list value of this (base) mft entry
- *
- * Each loaded mft record is represented by a mft_entry structure.
- *
- * @m_rec is a pointer to the actual MFT_RECORD. Only valid if mapped flag is
- * set.
- *
- * @m_flags is a set of flags describing the mft entry / record. The
- * following flags are defined:
- * mapped - Is the MFT_RECORD actually in memory? (i.e. Is @m_rec
- * valid?)
- * dirty - Does the record need to be written to disk? If not,
- * it is safe to discard @m_rec, but only if @m_count is
- * zero.
- * error - When reading the entry from disk it was detected that
- * it is corrupt. For example, it could be that a multi
- * sector transfer error was detected.
- * is_base_record - Is this mft record a base record?
- * attr_list_present - Set if an attribute list is present in this
- * mft record. This implies that is_base_record
- * is set.
- * attr_list_mapped - Set if the attribute list is mapped. Implies
- * that is_base_record and attr_list_present are
- * set.
- *
- * @m_ref is the mft reference of the mft record described by this entry. This
- * includes the sequence number for consistency checking purposes.
- *
- * @m_count is the usage count. When zero this record is not referenced anywhere
- * and can be thrown away safely (writing it to disk first if the dirty flag is
- * set).
- *
- * @m_mapped_attrs is an array of pointers to all mapped attributes of this mft
- * entry.
- *
- * @nr_mapped_attrs is the number of mapped attributes and hence the number of
- * elements in @m_mapped_attrs.
- *
- * @m_file is the ntfs_file this mft entry belongs to. If this is NULL, the mft
- * entry does not have a file associated with it. This can happen when a file is
- * closed but the associated mft entries are left in the cache or when mft
- * entries are directly accessed at low level for whatever reason.
- *
- * @m_list is an anchor for the @m_vol->mft_entries linked list.
- *
- * @m_dirty_list is an anchor for the @m_vol->dirty_mft_enties linked list.
- * Only valid if the dirty flag is set.
- *
- * @m_vol is the ntfs_volume this entry belongs to.
- *
- * @m_attr_list is a pointer to the attribute list attribute value. Only if
- * @m_flags has the attr_list_mapped flag set (which implies that is_base_record
- * and attr_list_present flags are set, too). This will effectively just contain
- * the same memory reference as the @a_val field of the mapped attribute list
- * attribute.
- */
-struct _mft_entry {
- MFT_RECORD *m_rec;
- unsigned long m_flags;
- MFT_REF m_ref;
- unsigned int m_count;
- attr **m_mapped_attrs;
- unsigned int nr_mapped_attrs;
- ntfs_file *m_file;
- struct list_head m_list;
- struct list_head m_dirty_list;
- ntfs_volume *m_vol;
- ATTR_LIST_ENTRY *m_attr_list;
-};
-
-/*
- * NOTE: I have completely ignored the existence of things like directories
- * and directory references for the moment! These will just be added later on.
- * The directories themselves are of course covered by being base mft records
- * and hence follow the same semantics like every other mft record.
- */
-
-/**
- * ntfs_file - structure describing an open file
- * @f_m_refs: array of mft references belonging to this file
- * @f_m_entries: array mft entries belonging to the @f_m_refs
- * @nr_m_refs: number of entries in above two arrays
- * @f_count: usage count of the file
- * @f_vol: volume the file belongs to
- * @f_list: anchor for the @f_vol->open_files list
- *
- * Each open file is described by an ntfs_file structure.
- *
- * @f_m_refs is the mft references of the file (i.e. the on disk inode numbers).
- * This is an array of MFT_REFs. The first reference is the base mft record and
- * if any others exist they are the associated loaded extension mft records.
- * Used for attribute list purposes.
- *
- * @f_m_entries is the loaded mft records for the file. This is an array of
- * pointers to mft_entries, corresponding to the f_m_refs. This is not strictly
- * necessary but results in a big speed up as we don't need to search the
- * @f_vol->mft_entries list every time.
- *
- * When an entry is referenced in the above lists the usage count for the
- * corresponding entry is increased by one.
- *
- * @nr_m_refs is the number of records in the @m_refs and @m_entries arrays. If
- * it is greater 1, we know there must be an attribute list attribute (but if
- * equals 1, we cannot assume there isn't one). This is of course the same as a
- * possible nr_m_entries, but refs is shorter to write. (-8
- *
- * @f_count it the usage count. When zero, this file is no longer open by anyone
- * and is thrown away. No need to concern oneself with dirty state as this is
- * done on a mft_entry level, i.e. a level below the idea of files.
- *
- * @f_vol is the volume the file belongs to.
- *
- * @f_list is an anchor into @f_vol->files list. When @f_count reaches 0, the
- * file is unlinked from the list and disposed off.
- */
-struct _ntfs_file {
- MFT_REF *f_m_refs;
- mft_entry **f_m_entries;
- unsigned int nr_m_refs;
- unsigned int f_count;
- ntfs_volume *f_vol;
- struct list_head f_list;
-};
-
-/*
- * FIXME: For RAID stuff will need the fd and dev_name variables to be arrays
- * or lists or something... Also will need to know the number of sectors (and
- * sector size if not 512) of each device making up the RAID array. Obviously,
- * will need RAID information as well like which RAID is used together with
- * state information, etc. But that is the far future.
- */
-
-/*
* ntfs_volume - structure describing an open volume in memory
- * FIXME: put in the remaining fields...
- * @open_files: linked list of all opened files
- * @nr_open_files: number of @open_files
- * @max_open_files: maximum number of @open_files
- * @mft_entries: linked list of all mft entries cached in memory
- * @nr_mft_entries: number of @mft_entries
- * @dirty_mft_entries: linked list of all dirty mft entries
- * @nr_dirty_mft_entries: number of @dirty_mft_entries
- * @dirty_attrs: linked list of all dirty, mapped attributes
- * @nr_dirty_attrs: number of @dirty_attrs
- * @v_list: anchor for list of mounted volumes
- *
- * @open_files is a linked list of ntfs_file struct pointers, keeping track of
- * of all open files. When a file is opened it is added to the back of this list
- * as we do not expect to be closing the file again that soon.
- *
- * @nr_open_files is the number of @open_files.
- *
- * @max_open_files is the maximum number of @open_files allowed.
- *
- * @mft_entries is a linked list of all loaded mft records (disk inodes) in
- * order of ascending mft record number (disk inode number, i.e. disregarding
- * the sequence number). Note, the list members are not the actual MFT_RECORDS,
- * but in memory mft_entry structs.
- *
- * @nr_mft_entries is the number of @mft_entries.
- *
- * @dirty_mft_entries is a linked list of all loaded mft records which are
- * dirty. Used for flushing the dirty mft entries - when one is marked dirty,
- * the entry is added to the end of this list. When it is flushed to disk, it is
- * marked clean and removed from this list. Effectively a FIFO.
- *
- * @nr_dirty_mft_entries is the number of @dirty_mft_entries.
- *
- * @dirty_attrs is a linked list of all dirty, non-resident, mapped attributes.
- *
- * @nr_dirty_attrs is the number of @dirty_attrs.
- *
- * @v_list is an anchor for the linked list of mounted volume.
*/
-struct _ntfs_volume {
+typedef struct {
int fd; /* File descriptor associated with volume. */
char *dev_name; /* Name of the device/file the volume is in. */
- char *vol_name; /* Name of the volume from the volume name
- attribute. */
- /* Version nos. and flags are from the volume information attribute. */
+ char *vol_name; /* Name of the volume. */
__u8 major_ver; /* Ntfs major version of volume. */
__u8 minor_ver; /* Ntfs minor version of volume. */
@@ -443,15 +129,5 @@
__u32 upcase_len; /* Length in Unicode characters of the
upcase table. */
- struct list_head open_files;
- int nr_open_files;
- int max_open_files;
- struct list_head mft_entries;
- int nr_mft_entries;
- struct list_head dirty_mft_entries;
- int nr_dirty_mft_entries;
- struct list_head dirty_attrs;
- int nr_dirty_attrs;
- struct list_head v_list;
-};
+} ntfs_volume;
#endif /* defined NTFS_TYPES_H */
Index: unistr.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/unistr.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -U2 -r1.7 -r1.8
--- unistr.h 9 Jun 2001 00:25:55 -0000 1.7
+++ unistr.h 14 Apr 2002 13:56:45 -0000 1.8
@@ -5,5 +5,5 @@
* 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
@@ -31,12 +31,4 @@
extern const __u8 legal_ansi_char_array[0x40];
-
-/*
- * These are just to make the code more readable...
- */
-typedef enum {
- CASE_SENSITIVE = 0,
- IGNORE_CASE = 1,
-} IGNORE_CASE_BOOL;
BOOL ntfs_are_names_equal(const uchar_t *s1, size_t s1_len,
Index: volume.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/volume.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -U2 -r1.15 -r1.16
--- volume.h 6 Dec 2001 01:14:52 -0000 1.15
+++ volume.h 14 Apr 2002 13:56:45 -0000 1.16
@@ -4,5 +4,5 @@
* volume.h - Exports for NTFS volume 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
@@ -25,70 +25,11 @@
#define VOLUME_H
-#include <stdio.h>
#include <sys/mount.h>
-#include "list.h"
-#include "support.h"
#include "types.h"
-int ntfs_sync_volume(ntfs_volume *vol);
+extern ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag);
-/**
- * ntfs_mount - open ntfs volume
- * @name: name of device/file to open
- * @rwflag: optional mount flags
- *
- * This function mounts an ntfs volume. @name should contain the name of the
- * device/file to mount as the ntfs volume.
- *
- * @rwflags is an optional second parameter. The same flags are used as for
- * the mount system call (man 2 mount). Currently only the following flags
- * are implemented:
- * MS_RDONLY - mount volume read-only
- *
- * The function opens the device or file @name and verifies that it contains a
- * valid bootsector. Then, it allocates an ntfs_volume structure and initializes
- * some of the values inside the structure from the information stored in the
- * bootsector. It proceeds to load the necessary system files and completes
- * setting up the structure.
- *
- * ntfs_mount() returns a pointer to the allocated ntfs_volume structure.
- * On error, the return value is NULL and errno is set appropriately.
- *
- * Note, that a copy is made of @name, and hence it can be discarded as
- * soon as the function returns.
- *
- * FIXME: Should document all error codes that can be returned and what each
- * means.
- */
-ntfs_volume *ntfs_mount(const char *name, unsigned long rwflag);
-
-/**
- * ntfs_umount - close ntfs volume
- * @vol: address of ntfs_volume structure of volume to close
- * @force: if true force close the volume even if it is busy
- *
- * Flush buffers, close all files and deallocate all structures (including @vol
- * itself) associated with the ntfs volume @vol.
- *
- * Return true on success. On error return false with errno set appropriately
- * (most likely to one of EAGAIN, EBUSY or EINVAL). The EAGAIN error means that
- * an operation is in progress and if you try the close later the operation
- * might be completed and the close succeed.
- *
- * If @force is true (i.e. not zero) this function will close the volume even
- * if this means that data might be lost. In this case the function always
- * returns 1.
- *
- * @vol must have previously been returned by a call to ntfs_mount().
- *
- * @vol itself is deallocated and should no longer be referenced after this
- * function returns success. If it returns an error then nothing has been done
- * so it is safe to continue using @vol.
- *
- * FIXME: Should document all error codes that can be returned and what each
- * means.
- */
-BOOL ntfs_umount(ntfs_volume *vol, const int force);
+extern BOOL ntfs_umount(ntfs_volume *vol, const int force);
#endif /* defined VOLUME_H */
--- mft_old.h DELETED ---
|