Changes by: flatcap
Update of /cvsroot/linux-ntfs/linux-ntfs/libntfs
In directory usw-pr-cvs1:/tmp/cvs-serv29422/libntfs
Modified Files:
volume.c
Log Message:
Matt Fanto's changes to retrieve the volume name and a utility to print it
Index: volume.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/volume.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -U2 -r1.18 -r1.19
--- volume.c 6 Dec 2001 01:14:52 -0000 1.18
+++ volume.c 11 Apr 2002 23:10:59 -0000 1.19
@@ -137,4 +137,6 @@
ATTR_RECORD *a;
VOLUME_INFORMATION *vinf;
+ uchar_t *vname;
+ int j;
__u32 u;
__s64 l;
@@ -561,4 +563,33 @@
/* FIXME: Need to initialise vol->vol_name as well. */
+ memset(&ctx, 0, sizeof(attr_search_context));
+ ctx.mrec = mb;
+ /* Find the $VOLUME_NAME attribute. */
+ if (!find_first_attr($VOLUME_NAME, NULL, 0, 0, NULL, 0, NULL, 0,
+ &ctx)) {
+ puts(FAILED);
+ fprintf(stderr, "$VOLUME_NAME attribute not found in "
+ "$Volume?!?\n");
+ errno = EIO;
+ goto error_exit;
+ }
+ a = ctx.attr;
+ /* Has to be resident. */
+ if (a->non_resident) {
+ fprintf(stderr, "Error: Attribute $VOLUME_NAME must " \
+ "be resident (and it isn't)!\n");
+ errno = EIO;
+ goto error_exit;
+ }
+ /* Get a pointer to the value of the attribute. */
+ vol->vol_name = malloc ((a->value_length/2)+1);
+ if(!vol->vol_name)
+ {
+ printf("Unable to allocate memory!\n");
+ exit(1);
+ }
+ vname = (uchar_t *)(VOLUME_NAME*)(le16_to_cpu(a->value_offset) + (char*)a);
+ for (j = 0; j < (a->value_length/2); j++) { vol->vol_name[j] = vname[j]; }
+ vol->vol_name[a->value_length/2] = 0;
puts(OK);
|