Duplicates in /proc/partitions

Corinna Vinschen corinna-cygwin@cygwin.com
Thu Aug 19 15:37:38 GMT 2021


On Aug 19 15:15, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via Cygwin wrote:
> > > loop is not working atomically.  If a new object is inserted into the
> > > dir preceeding the currently handled entry (which, on a reliable system
> > > should *never* occur), the entry is moved by one, and the next
> > > NtQueryDirectoryObject call returns the same object again.
> 
> Very interesting...  What would be inserted in the directory on my machine,
> in between the calls in that original test program?  It was the only one
> running there, explicitly, I mean...

This also occurs all the time on my system.  It seems to be quite normal
in fact.  That's the only action explaining that the same entry gets
different context values when running the loop multiple times.  Observing
the changing context value was what gave me the idea to trigger this by
creating a symlink to the \Device dir at a certain iteration in the
loop, and that in turn allowed me to reproduce the problem.

> And exclusion of the loop of partition
> enumeration seemed to cancel the insertion?

Not as such.  Probably this just changed the timing.

> one exhibition of the problem, and the other one on my machine here is
> different, and not well understood, but with the same side effect,
> unfortunately.
> 
> > Anyway, would you mind to test the below new proc_partition.c as well
> 
> Looks promising indeed!  No duplicates:
> 
> $ ./proc_partition
> bytes_read = 34346, context = 461, status = 0x00000000
> major minor  #blocks  name   win-mounts
> 
>     8     0 500107608 sda (461, Harddisk0)
>     8     1    102400 sda1
>     8     2 488280064 sda2    C:\
>     8    16 1000204632 sdb (461, Harddisk1)
>     8    17 1000202240 sdb1    D:\
>     8    32 1000204632 sdc (461, Harddisk2)
>     8    33 1000202240 sdc1    G:\
>     8    48 1000204632 sdd (461, Harddisk3)
>     8    49 1000202240 sdd1    I:\
>     8    64 234431064 sde (461, Harddisk4)
>     8    65 234428416 sde1    F:\
> DeviceIoControl (Harddisk5\Partition0, IOCTL_DISK_GET_PARTITION_INFO{_EX}) 5    8    80         0 sdf (461, Harddisk5)
> 
> > as the latest snapshot I just uploaded to https://cygwin.com/snapshots/?
> 
> I'll have to do that later, not now.  But I'll report once I have a change to try it out.

Great!  Looking forward to it.


Thanks,
Corinna


More information about the Cygwin mailing list