Changes by: mattjf
Update of /cvsroot/linux-ntfs/linux-ntfs/ntfstools
In directory usw-pr-cvs1:/tmp/cvs-serv2774/ntfstools
Modified Files:
ntfsinfo.c
Log Message:
Added new code to ntfsinfo
Index: ntfsinfo.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/ntfsinfo.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -U2 -r1.1 -r1.2
--- ntfsinfo.c 8 May 2002 05:55:15 -0000 1.1
+++ ntfsinfo.c 11 May 2002 21:43:56 -0000 1.2
@@ -25,6 +25,19 @@
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <locale.h>
+
+#include "mft.h"
+#include "attrib.h"
+#include "layout.h"
+#include "inode.h"
+
+void get_file_attribute_value(const char *dev, int inode);
+
int main(int argc, char **argv)
@@ -32,14 +45,13 @@
const char *AUTHOR = "Matthew J. Fanto";
const char *EXEC_NAME = "ntfsinfo";
- const char *VERSION = "1.0"; /*FIXME: get version from linux-ntfs */
-
+
if (argc < 3 || argc > 4) {
fprintf(stderr, "%s v%s - %s\n", EXEC_NAME, VERSION, AUTHOR);
- fprintf(stderr, "Usage: ntfsinfo device attribute\n");
+ fprintf(stderr, "Usage: ntfsinfo device inode");
exit(1);
}
- else
- get_file_attribute_value(argv[1], argv[2]);
+ else
+ get_file_attribute_value(argv[1], (int)argv[2]);
return 0;
@@ -48,14 +60,42 @@
-void get_file_attribute_value(char *dev, char *attribute)
+void get_file_attribute_value(const char *dev, int i)
{
+ MFT_REF mref;
+ MFT_RECORD *mrec = NULL;
+ ATTR_RECORD *attr = NULL;
+ FILE_NAME_ATTR *file_name_attr = NULL;
+ ntfs_attr_search_ctx *ctx = NULL;
+ ntfs_volume *vol = NULL;
+ uchar_t *file_name;
+ ntfs_inode *inode = NULL;
-
-
+
+ vol = ntfs_mount(dev,0);
+ mref = (MFT_REF)i;
+ inode = ntfs_open_inode(vol,mref);
+ if(ntfs_read_file_record(vol,NULL,&mrec,NULL)){
+ perror("Error reading file record!\n");
+ exit(1);
+ }
+ ctx = ntfs_get_attr_search_ctx(inode,mrec);
+
+ if(ntfs_lookup_attr(AT_FILE_NAME,NULL,0,0,0,NULL,0,ctx)){
+ perror("Error looking up attribute!\n");
+ exit(1);
+ }
+ attr = ctx->attr;
+ file_name_attr = (FILE_NAME_ATTR*)((char*)attr + le16_to_cpu(attr->value_offset));
+
+ file_name = malloc(sizeof(uchar_t)*file_name_attr->file_name_length);
+ file_name = &file_name_attr->file_name;
+ printf("%s\n",file_name);
+
+
}
|