Changes by: flatcap
Update of /cvsroot/linux-ntfs/linux-ntfs/libntfs
In directory usw-pr-cvs1:/tmp/cvs-serv1868/libntfs
Modified Files:
attrib.c debug.c dir.c inode.c runlist.c volume.c
Log Message:
new function headers and a few function moves
Index: attrib.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/attrib.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -U2 -r1.58 -r1.59
--- attrib.c 11 Jul 2002 16:20:33 -0000 1.58
+++ attrib.c 11 Jul 2002 23:44:13 -0000 1.59
@@ -1,3 +1,3 @@
-/**
+/*
* $Id$
*
@@ -380,6 +380,6 @@
/* Already cleaned up code below, but still look for FIXME:... */
-/*
- * Internal function:
+/**
+ * Internal:
[...2757 lines suppressed...]
- /* Sanity checks are performed elsewhere. */
- ctx->attr = (ATTR_RECORD*)((char*)mrec +
- le16_to_cpu(mrec->attrs_offset));
- ctx->is_first = TRUE;
- ctx->ntfs_ino = ni;
- ctx->al_entry = NULL;
- ctx->base_ntfs_ino = NULL;
- ctx->base_mrec = NULL;
- ctx->base_attr = NULL;
-}
-
/**
* ntfs_reinit_attr_search_ctx - reinitialize an attribute search context
@@ -2005,4 +2006,6 @@
/**
+ * Inline:
+ *
* ntfs_get_nr_significant_bytes - get number of bytes needed to store a number
* @n: number for which to get the number of bytes for
Index: debug.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/debug.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -U2 -r1.2 -r1.3
--- debug.c 11 Jul 2002 16:20:33 -0000 1.2
+++ debug.c 11 Jul 2002 23:44:13 -0000 1.3
@@ -25,6 +25,7 @@
#ifdef DEBUG
-
-/* Dump a run list. */
+/**
+ * ntfs_debug_dump_run_list - Dump a run list.
+ */
void ntfs_debug_dump_run_list(const run_list_element *rl)
{
Index: dir.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/dir.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -U2 -r1.7 -r1.8
--- dir.c 11 Jul 2002 16:20:33 -0000 1.7
+++ dir.c 11 Jul 2002 23:44:13 -0000 1.8
@@ -33,6 +33,6 @@
#include "volume.h"
-/**
- * The little endian Unicode string $I30 as a global constant.
+/*
+ * The little endian Unicode string "$I30" as a global constant.
*/
uchar_t I30[5] = { const_cpu_to_le16('$'), const_cpu_to_le16('I'),
@@ -40,4 +40,130 @@
const_cpu_to_le16('\0') };
+/*
+ * The little endian Unicode string ".." as a static global constant.
+ */
+static const uchar_t dotdot[3] = { const_cpu_to_le16('.'),
+ const_cpu_to_le16('.'),
+ const_cpu_to_le16('\0') };
+
+typedef union {
+ INDEX_ROOT *ir;
+ INDEX_ALLOCATION *ia;
+} index_union __attribute__ ((__transparent_union__));
+
+typedef enum {
+ INDEX_TYPE_ROOT, /* index root */
+ INDEX_TYPE_ALLOCATION, /* index allocation */
+} INDEX_TYPE;
+
+/**
+ * Internal:
+ *
+ * ntfs_filldir - ntfs specific filldir method
+ * @dir_ni: ntfs inode of current directory
+ * @pos: current position in directory
+ * @ivcn_bits: log(2) of index vcn size
+ * @index_type: specifies whether @iu is an index root or an index allocation
+ * @iu: index root or index block to which @ie belongs
+ * @ie: current index entry
+ * @dirent: context for filldir callback supplied by the caller
+ * @filldir: filldir callback supplied by the caller
+ *
+ * Pass information specifying the current directory entry @ie to the @filldir
+ * callback.
+ */
+static inline int ntfs_filldir(ntfs_inode *dir_ni, s64 *pos, u8 ivcn_bits,
+ const INDEX_TYPE index_type, index_union iu, INDEX_ENTRY *ie,
+ void *dirent, ntfs_filldir_t filldir)
+{
+ FILE_NAME_ATTR *fn = &ie->key.file_name;
+ unsigned dt_type;
+
+ /* Advance the position even if going to skip the entry. */
+ if (index_type == INDEX_TYPE_ALLOCATION)
+ *pos = (u8*)ie - (u8*)iu.ia + (sle64_to_cpu(
+ iu.ia->index_block_vcn) << ivcn_bits) +
+ dir_ni->vol->mft_record_size;
+ else /* if (index_type == INDEX_TYPE_ROOT) */
+ *pos = (u8*)ie - (u8*)iu.ir;
+ /* Skip root directory self reference entry. */
+ if (MREF_LE(ie->indexed_file) == FILE_root)
+ return 0;
+ if (ie->key.file_name.file_attributes &
+ FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT)
+ dt_type = NTFS_DT_DIR;
+ else
+ dt_type = NTFS_DT_REG;
+ return filldir(dirent, fn->file_name, fn->file_name_length,
+ fn->file_name_type, *pos,
+ le64_to_cpu(ie->indexed_file), dt_type);
+}
+
+/**
+ * Internal:
+ *
+ * ntfs_get_parent_mft_ref - find mft reference of parent directory of an inode
+ * @ni: ntfs inode whose parent directory to find
+ *
+ * Find the parent directory of the ntfs inode @ni. To do this, find the first
+ * file name attribute in the mft record of @ni and return the parent mft
+ * reference from that.
+ *
+ * Note this only makes sense for directories, since files can be hard linked
+ * from multiple directories and there is no way for us to tell which one is
+ * being looked for.
+ *
+ * Technically directories can have hard links, too, but we consider that as
+ * illegal as Linux/UNIX do not support directory hard links.
+ *
+ * Return the mft reference of the parent directory on success or -1 on error
+ * with errno set to the error code.
+ */
+static MFT_REF ntfs_get_parent_mft_ref(ntfs_inode *ni)
+{
+ MFT_REF mref;
+ ntfs_attr_search_ctx *ctx;
+ FILE_NAME_ATTR *fn;
+ int eo;
+
+ if (!ni) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ctx = ntfs_get_attr_search_ctx(ni, NULL);
+ if (!ctx)
+ return -1;
+ if (ntfs_lookup_attr(AT_FILE_NAME, AT_NONAME, 0, 0, 0, NULL, 0, ctx)) {
+ Dprintf("No file name found in inode 0x%Lx. Corrupt inode.\n",
+ (unsigned long long)ni->mft_no);
+ goto err_out;
+ }
+ if (ctx->attr->non_resident) {
+ Dprintf("File name attribute must be resident. Corrupt inode "
+ "0x%Lx.\n", (unsigned long long)ni->mft_no);
+ goto io_err_out;
+ }
+ fn = (FILE_NAME_ATTR*)((u8*)ctx->attr +
+ le16_to_cpu(ctx->attr->value_offset));
+ if ((u8*)fn + le32_to_cpu(ctx->attr->value_length) >
+ (u8*)ctx->attr + le32_to_cpu(ctx->attr->length)) {
+ Dprintf("Corrupt file name attribute in inode 0x%Lx.\n",
+ (unsigned long long)ni->mft_no);
+ goto io_err_out;
+ }
+ mref = le64_to_cpu(fn->parent_directory);
+ ntfs_put_attr_search_ctx(ctx);
+ return mref;
+io_err_out:
+ errno = EIO;
+err_out:
+ eo = errno;
+ ntfs_put_attr_search_ctx(ctx);
+ errno = eo;
+ return -1;
+}
+
+
/**
* ntfs_lookup_inode_by_name - find an inode in a directory given its name
@@ -450,129 +576,4 @@
goto eo_put_err_out;
}
-
-typedef union {
- INDEX_ROOT *ir;
- INDEX_ALLOCATION *ia;
-} index_union __attribute__ ((__transparent_union__));
-
-typedef enum {
- INDEX_TYPE_ROOT, /* index root */
- INDEX_TYPE_ALLOCATION, /* index allocation */
-} INDEX_TYPE;
-
-/*
- * Internal function:
- *
- * ntfs_filldir - ntfs specific filldir method
- * @dir_ni: ntfs inode of current directory
- * @pos: current position in directory
- * @ivcn_bits: log(2) of index vcn size
- * @index_type: specifies whether @iu is an index root or an index allocation
- * @iu: index root or index block to which @ie belongs
- * @ie: current index entry
- * @dirent: context for filldir callback supplied by the caller
- * @filldir: filldir callback supplied by the caller
- *
- * Pass information specifying the current directory entry @ie to the @filldir
- * callback.
- */
-static inline int ntfs_filldir(ntfs_inode *dir_ni, s64 *pos, u8 ivcn_bits,
- const INDEX_TYPE index_type, index_union iu, INDEX_ENTRY *ie,
- void *dirent, ntfs_filldir_t filldir)
-{
- FILE_NAME_ATTR *fn = &ie->key.file_name;
- unsigned dt_type;
-
- /* Advance the position even if going to skip the entry. */
- if (index_type == INDEX_TYPE_ALLOCATION)
- *pos = (u8*)ie - (u8*)iu.ia + (sle64_to_cpu(
- iu.ia->index_block_vcn) << ivcn_bits) +
- dir_ni->vol->mft_record_size;
- else /* if (index_type == INDEX_TYPE_ROOT) */
- *pos = (u8*)ie - (u8*)iu.ir;
- /* Skip root directory self reference entry. */
- if (MREF_LE(ie->indexed_file) == FILE_root)
- return 0;
- if (ie->key.file_name.file_attributes &
- FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT)
- dt_type = NTFS_DT_DIR;
- else
- dt_type = NTFS_DT_REG;
- return filldir(dirent, fn->file_name, fn->file_name_length,
- fn->file_name_type, *pos,
- le64_to_cpu(ie->indexed_file), dt_type);
-}
-
-/*
- * Internal function:
- *
- * ntfs_get_parent_mft_ref - find mft reference of parent directory of an inode
- * @ni: ntfs inode whose parent directory to find
- *
- * Find the parent directory of the ntfs inode @ni. To do this, find the first
- * file name attribute in the mft record of @ni and return the parent mft
- * reference from that.
- *
- * Note this only makes sense for directories, since files can be hard linked
- * from multiple directories and there is no way for us to tell which one is
- * being looked for.
- *
- * Technically directories can have hard links, too, but we consider that as
- * illegal as Linux/UNIX do not support directory hard links.
- *
- * Return the mft reference of the parent directory on success or -1 on error
- * with errno set to the error code.
- */
-static MFT_REF ntfs_get_parent_mft_ref(ntfs_inode *ni)
-{
- MFT_REF mref;
- ntfs_attr_search_ctx *ctx;
- FILE_NAME_ATTR *fn;
- int eo;
-
- if (!ni) {
- errno = EINVAL;
- return -1;
- }
-
- ctx = ntfs_get_attr_search_ctx(ni, NULL);
- if (!ctx)
- return -1;
- if (ntfs_lookup_attr(AT_FILE_NAME, AT_NONAME, 0, 0, 0, NULL, 0, ctx)) {
- Dprintf("No file name found in inode 0x%Lx. Corrupt inode.\n",
- (unsigned long long)ni->mft_no);
- goto err_out;
- }
- if (ctx->attr->non_resident) {
- Dprintf("File name attribute must be resident. Corrupt inode "
- "0x%Lx.\n", (unsigned long long)ni->mft_no);
- goto io_err_out;
- }
- fn = (FILE_NAME_ATTR*)((u8*)ctx->attr +
- le16_to_cpu(ctx->attr->value_offset));
- if ((u8*)fn + le32_to_cpu(ctx->attr->value_length) >
- (u8*)ctx->attr + le32_to_cpu(ctx->attr->length)) {
- Dprintf("Corrupt file name attribute in inode 0x%Lx.\n",
- (unsigned long long)ni->mft_no);
- goto io_err_out;
- }
- mref = le64_to_cpu(fn->parent_directory);
- ntfs_put_attr_search_ctx(ctx);
- return mref;
-io_err_out:
- errno = EIO;
-err_out:
- eo = errno;
- ntfs_put_attr_search_ctx(ctx);
- errno = eo;
- return -1;
-}
-
-/**
- * The little endian Unicode string .. as a static global constant.
- */
-static const uchar_t dotdot[3] = { const_cpu_to_le16('.'),
- const_cpu_to_le16('.'),
- const_cpu_to_le16('\0') };
/**
Index: inode.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/inode.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -U2 -r1.15 -r1.16
--- inode.c 11 Jul 2002 16:20:33 -0000 1.15
+++ inode.c 11 Jul 2002 23:44:13 -0000 1.16
@@ -33,4 +33,9 @@
#include "runlist.h"
+/**
+ * Internal:
+ *
+ * __allocate_ntfs_inode - desc
+ */
static __inline__ ntfs_inode *__allocate_ntfs_inode(ntfs_volume *vol)
{
@@ -43,9 +48,9 @@
}
-ntfs_inode *allocate_ntfs_inode(ntfs_volume *vol)
-{
- return __allocate_ntfs_inode(vol);
-}
-
+/**
+ * Internal:
+ *
+ * __release_ntfs_inode - desc
+ */
static __inline__ int __release_ntfs_inode(ntfs_inode *ni)
{
@@ -60,4 +65,13 @@
free(ni);
return 0;
+}
+
+
+/**
+ * allocate_ntfs_inode - desc
+ */
+ntfs_inode *allocate_ntfs_inode(ntfs_volume *vol)
+{
+ return __allocate_ntfs_inode(vol);
}
Index: runlist.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/runlist.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -U2 -r1.3 -r1.4
--- runlist.c 11 Jul 2002 16:20:34 -0000 1.3
+++ runlist.c 11 Jul 2002 23:44:13 -0000 1.4
@@ -1,3 +1,3 @@
-/**
+/*
* $Id$
*
@@ -35,6 +35,6 @@
#include "disk_io.h"
-/*
- * Internal function:
+/**
+ * Internal:
*
* ntfs_rl_mm - run_list memmove
@@ -47,6 +47,6 @@
}
-/*
- * Internal function:
+/**
+ * Internal:
*
* rl_mc - run_list memory copy
@@ -59,8 +59,8 @@
}
-/*
- * Internal function:
+/**
+ * Internal:
*
- * ntfs_rl_realloc - Reallocate memory for run_lists
+ * ntfs_rl_realloc - Reallocate memory for run_lists*
* @rl: original run list
* @old_size: number of run list elements in the original run list @rl
@@ -87,6 +87,6 @@
}
-/*
- * Internal function:
+/**
+ * Internal:
*
* ntfs_are_rl_mergeable - test if two run lists can be joined together
@@ -119,6 +119,6 @@
}
-/*
- * Internal function:
+/**
+ * Internal:
*
* __ntfs_rl_merge - merge two run lists without testing if they can be merged
@@ -136,6 +136,6 @@
}
-/*
- * Internal function:
+/**
+ * Internal:
*
* ntfs_rl_merge - test if two run lists can be joined together and merge them
@@ -161,6 +161,6 @@
}
-/*
- * Internal function:
+/**
+ * Internal:
*
* ntfs_rl_append - append a run list after a given element
@@ -228,6 +228,6 @@
}
-/*
- * Internal function:
+/**
+ * Internal:
*
* ntfs_rl_insert - insert a run list into another
@@ -337,6 +337,6 @@
}
-/*
- * Internal function:
+/**
+ * Internal:
*
* ntfs_rl_replace - overwrite a run_list element with another run list
@@ -403,6 +403,6 @@
}
-/*
- * Internal function:
+/**
+ * Internal:
*
* ntfs_rl_split - insert a run list into the centre of a hole
Index: volume.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/volume.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -U2 -r1.49 -r1.50
--- volume.c 11 Jul 2002 16:20:34 -0000 1.49
+++ volume.c 11 Jul 2002 23:44:13 -0000 1.50
@@ -39,6 +39,6 @@
#include "runlist.h"
-/*
- * Internal function:
+/**
+ * Internal:
*
* __allocate_ntfs_volume -
@@ -50,6 +50,6 @@
}
-/*
- * Internal function:
+/**
+ * Internal:
*
* __release_ntfs_volume -
@@ -83,8 +83,6 @@
}
-extern ntfs_inode *allocate_ntfs_inode(ntfs_volume *);
-
-/*
- * Internal function:
+/**
+ * Internal:
*
* ntfs_load_mft - load the $MFT and setup the ntfs volume with it
@@ -292,6 +290,6 @@
}
-/*
- * Internal function:
+/**
+ * Internal:
*
* ntfs_load_mftmirr - load the $MFTMirr and setup the ntfs volume with it
@@ -357,4 +355,38 @@
}
+#ifdef HAVE_MNTENT_H
+/**
+ * Internal:
+ *
+ * ntfs_check_mntent - desc
+ *
+ * If you are wanting to use this, you actually wanted to use
+ * ntfs_check_if_mounted(), you just didn't realize. (-:
+ *
+ * See description of ntfs_check_if_mounted(), below.
+ */
+static int ntfs_check_mntent(const char *file, unsigned long *mnt_flags)
+{
+ struct mntent *mnt;
+ FILE *f;
+
+ if (!(f = setmntent(MOUNTED, "r")))
+ return -1;
+ while ((mnt = getmntent(f)))
+ if (!strcmp(file, mnt->mnt_fsname))
+ break;
+ endmntent(f);
+ if (!mnt)
+ return 0;
+ *mnt_flags = NTFS_MF_MOUNTED;
+ if (!strcmp(mnt->mnt_dir, "/"))
+ *mnt_flags |= NTFS_MF_ISROOT;
+ if (hasmntopt(mnt, "ro") && !hasmntopt(mnt, "rw"))
+ *mnt_flags |= NTFS_MF_READONLY;
+ return 0;
+}
+
+#endif
+
/**
* ntfs_startup_volume - allocate and setup an ntfs volume
@@ -807,34 +839,4 @@
}
-#ifdef HAVE_MNTENT_H
-/**
- * Internal function: ntfs_check_mntent
- *
- * If you are wanting to use this, you actually wanted to use
- * ntfs_check_if_mounted(), you just didn't realize. (-:
- *
- * See description of ntfs_check_if_mounted(), below.
- */
-static int ntfs_check_mntent(const char *file, unsigned long *mnt_flags)
-{
- struct mntent *mnt;
- FILE *f;
-
- if (!(f = setmntent(MOUNTED, "r")))
- return -1;
- while ((mnt = getmntent(f)))
- if (!strcmp(file, mnt->mnt_fsname))
- break;
- endmntent(f);
- if (!mnt)
- return 0;
- *mnt_flags = NTFS_MF_MOUNTED;
- if (!strcmp(mnt->mnt_dir, "/"))
- *mnt_flags |= NTFS_MF_ISROOT;
- if (hasmntopt(mnt, "ro") && !hasmntopt(mnt, "rw"))
- *mnt_flags |= NTFS_MF_READONLY;
- return 0;
-}
-#endif
/**
|