Changes by: flatcap
Update of /cvsroot/linux-ntfs/linux-ntfs/libntfs
In directory usw-pr-cvs1:/tmp/cvs-serv2096/libntfs
Modified Files:
attrib.c dir.c inode.c unistr.c volume.c
Log Message:
added AT_NONAME so we can search for a (un)named attribute or just
iterate through all attributes
Index: attrib.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/attrib.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -U2 -r1.53 -r1.54
--- attrib.c 8 Jul 2002 06:23:22 -0000 1.53
+++ attrib.c 8 Jul 2002 23:27:15 -0000 1.54
@@ -38,4 +38,6 @@
#include "inode.h"
+uchar_t AT_NONAME[] = { const_cpu_to_le16('\0') };
+
/* FIXME: Need to write the new flags to disk. */
/**
@@ -57,5 +59,5 @@
return 0;
}
- if (ntfs_lookup_attr(AT_VOLUME_INFORMATION, NULL, 0, 0, 0, NULL, 0,
+ if (ntfs_lookup_attr(AT_VOLUME_INFORMATION, AT_NONAME, 0, 0, 0, NULL, 0,
ctx)) {
Dputs("Error: Attribute $VOLUME_INFORMATION was not found in "
@@ -395,6 +397,10 @@
na->ni = ni;
na->type = type;
- na->name = name;
- na->name_len = name ? name_len : 0;
+ if (name) {
+ na->name = name;
+ na->name_len = name_len;
+ } else {
+ na->name = AT_NONAME;
+ }
}
@@ -529,5 +535,5 @@
if (NAttrNonResident(na) && na->rl)
free(na->rl);
- if (na->name)
+ if (na->name != AT_NONAME)
free(na->name);
free(na);
@@ -2478,8 +2484,11 @@
continue;
/*
- * If @name is present, compare the two names. If @name is
- * missing, assume we want an unnamed attribute.
+ * If @name is AT_NONAME we want an unnamed attribute.
+ * If @name is present, compare the two names.
+ * Otherwise, match any attribute.
*/
if (!name) {
+ // do nothing
+ } else if (name == AT_NONAME) {
/* The search failed if the found attribute is named. */
if (a->name_length) {
@@ -2683,7 +2692,8 @@
continue;
}
- /*
- * If @name is present, compare the two names. If @name is
- * missing, assume we want an unnamed attribute.
+ /*
+ * If @name is AT_NONAME we want an unnamed attribute.
+ * If @name is present, compare the two names.
+ * Otherwise, match any attribute.
*/
al_name_len = al_entry->name_length;
@@ -2696,4 +2706,6 @@
goto is_enumeration;
if (!name) {
+ // do nothing
+ } else if (name == AT_NONAME) {
if (al_name_len)
goto not_found;
Index: dir.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/dir.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -U2 -r1.5 -r1.6
--- dir.c 8 Jul 2002 06:23:22 -0000 1.5
+++ dir.c 8 Jul 2002 23:27:16 -0000 1.6
@@ -539,5 +539,5 @@
if (!ctx)
return -1;
- if (ntfs_lookup_attr(AT_FILE_NAME, NULL, 0, 0, 0, NULL, 0, ctx)) {
+ 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);
Index: inode.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/inode.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -U2 -r1.12 -r1.13
--- inode.c 8 Jul 2002 06:23:22 -0000 1.12
+++ inode.c 8 Jul 2002 23:27:16 -0000 1.13
@@ -109,5 +109,5 @@
if (!ctx)
goto err_out;
- if (ntfs_lookup_attr(AT_ATTRIBUTE_LIST, NULL, 0, 0, 0, NULL, 0, ctx)) {
+ if (ntfs_lookup_attr(AT_ATTRIBUTE_LIST, AT_NONAME, 0, 0, 0, NULL, 0, ctx)) {
if (errno != ENOENT)
goto put_err_out;
Index: unistr.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/unistr.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -U2 -r1.18 -r1.19
--- unistr.c 8 Jul 2002 06:23:22 -0000 1.18
+++ unistr.c 8 Jul 2002 23:27:16 -0000 1.19
@@ -230,4 +230,7 @@
}
+/**
+ * ntfs_upcase_name
+ */
void ntfs_upcase_name(uchar_t *name, u32 name_len, const uchar_t *upcase,
const u32 upcase_len)
@@ -241,4 +244,7 @@
}
+/**
+ * ntfs_file_upcase_value
+ */
void ntfs_file_upcase_value(FILE_NAME_ATTR *file_name_attr,
const uchar_t *upcase, const u32 upcase_len)
@@ -248,4 +254,7 @@
}
+/**
+ * ntfs_file_compare_values
+ */
int ntfs_file_compare_values(FILE_NAME_ATTR *file_name_attr1,
FILE_NAME_ATTR *file_name_attr2,
Index: volume.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/volume.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -U2 -r1.45 -r1.46
--- volume.c 2 Jul 2002 23:47:10 -0000 1.45
+++ volume.c 8 Jul 2002 23:27:16 -0000 1.46
@@ -143,5 +143,5 @@
}
/* Find the $ATTRIBUTE_LIST attribute in $MFT if present. */
- if (ntfs_lookup_attr(AT_ATTRIBUTE_LIST, NULL, 0, 0, 0, NULL, 0, ctx)) {
+ if (ntfs_lookup_attr(AT_ATTRIBUTE_LIST, AT_NONAME, 0, 0, 0, NULL, 0, ctx)) {
if (errno != ENOENT) {
Dputs("Error: $MFT has corrupt attribute list.");
@@ -201,5 +201,5 @@
highest_vcn = next_vcn = 0;
a = NULL;
- while (!ntfs_lookup_attr(AT_DATA, NULL, 0, 0, next_vcn, NULL, 0, ctx)) {
+ while (!ntfs_lookup_attr(AT_DATA, AT_NONAME, 0, 0, next_vcn, NULL, 0, ctx)) {
run_list_element *nrl;
@@ -674,5 +674,5 @@
}
/* Find the $VOLUME_INFORMATION attribute. */
- if (ntfs_lookup_attr(AT_VOLUME_INFORMATION, NULL, 0, 0, 0, NULL, 0,
+ if (ntfs_lookup_attr(AT_VOLUME_INFORMATION, AT_NONAME, 0, 0, 0, NULL, 0,
ctx)) {
Dputs(FAILED);
@@ -711,5 +711,5 @@
/* Find the $VOLUME_NAME attribute. */
ntfs_reinit_attr_search_ctx(ctx);
- if (ntfs_lookup_attr(AT_VOLUME_NAME, NULL, 0, 0, 0, NULL, 0, ctx)) {
+ if (ntfs_lookup_attr(AT_VOLUME_NAME, AT_NONAME, 0, 0, 0, NULL, 0, ctx)) {
Dputs(FAILED);
Dputs("$VOLUME_NAME attribute not found in $Volume?!?");
|