Duplicates in /proc/partitions

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Aug 17 13:51:54 GMT 2021


On Aug 17 12:57, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via Cygwin wrote:
> > $ gcc -g -O2 -o proc_partition_O2 proc_partition.c -lntdll
> 
> I ran the program (without gdb yet, can't doit right away)... Its
> output is a bit different from /proc/partitions (w.r.t. drive names),

Yes, it's just faked in the most dirt-simple way.  I added a comment to
the code to outline why that is.

> but I still see the duplicates:

Great!  That means it should be pretty straightforward to see why the
problem occurs by stepping through the code.  For a start I'd suggest
to set a breakpoint to line 103, that's the first DeviceIoControl call.
That line is only reached for actual disks when looping over the
native \Device directory.

On second thought, I have a vague idea...  Could you please just add
something to the output, i.e, change lines 124/125 from

    printf ("%5d %5d %9llu sd%c\n",
            8, (dev_name - 'a') * 16, size >> 10, dev_name);

to

    printf ("%5d %5d %9llu sd%c (%lu)\n",
            8, (dev_name - 'a') * 16, size >> 10, dev_name,
            (unsigned long) context);

and just compile and run the testcase again?


Thanks,
Corinna


More information about the Cygwin mailing list