Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/libntfs
In directory usw-pr-cvs1:/tmp/cvs-serv15593/libntfs
Modified Files:
Makefile.am Makefile.in attrib.c attrib_RE.c inode.c mft.c
volume.c
Added Files:
debug.c
Log Message:
Attribute list support (merging done, part 2, some stuff still incomplete). mkntfs ntfs volume creation. See the changelog...
--- NEW FILE ---
/*
* $Id: debug.c,v 1.1 2002/04/22 10:34:31 antona Exp $
*
* debug.c - Debugging output functions. Part of the Linux-NTFS project.
*
* Copyright (c) 2002 Anton Altaparmakov.
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program/include file is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (in the main directory of the Linux-NTFS
* distribution in the file COPYING); if not, write to the Free Software
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debug.h"
#ifdef DEBUG
/* Dump a run list. */
void ntfs_debug_dump_run_list(const run_list_element *rl)
{
int i = 0;
const char *lcn_str[5] = { "LCN_HOLE ", "LCN_RL_NOT_MAPPED",
"LCN_ENOENT ", "LCN_EINVAL ",
"LCN_unknown " };
Dputs("NTFS-fs DEBUG: Dumping run list (values in hex):");
if (!rl) {
Dputs("Run list not present.");
return;
}
Dputs("VCN LCN Run length");
do {
LCN lcn = (rl + i)->lcn;
if (lcn < (LCN)0) {
int index = -lcn - 1;
if (index > -LCN_EINVAL - 1)
index = 4;
Dprintf("%-16Lx %s %-16Lx%s\n", rl[i].vcn,
lcn_str[index], rl[i].length,
rl[i].length ? "" : " (run list end)");
} else
Dprintf("%-16Lx %-16Lx %-16Lx%s\n", rl[i].vcn,
rl[i].lcn, rl[i].length,
rl[i].length ? "" : " (run list end)");
} while (rl[i++].length);
}
#endif
Index: Makefile.am
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/Makefile.am,v
retrieving revision 1.12
retrieving revision 1.13
diff -U2 -r1.12 -r1.13
--- Makefile.am 19 Apr 2002 18:23:56 -0000 1.12
+++ Makefile.am 22 Apr 2002 10:34:31 -0000 1.13
@@ -19,18 +19,15 @@
lib_LTLIBRARIES = libntfs.la
libntfs_la_LDFLAGS = -version-info $(LTVERSION)
-libntfs_la_SOURCES = \
- attrib.c \
- bootsect.c \
- mft.c \
- volume.c \
- disk_io.c \
- mst.c \
- unistr.c \
- inode.c
+libntfs_la_SOURCES = \
+ attrib.c \
+ bootsect.c \
+ debug.c \
+ disk_io.c \
+ inode.c \
+ mft.c \
+ mst.c \
+ unistr.c \
+ volume.c
INCLUDES = $(linux_ntfsincludedir) $(all_includes)
-
-# Don't need this distributed.
-#EXTRA_DIST = \
-# attrib_RE.c
Index: Makefile.in
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/Makefile.in,v
retrieving revision 1.16
retrieving revision 1.17
diff -U2 -r1.16 -r1.17
--- Makefile.in 19 Apr 2002 18:23:56 -0000 1.16
+++ Makefile.in 22 Apr 2002 10:34:31 -0000 1.17
@@ -104,12 +104,13 @@
libntfs_la_LDFLAGS = -version-info $(LTVERSION)
libntfs_la_SOURCES = \
- attrib.c \
- bootsect.c \
- mft.c \
- volume.c \
- disk_io.c \
- mst.c \
- unistr.c \
- inode.c
+ attrib.c \
+ bootsect.c \
+ debug.c \
+ disk_io.c \
+ inode.c \
+ mft.c \
+ mst.c \
+ unistr.c \
+ volume.c
@@ -124,6 +125,6 @@
LIBS = @LIBS@
libntfs_la_LIBADD =
-libntfs_la_OBJECTS = attrib.lo bootsect.lo mft.lo volume.lo disk_io.lo \
-mst.lo unistr.lo inode.lo
+libntfs_la_OBJECTS = attrib.lo bootsect.lo debug.lo disk_io.lo inode.lo \
+mft.lo mst.lo unistr.lo volume.lo
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -137,6 +138,7 @@
TAR = gtar
GZIP_ENV = --best
-DEP_FILES = .deps/attrib.P .deps/bootsect.P .deps/disk_io.P \
-.deps/inode.P .deps/mft.P .deps/mst.P .deps/unistr.P .deps/volume.P
+DEP_FILES = .deps/attrib.P .deps/bootsect.P .deps/debug.P \
+.deps/disk_io.P .deps/inode.P .deps/mft.P .deps/mst.P .deps/unistr.P \
+.deps/volume.P
SOURCES = $(libntfs_la_SOURCES)
OBJECTS = $(libntfs_la_OBJECTS)
@@ -377,8 +379,4 @@
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
-
-# Don't need this distributed.
-#EXTRA_DIST = \
-# attrib_RE.c
# Tell versions [3.59,3.63) of GNU make to not export all variables.
Index: attrib.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/attrib.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -U2 -r1.27 -r1.28
--- attrib.c 21 Apr 2002 10:11:36 -0000 1.27
+++ attrib.c 22 Apr 2002 10:34:31 -0000 1.28
@@ -136,5 +136,5 @@
*/
/* Decompress the mapping pairs array into a run list. */
- rl = decompress_run_list(a);
+ rl = ntfs_decompress_mapping_pairs(vol, a, NULL);
if (!rl) {
errno = EINVAL;
@@ -302,5 +302,9 @@
}
/* Decompress the mapping pairs array into a run list. */
- rl = decompress_run_list(a);
+ rl = ntfs_decompress_mapping_pairs(vol, a, NULL);
[...1041 lines suppressed...]
+ ni->run_list);
+ if (!rl) {
+ int eo = errno;
+ ntfs_put_attr_search_ctx(ctx);
+ errno = eo;
+ return -1;
}
+ ni->run_list = rl;
}
-#endif
- /* Finally finished! */
- return rl;
+ ntfs_put_attr_search_ctx(ctx);
+ return 0;
}
-
-/* Already cleaned up code below, but still look for FIXME:... */
+#endif
/**
Index: attrib_RE.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/attrib_RE.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -U2 -r1.4 -r1.5
--- attrib_RE.c 20 Apr 2002 23:09:42 -0000 1.4
+++ attrib_RE.c 22 Apr 2002 10:34:31 -0000 1.5
@@ -4,4 +4,48 @@
* equivalent to originals. */
+/*
+ * 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
+ * @alist_mrec: mft record containing attribute list (i.e. base mft record)
+ * @alist_attr: attribute list attribute record
+ * @alist_val: attribute list value (if alist is resident in @alist_mrec)
+ * @alist_val_end: end of attribute list value + 1
+ * @alist_val_len: length of attribute list in bytes
+ * @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 @base and @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 in lookup_attr() and only when called with @mrec
+ * not NULL. Then, if @is_first is TRUE, lookup_attr() begins the search with
+ * @attr. If @is_first is FALSE, lookup_attr() begins the search after @attr.
+ * This is so that, after the first call to lookup_attr(), we can call
+ * lookup_attr() again, without any modification of the search context, to
+ * automagically get the next matching attribute.
+ *
+ * In contrast, find_attr() ignores @is_first and always begins the search with
+ * @attr. find_attr() shouldn't really be called directly; it is just for
+ * internal use. FIXME: Might want to change this behaviour later, but not
+ * before I am finished with lookup_external_attr(). (AIA)
+ */
+typedef struct {
+ __u8 *base;
+ MFT_RECORD *mrec;
+ ATTR_RECORD *attr;
+
+ __u8 *alist_val_base;
+ MFT_RECORD *alist_mrec;
+ ATTR_RECORD *alist_attr;
+ ATTR_LIST_ENTRY *alist_val;
+ ATTR_LIST_ENTRY *alist_val_end;
+ __u32 alist_val_len;
+ IS_FIRST_BOOL is_first;
+ __u8 *alist_old_base;
+} attr_search_context;
+
BOOL find_attr(const ntfs_volume *vol, const ATTR_TYPES type,
const wchar_t *name, const __u32 name_len,
Index: inode.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/inode.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -U2 -r1.7 -r1.8
--- inode.c 21 Apr 2002 01:13:50 -0000 1.7
+++ inode.c 22 Apr 2002 10:34:31 -0000 1.8
@@ -134,5 +134,5 @@
NInoSetAttrListNonResident(ni);
// FIXME: We are duplicating work here! (AIA)
- ni->attr_list_rl = decompress_run_list(ctx->attr);
+ ni->attr_list_rl = ntfs_decompress_mapping_pairs(vol, ctx->attr, NULL);
if (ni->attr_list_rl) {
/* We got the run list, so we are done. */
Index: mft.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/mft.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -U2 -r1.22 -r1.23
--- mft.c 20 Apr 2002 23:09:42 -0000 1.22
+++ mft.c 22 Apr 2002 10:34:31 -0000 1.23
@@ -69,9 +69,9 @@
}
/* Starting cluster of the first mft record to read. */
- lcn = ntfs_vcn_to_lcn(vol->mft_runlist, m << vol->mft_record_size_bits
+ lcn = ntfs_vcn_to_lcn(vol->mft_rl, m << vol->mft_record_size_bits
>> vol->cluster_size_bits);
/*
* We always keep the COMPLETE run list for $MFT/$DATA in
- * vol->mft_runlist.
+ * vol->mft_rl.
*/
if (lcn < 0) {
@@ -132,9 +132,9 @@
}
/* Starting cluster of the first mft record to write. */
- lcn = ntfs_vcn_to_lcn(vol->mft_runlist, m << vol->mft_record_size_bits
+ lcn = ntfs_vcn_to_lcn(vol->mft_rl, m << vol->mft_record_size_bits
>> vol->cluster_size_bits);
/*
* We always keep the COMPLETE run list for $MFT/$DATA in
- * vol->mft_runlist.
+ * vol->mft_rl.
*/
if (lcn < 0) {
Index: volume.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/volume.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -U2 -r1.31 -r1.32
--- volume.c 20 Apr 2002 23:09:43 -0000 1.31
+++ volume.c 22 Apr 2002 10:34:31 -0000 1.32
@@ -52,6 +52,6 @@
if (v->mft_bitmap)
free(v->mft_bitmap);
- if (v->mft_runlist)
- free(v->mft_runlist);
+ if (v->mft_rl)
+ free(v->mft_rl);
if (v->upcase)
free(v->upcase);
@@ -322,6 +322,6 @@
}
/* Get the run list. */
- vol->mft_runlist = decompress_run_list(a);
- if (!vol->mft_runlist) {
+ vol->mft_rl = ntfs_decompress_mapping_pairs(vol, a, NULL);
+ if (!vol->mft_rl) {
Dputs(FAILED);
Dputs("Error decompressing run list from $Mft $DATA "
|