Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/libntfs
In directory usw-pr-cvs1:/tmp/cvs-serv7324/libntfs
Modified Files:
attrib.c disk_io.c
Log Message:
Remove find_first_attr and make all users use get_attr_search_ctx + find_attr instead.
Index: attrib.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/attrib.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -U2 -r1.17 -r1.18
--- attrib.c 14 Apr 2002 14:08:29 -0000 1.17
+++ attrib.c 14 Apr 2002 15:26:23 -0000 1.18
@@ -186,48 +186,4 @@
}
-/**
- * find_first_attr - find first attribute in mft record
- * @type: attribute type to find
- * @name: attribute name to find (optional, i.e. NULL means don't care)
- * @name_len: attribute name length (only needed if @name present)
- * @ic: IGNORE_CASE or CASE_SENSITIVE (ignored if @name not present)
- * @upcase: unicode upcase table
- * @ucpase_len: length of upcase table in unicode characters
- * @val: attribute value to find (optional, resident attributes only)
- * @val_len: attribute value length
- * @ctx: search context with mft record and attribute to search from
- *
- * find_first_attr() is just an inlined wrapper for find_attr(). For details
- * see description of find_attr() above.
- */
-__inline__ BOOL find_first_attr(const ATTR_TYPES type, const uchar_t *name,
- const __u32 name_len, const IGNORE_CASE_BOOL ic,
- const uchar_t *upcase, const __u32 upcase_len,
- const __u8 *val, const __u32 val_len, attr_search_context *ctx)
-{
- MFT_RECORD *m;
- ATTR_RECORD *a;
-
-#ifdef DEBUG
- if (!ctx || !ctx->mrec) {
- Dputs("find_first_attr() received NULL pointer!");
- return FALSE;
- }
- if (ctx->attr)
- Dprintf("find_first_attr(): received non-NULL attribute "
- "pointer.\nThis will be overwritten resulting "
- "in possible memory leakage.\n");
-#endif
- m = ctx->mrec;
- ctx->is_first = TRUE;
- ctx->attr = a = (ATTR_RECORD*)((char*)m + le16_to_cpu(m->attrs_offset));
- if (p2n(a) >= p2n(m) && (char*)a <= (char*)m +
- le32_to_cpu(m->bytes_allocated))
- return find_attr(type, name, name_len, ic, upcase, upcase_len,
- val, val_len, ctx);
- Dputs("find_first_attr(): file is corrupt.");
- return FALSE;
-}
-
/* FIXME: Need to write the new flags to disk. */
int set_ntfs_volume_flags(ntfs_volume *v, MFT_RECORD *b,
@@ -236,5 +192,5 @@
ATTR_RECORD *r;
VOLUME_INFORMATION *c;
- attr_search_context ctx;
+ attr_search_context *ctx;
/* Sanity checks. */
@@ -242,18 +198,21 @@
return 0;
/* Get a pointer to the volume information attribute. */
- memset(&ctx, 0, sizeof(attr_search_context));
- ctx.mrec = b;
- if (!find_first_attr($VOLUME_INFORMATION, NULL, 0, 0, NULL, 0, NULL, 0,
- &ctx)) {
- fprintf(stderr, "Error: Attribute $VOLUME_INFORMATION was " \
- "not found in $Volume!\n");
+ ctx = get_attr_search_ctx(NULL, b);
+ if (!ctx) {
+ Dperror("Failed to allocate attribute search context");
return 0;
}
- r = ctx.attr;
+ if (!find_attr($VOLUME_INFORMATION, NULL, 0, 0, NULL, 0, NULL, 0,
+ ctx)) {
+ Dputs("Error: Attribute $VOLUME_INFORMATION was not found in "
+ "$Volume!");
+ goto err_out;
+ }
+ r = ctx->attr;
/* Sanity check. */
if (r->non_resident) {
- fprintf(stderr, "Error: Attribute $VOLUME_INFORMATION must " \
- "be resident (and it isn't)!\n");
- return 0;
+ Dputs("Error: Attribute $VOLUME_INFORMATION must be resident "
+ "(and it isn't)!");
+ goto err_out;
}
/* Get a pointer to the value of the attribute. */
@@ -261,15 +220,19 @@
/* Sanity checks. */
if ((char*)c + le32_to_cpu(r->value_length) >
- le16_to_cpu(b->bytes_in_use) + (char*)b ||
- le16_to_cpu(r->value_offset) + le32_to_cpu(r->value_length) >
- le32_to_cpu(r->length)) {
- fprintf(stderr, "Error: Attribute $VOLUME_INFORMATION in " \
- "$Volume is corrupt!\n");
- return 0;
+ le16_to_cpu(b->bytes_in_use) + (char*)b ||
+ le16_to_cpu(r->value_offset) +
+ le32_to_cpu(r->value_length) > le32_to_cpu(r->length)) {
+ Dputs("Error: Attribute $VOLUME_INFORMATION in $Volume is "
+ "corrupt!");
+ goto err_out;
}
/* Set the volume flags. */
c->flags = cpu_to_le16(flags);
+ put_attr_search_ctx(ctx);
/* Success! */
return 1;
+err_out:
+ put_attr_search_ctx(ctx);
+ return 0;
}
Index: disk_io.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/disk_io.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -U2 -r1.15 -r1.16
--- disk_io.c 14 Apr 2002 14:08:30 -0000 1.15
+++ disk_io.c 14 Apr 2002 15:26:23 -0000 1.16
@@ -30,4 +30,5 @@
#include "types.h"
#include "disk_io.h"
+#include "bitmap.h"
__s64 ntfs_pwrite(int fd, const void *b, __s64 count, const __s64 pos)
@@ -117,5 +118,5 @@
finished:
/* Quickly deprotect the data again. */
- __post_read_mst_fixup((NTFS_RECORD*)b, count);
+ post_write_mst_fixup((NTFS_RECORD*)b);
error_end:
return error;
|