[DVDnav-discuss] dvdnav patches from handbrake project

Erik Hovland erik at hovland.org
Thu Jul 8 05:24:15 CEST 2010


>>> To keep things organized, here's current status of these patches.
>>> These are pending:
>>>     * read-block2char.patch
>>
>> This one is really disturbing me:
>>> Index: libdvdread/src/dvd_reader.c
>>> ===================================================================
>>> --- libdvdread/src/dvd_reader.c    (revision 1194)
>>> +++ libdvdread/src/dvd_reader.c    (working copy)
>>> @@ -318,7 +318,7 @@
>>>    char *new_path;
>>>
>>>    /* If it doesn't start with "/dev/" or does start with "/dev/r"
>>> exit */
>>> -  if( !strncmp( path, "/dev/",  5 ) || strncmp( path, "/dev/r", 6 ) )
>>> +  if( strncmp( path, "/dev/",  5 ) || !strncmp( path, "/dev/r", 6 ) )
>>>      return (char *) strdup( path );
>>>
>>>    /* Replace "/dev/" with "/dev/r" */
>>
>> The function is supposed to replace -on most BSDs- access to a block
>> device to the equivalent raw device,
>> returning in a string the correct device name to use.
>> Now, it's true that in the current code the comment reads one thing
>> and the code does the exact opposite, but
>> both the original code and the patched one don't make sense to me:
>> -if the string starts with /dev/ it's not necesserily correct or wrong
>> -it the string starts with /dev/r it IS correct and doesn't need to be
>> replaced, so
>> return (char *) strdup( path );
>> is fine
>>
>> In practice to me the right code to use seems:
>>   /* If the string starts with "/dev/r"  then return it */
>>   if(!strncmp( path, "/dev/r", 6 ) )
>>     return (char *) strdup( path );
>>
>>
>> of course if the string doesn't start with /dev/ it's wrong, but this
>> is the idiot's business (that didn't specify a correct
>> device to use).
>> Am I missing something?
>>
> I think the idea here is that the name should only be changed if it is a
> standard system device.  The user could create his own device node
> elsewhere in the filesystem and use it.  In this case, modifying the
> name would make it fail where it would have succeeded if you had not
> modified the name (assuming the user knew what he was doing and created
> a raw block device).

Nico, where do you stand on this?

 I finally stared at this enough to agree w/ John. If the user gives something
outside of /dev assume they think they know better, dup and move on. If the
device filename string starts w/  /dev/r then dup and move on. Otherwise take
whatever /dev/<blah> is there and slap an r in it for /dev/r<blah>. This seems
highly kludgy just assuming that something in /dev w/out an r is usable - it
would probably make the most sense to find out if the given device is a block
device and then ask it for its raw counterpart. I would prefer to leave those
OS specific things up to people who actually use this platform. If this makes
handbrake work on OS X/darwin  then fine w/ me.

E

-- 
Erik Hovland
erik at hovland.org
http://hovland.org/


More information about the DVDnav-discuss mailing list