Date: Wed, 28 Jan 2009 19:34:58 +0200 From: Giorgos Keramidas <keramida@freebsd.org> To: "M. Warner Losh" <imp@bsdimp.com> Cc: hackers@freebsd.org Subject: Re: Code review request: cdcontrol status label additon Message-ID: <87zlhb49ml.fsf@kobe.laptop> In-Reply-To: <20090128.101900.1355775961.imp@bsdimp.com> (M. Warner Losh's message of "Wed, 28 Jan 2009 10:19:00 -0700 (MST)") References: <20090128.092046.84362525.imp@bsdimp.com> <87mydbiecp.fsf@kobe.laptop> <87d4e7e4y0.fsf@kobe.laptop> <20090128.101900.1355775961.imp@bsdimp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 28 Jan 2009 10:19:00 -0700 (MST), "M. Warner Losh" <imp@bsdimp.com> wrote: > : lseek(3,0x8000,SEEK_SET) = 32768 (0x8000) > : read(3,0xbfbfe3a3,2048) ERR#5 'Input/output error' > > OK. That's definitely not page aligned. Slightly modified to force the alignment. Thanks for the tip about the address, which I failed to notice in truss output :) %%% diff -r 0c625c73ecc0 usr.sbin/cdcontrol/cdcontrol.1 --- a/usr.sbin/cdcontrol/cdcontrol.1 Wed Jan 28 18:38:39 2009 +0200 +++ b/usr.sbin/cdcontrol/cdcontrol.1 Wed Jan 28 19:34:15 2009 +0200 @@ -156,12 +156,14 @@ Play the right subtrack on both left and right channels. .It Ic info Print the table of contents. -.It Ic status Op Cm audio | media | volume +.It Ic status Op Cm audio | label | media | volume Print the information about the disc: .Pp .Bl -tag -width ".Cm volume" -compact .It Cm audio the current playing status and position +.It Cm label +the current ISO 9660 volume label, if present .It Cm media the current media catalog status .It Cm volume diff -r 0c625c73ecc0 usr.sbin/cdcontrol/cdcontrol.c --- a/usr.sbin/cdcontrol/cdcontrol.c Wed Jan 28 18:38:39 2009 +0200 +++ b/usr.sbin/cdcontrol/cdcontrol.c Wed Jan 28 19:34:15 2009 +0200 @@ -86,6 +86,7 @@ #define STATUS_AUDIO 0x1 #define STATUS_MEDIA 0x2 #define STATUS_VOLUME 0x4 +#define STATUS_LABEL 0x8 struct cmdtab { int command; @@ -801,6 +802,8 @@ what |= STATUS_MEDIA; else if (!strncasecmp(p, "volume", strlen(p))) what |= STATUS_VOLUME; + else if (!strncasecmp(p, "label", strlen(p))) + what |= STATUS_LABEL; else { warnx("invalid command arguments"); return 0; @@ -851,6 +854,32 @@ else printf ("No volume level info available\n"); } + if (what & STATUS_LABEL) { +#define ISO9660_MAGIC "\x01" "CD001" "\x01\x00" +#define ISO9660_OFFSET 0x8000 +#define VOLUME_LEN 32 +#define CD_SECTOR_LEN 2048 +#define LABEL_NAME_OFF 0x28 +#define LABEL_NAME_LEN 32 + uint32_t buffer[CD_SECTOR_LEN / sizeof(uint32_t)]; + char *sp, *ep; + + lseek(fd, ISO9660_OFFSET, SEEK_SET); + rc = read (fd, buffer, CD_SECTOR_LEN); + if (rc == CD_SECTOR_LEN && + memcmp(buffer, ISO9660_MAGIC, sizeof(ISO9660_MAGIC) - 1) == 0) { + sp = (void *)buffer + LABEL_NAME_OFF; + ep = sp + LABEL_NAME_LEN - 1; + while (*ep == ' ' && ep >= sp) + *ep-- = '\0'; + if (verbose) + printf("ISO 9660 Label is: %s\n", sp); + else + printf("%s\n", sp); + } + else + printf("No ISO 9660 label found\n"); + } return(0); } %%%
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87zlhb49ml.fsf>