Changes by: flatcap
Update of /cvsroot/linux-ntfs/ntfsprogs/include/ntfs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21510/include/ntfs
Modified Files:
Makefile.am bitmap.h dir.h index.h inode.h mft.h volume.h
Added Files:
rich.h tree.h
Log Message:
ntfsrm has been split up and merged into libntfs.
currently it's #ifdef'd out.
tree.c - code for handling directory trees
rich.c - a few helpers without a home (this file will go away soon)
Note: ntfsrm isn't in the build any more (you need to ./configure --enable-rich; make extras). When rm is less intrusive, again, I'll put it back in the build.
--- NEW FILE ---
/**
* rich.h - Temporary junk file. Part of the Linux-NTFS project.
*
* Copyright (c) 2004-2005 Richard Russon
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program/include file is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (in the main directory of the Linux-NTFS
* distribution in the file COPYING); if not, write to the Free Software
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _NTFS_RICH_H_
#define _NTFS_RICH_H_
#include "layout.h"
#include "attrib.h"
#include "bitmap.h"
// XXX Temporarily copied from utils.h
#define RED "\e[31m"
#define GREEN "\e[32m"
#define YELLOW "\e[33m"
#define BLUE "\e[34m"
#define MAGENTA "\e[35m"
#define CYAN "\e[36m"
#define BOLD "\e[01m"
#define END "\e[0m"
#define ROUND_UP(num,bound) (((num)+((bound)-1)) & ~((bound)-1))
#define ROUND_DOWN(num,bound) ((num) & ~((bound)-1))
#define ATTR_SIZE(s) ROUND_UP(s,8)
ATTR_RECORD * find_attribute (const ATTR_TYPES type, ntfs_attr_search_ctx *ctx);
ATTR_RECORD * find_first_attribute (const ATTR_TYPES type, MFT_RECORD *mft);
int utils_free_non_residents3 (struct ntfs_bmp *bmp, ntfs_inode *inode, ATTR_RECORD *attr);
int utils_free_non_residents2 (ntfs_inode *inode, struct ntfs_bmp *bmp);
void ntfs_name_print (ntfschar *name, int name_len);
#endif /* _NTFS_RICH_H_ */
--- NEW FILE ---
/**
* tree.h - Directory tree handling code. Part of the Linux-NTFS project.
*
* Copyright (c) 2004-2005 Richard Russon
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program/include file is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (in the main directory of the Linux-NTFS
* distribution in the file COPYING); if not, write to the Free Software
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _NTFS_TREE_H_
#define _NTFS_TREE_H_
#include "layout.h"
#include "volume.h"
struct ntfs_dir;
/**
* struct ntfs_dt
*/
struct ntfs_dt {
struct ntfs_dir *dir;
struct ntfs_dt *parent;
u8 *data;
int data_len;
int child_count;
INDEX_ENTRY **children;
struct ntfs_dt **sub_nodes;
ntfs_inode **inodes;
VCN vcn;
INDEX_HEADER *header;
BOOL changed;
};
void ntfs_dt_free (struct ntfs_dt *dt);
int ntfs_dt_rollback (struct ntfs_dt *dt);
int ntfs_dt_commit (struct ntfs_dt *dt);
BOOL ntfs_dt_create_children2 (struct ntfs_dt *dt, int count);
BOOL ntfs_dt_resize_children3 (struct ntfs_dt *dt, int new);
int ntfs_dt_root_count (struct ntfs_dt *dt);
int ntfs_dt_alloc_count (struct ntfs_dt *dt);
int ntfs_dt_initialise2 (ntfs_volume *vol, struct ntfs_dt *dt);
struct ntfs_dt * ntfs_dt_create (struct ntfs_dir *dir, struct ntfs_dt *parent, VCN vcn);
MFT_REF ntfs_dt_find (struct ntfs_dt *dt, ntfschar *name, int name_len);
struct ntfs_dt * ntfs_dt_find2 (struct ntfs_dt *dt, ntfschar *name, int name_len, int *index_num);
struct ntfs_dt * ntfs_dt_find3 (struct ntfs_dt *dt, ntfschar *name, int name_len, int *index_num);
struct ntfs_dt * ntfs_dt_find4 (struct ntfs_dt *dt, ntfschar *name, int name_len, int *index_num);
void ntfs_dt_find_all (struct ntfs_dt *dt);
int ntfs_dt_find_parent (struct ntfs_dt *dt);
BOOL ntfs_dt_isroot (struct ntfs_dt *dt);
int ntfs_dt_root_freespace (struct ntfs_dt *dt);
int ntfs_dt_alloc_freespace (struct ntfs_dt *dt);
int ntfs_dt_transfer (struct ntfs_dt *old, struct ntfs_dt *new, int start, int count);
int ntfs_dt_alloc_insert (struct ntfs_dt *dt, INDEX_ENTRY *first, int count);
INDEX_ENTRY * ntfs_dt_alloc_insert2 (struct ntfs_dt *dt, int before, int count, int bytes);
int ntfs_dt_root_insert (struct ntfs_dt *dt, INDEX_ENTRY *first, int count);
int ntfs_dt_alloc_remove2 (struct ntfs_dt *dt, int start, int count);
int ntfs_dt_root_remove2 (struct ntfs_dt *dt, int start, int count);
int ntfs_dt_transfer2 (struct ntfs_dt *old, struct ntfs_dt *new, int start, int count);
int ntfs_dt_root_replace (struct ntfs_dt *del, int del_num, INDEX_ENTRY *del_ie, INDEX_ENTRY *suc_ie);
BOOL ntfs_dt_alloc_replace (struct ntfs_dt *del, int del_num, INDEX_ENTRY *del_ie, INDEX_ENTRY *suc_ie);
BOOL ntfs_dt_root_remove (struct ntfs_dt *del, int del_num);
BOOL ntfs_dt_alloc_remove (struct ntfs_dt *del, int del_num);
int ntfs_dt_alloc_add (struct ntfs_dt *parent, int index_num, INDEX_ENTRY *ie, struct ntfs_dt *child);
int ntfs_dt_root_add (struct ntfs_dt *parent, int index_num, INDEX_ENTRY *ie, struct ntfs_dt *child);
int ntfs_dt_add2 (INDEX_ENTRY *ie, struct ntfs_dt *suc, int suc_num, struct ntfs_dt *ded);
#endif /* _NTFS_TREE_H_ */
Index: Makefile.am
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/include/ntfs/Makefile.am,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -p -r1.10 -r1.11
--- Makefile.am 16 Oct 2005 21:57:00 -0000 1.10
+++ Makefile.am 16 Oct 2005 23:33:03 -0000 1.11
@@ -24,10 +24,12 @@ linux_ntfsinclude_HEADERS = \
logging.h \
mft.h \
mst.h \
+ ntfstime.h \
+ rich.h \
runlist.h \
security.h \
support.h \
- ntfstime.h \
+ tree.h \
types.h \
unistr.h \
version.h \
Index: bitmap.h
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/include/ntfs/bitmap.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -p -r1.3 -r1.4
--- bitmap.h 12 Mar 2004 17:25:04 -0000 1.3
+++ bitmap.h 16 Oct 2005 23:33:04 -0000 1.4
@@ -2,6 +2,7 @@
* bitmap.h - Exports for bitmap handling. Part of the Linux-NTFS project.
*
* Copyright (c) 2000-2004 Anton Altaparmakov
+ * Copyright (c) 2004-2005 Richard Russon
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@@ -130,4 +131,36 @@ static __inline__ int ntfs_bitmap_clear_
return ntfs_bitmap_clear_run(na, bit, 1);
}
+
+#ifdef NTFS_RICH
+
+#include "layout.h"
+#include "inode.h"
+
+/**
+ * struct ntfs_bmp
+ * a cache for either dir/$BITMAP, $MFT/$BITMAP or $Bitmap/$DATA
+ */
+struct ntfs_bmp {
+ ntfs_volume *vol;
+ ntfs_attr *attr;
+ int count;
+ u8 **data;
+ VCN *data_vcn;
+};
+
+
+int ntfs_bmp_rollback (struct ntfs_bmp *bmp);
+int ntfs_bmp_commit (struct ntfs_bmp *bmp);
+void ntfs_bmp_free (struct ntfs_bmp *bmp);
+struct ntfs_bmp * ntfs_bmp_create (ntfs_inode *inode, ATTR_TYPES type, ntfschar *name, int name_len);
+int ntfs_bmp_add_data (struct ntfs_bmp *bmp, VCN vcn, u8 *data);
+u8 * ntfs_bmp_get_data (struct ntfs_bmp *bmp, VCN vcn);
+int ntfs_bmp_set_range (struct ntfs_bmp *bmp, VCN vcn, s64 length, int value);
+s64 ntfs_bmp_find_last_set (struct ntfs_bmp *bmp);
+int ntfs_bmp_find_space (struct ntfs_bmp *bmp, LCN start, long size);
+
+#endif /* NTFS_RICH */
+
#endif /* defined _NTFS_BITMAP_H */
+
Index: dir.h
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/include/ntfs/dir.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -p -r1.6 -r1.7
--- dir.h 24 Sep 2005 15:20:49 -0000 1.6
+++ dir.h 16 Oct 2005 23:33:04 -0000 1.7
@@ -3,6 +3,7 @@
*
* Copyright (c) 2002 Anton Altaparmakov
* Copyright (c) 2005 Yura Pakhuchiy
+ * Copyright (c) 2004-2005 Richard Russon
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@@ -73,5 +74,37 @@ typedef int (*ntfs_filldir_t)(void *dire
extern int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos,
void *dirent, ntfs_filldir_t filldir);
+#ifdef NTFS_RICH
+
+/**
+ * struct ntfs_dir
+ */
+struct ntfs_dir {
+ ntfs_volume *vol;
+ struct ntfs_dir *parent;
+ ntfschar *name;
+ int name_len;
+ MFT_REF mft_num;
+ struct ntfs_dt *index;
+ struct ntfs_dir **children;
+ int child_count;
+ struct ntfs_bmp *bitmap;
+ ntfs_inode *inode;
+ ntfs_attr *iroot;
+ ntfs_attr *ialloc;
+ int index_size;
+};
+
+
+int ntfs_dir_rollback (struct ntfs_dir *dir);
+int ntfs_dir_truncate (ntfs_volume *vol, struct ntfs_dir *dir);
+int ntfs_dir_commit (struct ntfs_dir *dir);
+void ntfs_dir_free (struct ntfs_dir *dir);
+struct ntfs_dir * ntfs_dir_create (ntfs_volume *vol, MFT_REF mft_num);
+void ntfs_dir_add (struct ntfs_dir *parent, struct ntfs_dir *child);
+struct ntfs_dir * ntfs_dir_find2 (struct ntfs_dir *dir, ntfschar *name, int name_len);
+
+#endif /* NTFS_RICH */
+
#endif /* defined _NTFS_DIR_H */
Index: index.h
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/include/ntfs/index.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -p -r1.6 -r1.7
--- index.h 14 Aug 2005 15:44:47 -0000 1.6
+++ index.h 16 Oct 2005 23:33:04 -0000 1.7
@@ -3,6 +3,7 @@
*
* Copyright (c) 2004 Anton Altaparmakov
* Copyright (c) 2005 Yura Pakhuchiy
+ * Copyright (c) 2004-2005 Richard Russon
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@@ -121,4 +122,21 @@ static inline void ntfs_index_entry_mark
ictx->ia_dirty = TRUE;
}
+
+#ifdef NTFS_RICH
+
+#include "layout.h"
+
+void ntfs_ie_free (INDEX_ENTRY *ie);
+INDEX_ENTRY * ntfs_ie_create (void);
+VCN ntfs_ie_get_vcn (INDEX_ENTRY *ie);
+INDEX_ENTRY * ntfs_ie_copy (INDEX_ENTRY *ie);
+INDEX_ENTRY * ntfs_ie_set_vcn (INDEX_ENTRY *ie, VCN vcn);
+INDEX_ENTRY * ntfs_ie_remove_vcn (INDEX_ENTRY *ie);
+INDEX_ENTRY * ntfs_ie_set_name (INDEX_ENTRY *ie, ntfschar *name, int namelen, FILE_NAME_TYPE_FLAGS nametype);
+INDEX_ENTRY * ntfs_ie_remove_name (INDEX_ENTRY *ie);
+
+#endif /* NTFS_RICH */
+
#endif /* _NTFS_INDEX_H */
+
Index: inode.h
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/include/ntfs/inode.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -p -r1.15 -r1.16
--- inode.h 14 Aug 2005 15:44:47 -0000 1.15
+++ inode.h 16 Oct 2005 23:33:04 -0000 1.16
@@ -3,6 +3,7 @@
*
* Copyright (c) 2001,2002 Anton Altaparmakov
* Copyright (c) 2004-2005 Yura Pakhuchiy
+ * Copyright (c) 2004-2005 Richard Russon
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@@ -184,4 +185,12 @@ extern int ntfs_inode_add_attrlist(ntfs_
extern int ntfs_inode_free_space(ntfs_inode *ni, int size);
+#ifdef NTFS_RICH
+
+int ntfs_inode_close2 (ntfs_inode *ni);
+ntfs_inode * ntfs_inode_open2 (ntfs_volume *vol, const MFT_REF mref);
+ntfs_inode * ntfs_inode_open3 (ntfs_volume *vol, const MFT_REF mref);
+
+#endif /* NTFS_RICH */
+
#endif /* defined _NTFS_INODE_H */
Index: mft.h
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/include/ntfs/mft.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -p -r1.5 -r1.6
--- mft.h 13 Sep 2004 14:44:01 -0000 1.5
+++ mft.h 16 Oct 2005 23:33:04 -0000 1.6
@@ -2,6 +2,7 @@
* mft.h - Exports for MFT record handling. Part of the Linux-NTFS project.
*
* Copyright (c) 2000-2002 Anton Altaparmakov
+ * Copyright (c) 2004-2005 Richard Russon
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@@ -110,5 +111,18 @@ extern ntfs_inode *ntfs_mft_record_alloc
extern int ntfs_mft_record_free(ntfs_volume *vol, ntfs_inode *ni);
+#ifdef NTFS_RICH
+
+#include "bitmap.h"
+#include "dir.h"
+
+int ntfs_mft_remove_attr (struct ntfs_bmp *bmp, ntfs_inode *inode, ATTR_TYPES type);
+ATTR_RECORD * ntfs_mft_add_attr (ntfs_inode *inode, ATTR_TYPES type, u8 *data, int data_len);
+int ntfs_mft_resize_resident (ntfs_inode *inode, ATTR_TYPES type, ntfschar *name, int name_len, u8 *data, int data_len);
+int ntfs_mft_free_space (struct ntfs_dir *dir);
+int ntfs_mft_add_index (struct ntfs_dir *dir);
+
+#endif /* NTFS_RICH */
+
#endif /* defined _NTFS_MFT_H */
Index: volume.h
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/include/ntfs/volume.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -p -r1.14 -r1.15
--- volume.h 24 Sep 2005 22:54:55 -0000 1.14
+++ volume.h 16 Oct 2005 23:33:04 -0000 1.15
@@ -3,6 +3,7 @@
*
* Copyright (c) 2000-2004 Anton Altaparmakov
* Copyright (c) 2005 Yura Pakhuchiy
+ * Copyright (c) 2004-2005 Richard Russon
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@@ -203,5 +204,16 @@ extern int ntfs_logfile_reset(ntfs_volum
extern int ntfs_volume_write_flags(ntfs_volume *v, const u16 flags);
+#ifdef NTFS_RICH
+
+int ntfs_volume_commit (ntfs_volume *vol);
+int ntfs_volume_rollback (ntfs_volume *vol);
+int ntfs_volume_umount2 (ntfs_volume *vol, const BOOL force);
+ntfs_volume * ntfs_volume_mount2 (const char *device, unsigned long flags, BOOL force);
+int utils_valid_device (const char *name, int force);
+ntfs_volume * utils_mount_volume (const char *device, unsigned long flags, BOOL force);
+
+#endif /* NTFS_RICH */
+
#endif /* defined _NTFS_VOLUME_H */
|