+/*
+ PrintVolumeNameAttr
+
+ Get the volume name of the volume mounted at "path". Print that volume
+ name to standard out.
+
+ Returns: FSUR_RECOGNIZED, FSUR_IO_FAIL
+*/
+struct VolumeNameBuf {
+ u_int32_t info_length;
+ attrreference_t name_ref;
+ char buffer[1024];
+};
+
+static int
+PrintVolumeNameAttr(const char *path)
+{
+ struct attrlist alist;
+ struct VolumeNameBuf volNameInfo;
+ int result;
+
+ /* Set up the attrlist structure to get the volume's Finder Info */
+ alist.bitmapcount = 5;
+ alist.reserved = 0;
+ alist.commonattr = 0;
+ alist.volattr = ATTR_VOL_INFO | ATTR_VOL_NAME;
+ alist.dirattr = 0;
+ alist.fileattr = 0;
+ alist.forkattr = 0;
+
+ /* Get the Finder Info */
+ result = getattrlist(path, &alist, &volNameInfo, sizeof(volNameInfo), 0);
+ if (result) {
+ result = FSUR_IO_FAIL;
+ goto Err_Exit;
+ }
+
+ /* Print the name to standard out */
+ printf("%.*s", (int) volNameInfo.name_ref.attr_length, ((char *) &volNameInfo.name_ref) + volNameInfo.name_ref.attr_dataoffset);
+ result = FSUR_RECOGNIZED;
+
+Err_Exit:
+ return result;
+}
+
+