odd_cdrom_trick

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



Subject: Re: How can I read the volume label of a CD ??
From: fred smith <fredex@fcshome.stoneham.ma.us>
Date: Fri, 7 May 1999 13:52:58 -0400


On Fri, May 07, 1999 at 01:20:10AM -0700, shade Aussie wrote:
> 
> Hi.
> 
> Does anyone know how to read the volume label of a CD ?
> I want to automate the renaming of the paths and
> mountings for our CD server.
> The ls and dir commands can not seem to do it.
> 
> Thanx in advance
> 
>      Martin

Here's a quick & dirty little hack I whipped up some time back. After
compiling it, you stick your CD in the drive, DO NOT MOUNT IT, then
run this baby like:

	getvn /dev/cdrom

Fred
--------------------

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>

int main (int argc, char ** argv)
	{
	int fd;
	char buf[12];
	
	if (argc != 2)
		{
		printf ("Usage: %s <cdrom devicename>\n", argv[0]);
		exit (0);
		}

	fd = open (argv[1], O_RDONLY);
	if (fd < 0)
		{
		printf ("oops! Error opening device %s\n", argv[1]);
		exit (1);
		}
	if (lseek (fd, (long) 0x8028, SEEK_SET) != (long) 0x8028)
		{
		printf ("oops! Error seeking device %s\n", argv[1]);
		exit (1);
		}
	if (read (fd, buf, 11) != 11)
		{
		printf ("oops! Error reading device %s\n", argv[1]);
		exit (1);
		}
	close (fd);
	printf ("Volume name in device %s: %s\n", argv[1], buf);
	return (0);
	}
===




the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu