Changes by: flatcap
Update of /cvsroot/linux-ntfs/linux-ntfs/ntfstools
In directory usw-pr-cvs1:/tmp/cvs-serv1965
Modified Files:
ntfsinfo.c
Log Message:
minor bugfix, free used vars, remove duplicated code
Index: ntfsinfo.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/ntfsinfo.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -U2 -r1.5 -r1.6
--- ntfsinfo.c 2 Jun 2002 13:57:59 -0000 1.5
+++ ntfsinfo.c 25 Jun 2002 15:17:13 -0000 1.6
@@ -3,5 +3,5 @@
*
* ntfsinfo - Part of the Linux-NTFS project.
- *
+ *
* Copyright (c) 2002 Matthew J. Fanto
* Copyright (c) 2002 Anton Altaparmakov
@@ -40,4 +40,7 @@
void get_file_attribute_value(const char *dev, long int i);
+/**
+ * main
+ */
int main(int argc, char **argv)
{
@@ -45,22 +48,19 @@
const char *EXEC_NAME = "ntfsinfo";
const char *locale;
- int i;
+ int i;
+
+ if (!locale) {
+ char *locale;
+
+ locale = setlocale(LC_ALL, NULL);
+ printf("Failed to set locale, using default (%s).\n", locale);
+ } else
+ printf("Using locale %s.\n", locale);
- locale = setlocale(LC_ALL, "");
- if (!locale) {
- char *locale;
-
- locale = setlocale(LC_ALL, NULL);
- printf("Failed to set locale, using default (%s).\n", locale);
- } else
- printf("Using locale %s.\n", locale);
-
if(argc < 3 || argc > 4) {
fprintf(stderr, "%s v%s - %s\n", EXEC_NAME, VERSION, AUTHOR);
- fprintf(stderr, "Usage: ntfsinfo device inode");
+ fprintf(stderr, "Usage: ntfsinfo device inode");
exit(1);
- }
-
- else {
+ } else {
i = atol(argv[2]);
get_file_attribute_value(argv[1], i);
@@ -70,18 +70,17 @@
}
-
-
+/**
+ * get_file_attribute_value
+ */
void get_file_attribute_value(const char *dev, long 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;
- char *file_name;
+ char *file_name = NULL;
ntfs_inode *inode = NULL;
-
+
vol = ntfs_mount(dev,0);
@@ -89,25 +88,23 @@
inode = ntfs_open_inode(vol,mref);
- if(ntfs_read_file_record(vol,mref,&mrec,NULL)){
- perror("Error reading file record!\n");
- exit(1);
- }
-
- ctx = ntfs_get_attr_search_ctx(inode,mrec);
-
+ ctx = ntfs_get_attr_search_ctx(inode,NULL);
-//Here is where we need to start searching for each attribute
+ //Here is where we need to start searching for each attribute
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));
-
- ntfs_ucstombs(file_name_attr->file_name,file_name_attr->file_name_length,&file_name,file_name_attr->file_name_length);
+
+ ntfs_ucstombs(file_name_attr->file_name,file_name_attr->file_name_length,
+ &file_name,file_name_attr->file_name_length);
printf("%s\n",file_name);
-
+
+ free (ctx);
+ ntfs_close_inode (inode);
+ ntfs_umount (vol, FALSE);
}
|