Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/libntfs
In directory usw-pr-cvs1:/tmp/cvs-serv31323
Modified Files:
unistr.c volume.c
Log Message:
Added new name comparison function.
Index: unistr.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/unistr.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -U2 -r1.1 -r1.2
--- unistr.c 2001/03/07 01:17:33 1.1
+++ unistr.c 2001/03/31 15:27:34 1.2
@@ -23,4 +23,31 @@
/**
+ * ntfs_are_names_equal - compare two Unicode names for equality
+ * @s1: name to compare to @s2
+ * @s1_len: length in Unicode characters of @s1
+ * @s2: name to compare to @s1
+ * @s2_len: length in Unicode characters of @s2
+ * @ic: ignore case bool
+ * @upcase: upcase table (only if @ic == IGNORE_CASE)
+ * @upcase_size: length in Unicode characters of @upcase (if present)
+ *
+ * Compare the names @s1 and @s2 and return TRUE (1) if the names are
+ * identical, or FALSE (0) if they are not identical. If @ic is IGNORE_CASE,
+ * the @upcase table is used to performa a case insensitive comparison.
+ */
+BOOL ntfs_are_names_equal(const wchar_t *s1, size_t s1_len,
+ const wchar_t *s2, size_t s2_len,
+ const IGNORE_CASE_BOOL ic,
+ const wchar_t *upcase, const __u32 upcase_size)
+{
+ if (s1_len != s2_len)
+ return FALSE;
+ if (ic == CASE_SENSITIVE)
+ return memcmp(s1, s2, s1_len << 1) ? FALSE: TRUE;
+ return ntfs_wcsncasecmp(s1, s2, s1_len, upcase, upcase_size) ? FALSE:
+ TRUE;
+}
+
+/**
* ntfs_collate_names - collate two Unicode names
* @upcase: upcase table (ignored if @ic is CASE_SENSITIVE)
Index: volume.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/volume.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -U2 -r1.6 -r1.7
--- volume.c 2001/03/06 02:10:55 1.6
+++ volume.c 2001/03/31 15:27:34 1.7
@@ -49,4 +49,5 @@
__u8 sectors_per_cluster, bits;
__s8 c;
+ attr_search_context ctx;
if (!name) {
@@ -222,6 +223,16 @@
}
/* Find the bitmap attribute. */
- a = find_first_attribute(vol, mb, $BITMAP, NULL);
- if (!a) {
+ memset(ctx, 0, sizeof(attr_search_context));
+ ctx.mrec = mb;
+ ctx.attr = (ATTR_RECORD*)((char*)mb + le16_to_cpu(mb->attrs_offset));
+ if (ctx.attr < mb || ctx.attr > (char*)mb + vol->mft_record_size) {
+ puts(FAILED);
+ fprintf(stderr, "Error: corrupt mft record for $Mft.\n"
+ "Cannot handle this yet. )-:\n");
+ errno = EIO;
+ goto error_exit;
+ }
+ ctx.is_first = TRUE;
+ if (!lookup_attr(vol, 0, $BITMAP, NULL, 0, 0, 0, 0, 0, &ctx)) {
puts(FAILED);
fprintf(stderr, "$bitmap attribute not found in $Mft?!?\n");
@@ -229,5 +240,6 @@
goto error_exit;
}
- /* Get attribute value size and allocate a big enough buffer.*/
+ a = ctx.attr;
+ /* Get attribute value size and allocate a big enough buffer. */
l = get_attribute_value_length(a);
if (!l) {
@@ -252,7 +264,12 @@
goto error_exit;
}
+ //if (ctx.alist_val)
+ // free(ctx.alist_val);
/* Find the $DATA attribute in $Mft. */
- a = find_first_attribute(vol, mb, $DATA, NULL);
- if (!a) {
+ memset(ctx, 0, sizeof(attr_search_context));
+ ctx.mrec = mb;
+ ctx.attr = (ATTR_RECORD*)((char*)mb + le16_to_cpu(mb->attrs_offset));
+ ctx.is_first = TRUE;
+ if (!lookup_attr(vol, 0, $DATA, NULL, 0, 0, 0, 0, 0, &ctx)) {
puts(FAILED);
fprintf(stderr, "$DATA attribute not found in $Mft?!?\n");
|