DragonFly users List (threaded) for 2007-02
DragonFly BSD
DragonFly users List (threaded) for 2007-02
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: lsdvd won't work on DF 1.8


From: "Dmitri Nikulin" <dnikulin@xxxxxxxxx>
Date: Sun, 18 Feb 2007 15:33:06 +1100

On 2/18/07, Kimura Fuyuki <fuyuki@hadaly.org> wrote:
OK, I give up...

Could someone tell me why the following simple program fails to print a dvd
title? It seems to read from offset 32768.  (block boundary?)

#include <stdio.h>
int main(void)
{
        FILE *fp;
        char buf[33];
        buf[32] = '\0';
        fp = fopen("/dev/acd0c", "r");
        fseek(fp, 32808, SEEK_SET);
        fread(buf, 1, 32, fp);
        puts(buf);
        return 0;
}


You should terminate after the fread's number of bytes, not arbitrarily at the end of the buffer. If the erase-backwards or carriage-return characters appear, they will damage the preceding string, and that's no good. If the DVD titles are null terminated within the 32 bytes anyway, then you don't even need to pre-terminate. Either way, what you have now doesn't make much sense.

On that note, it doesn't read from 32768. It reads from 32808, since
that's where it's seeking to.

---
Dmitri Nikulin

Centre for Synchrotron Science
Monash University
Victoria 3800, Australia



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]