[Patch] Avoid duplicate names in /proc/registry (which may crash find)

Christian Franke Christian.Franke@t-online.de
Fri Dec 5 22:24:00 GMT 2008

Corinna Vinschen wrote:
> On Dec  4 21:49, Christian Franke wrote:
>> Here is a simple approach to handle the duplicate key/value name problem in 
>> /proc/registry. A value is skipped if key with same name exists. Number of 
>> actual key existence checks are reduced by a simple hash table.
>> ...
> That looks like a quite neat idea to rectify this problem but, now that
> I think of it I'm wondering if this isn't a good starting point for
> a better solution as you proposed on the Cygwin list.

Yes, it is ... see below.

> So let's assume there's a key and a value with the same name. 
> The old implementation just ignored the problem.  Trying to access the
> value failed because the value was simply shadowed by the key.  `cat
> foo' returned "is a directory" or something.
> The now proposed solution hides the value instead.  There just isn't a
> value of that name anymore.  In the end, the result is the same.
> Accessing the value still doesn't work.

The hidden value also prevents that the key is scanned twice by find and ls.

> However, since these value were never accessible, doesn't that mean
> there is no backward compatibility problem if we actually change the
> name of the values instead to, say, foo.val?  That's what you proposed
> on the main list, right?
> Is the above line of thought correct?  If yes, together with your hash
> table it would be quite simle to implement this.  We would just have to
> think of a good value for ".val".  Unfortunately, there's no character
> disallowed in the registry names, not even a \0 :(

Yes, and \0 is reportedly used at least by some copy protection software.

> Maybe ".val" is already a good suffix?

I would prefer "%val" to avoid any extra encoding for names using 
".val". The "%" is already used as an escape char, so "%val" in a name 
would appear as "%25val"

With the attached patch, a duplicate name "foo" is handled as follows:

- readdir() returns the key as "foo" and the value as "foo%val".
- If the name is "foo%val", stat() and open() consider only the value "foo".

This keeps the names 'as is' if possible and allows access to the (very 
few) entries with duplicate names. The "%val" is at least somewhat 


$ ls -l 
dr--r-x--- 3 Administratoren SYSTEM   0 Mar 29  2005 Security
dr--r-x--- 3 Administratoren SYSTEM   0 Mar 29  2005 Security Account 
-r--r----- 1 Administratoren SYSTEM 168 Mar 29  2005 Security%val


-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygwin-1.7-registry-nodups-2.patch
Type: text/x-patch
Size: 8685 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20081205/511dc2a8/attachment.bin>

More information about the Cygwin-patches mailing list