Re: win-mounts no longer displays anything when doing "cat /proc/partitions"

2019-09-19 Thread Andrey Repin
Greetings, Hashim Aziz!

> I've been using Cygwin loyally for almost 5 years now, and throughout that
> time have found the win-mounts column invaluable to find a drive or USB's
> /dev/sdX mapping, by doing cat /proc/partitions. I haven't run that command
> in a while, however, and today I realised that this functionality no longer
> seems to work - no Windows drive mapping information displays in the
> win-mounts column, so now I'm unable to determine which drive /dev/sdX
> corresponds to.

$ mountvol
[ snip ]
Possible values for VolumeName along with current mount points are:

\\?\Volume{80006d80-c2bb-4297-93c1-2f6d1a2a8acb}\
C:\
C:\dev\sda1\

\\?\Volume{6833c423-2223-11e4-b07d-806e6f6e6963}\
*** NO MOUNT POINTS ***

\\?\Volume{6833c424-2223-11e4-b07d-806e6f6e6963}\
*** NO MOUNT POINTS ***

\\?\Volume{9d412aba-0e54-4628-9c6b-b84fb18d062a}\
*** NO MOUNT POINTS ***

\\?\Volume{6833c441-2223-11e4-b07d-806e6f6e6963}\
*** NO MOUNT POINTS ***

\\?\Volume{6833c442-2223-11e4-b07d-806e6f6e6963}\
*** NO MOUNT POINTS ***

\\?\Volume{6833c443-2223-11e4-b07d-806e6f6e6963}\
*** NO MOUNT POINTS ***

\\?\Volume{6833c444-2223-11e4-b07d-806e6f6e6963}\
*** NO MOUNT POINTS ***

\\?\Volume{1530eb84-587d-11e9-a744-902b3437d8e4}\
W:\

\\?\Volume{152b5e11-3180-11e4-9bb8-806e6f6e6963}\
R:\

$ cat /proc/partitions
major minor  #blocks  name   win-mounts

8 0  78150744 sda
8 1102400 sda1
8 2131072 sda2
8 3  77916160 sda3   C:\ C:\dev\sda1\
816 488386584 sdb
817 486615520 sdb1
832 312571224 sdc
833 312568641 sdc1
848 488386584 sdd
849 488384512 sdd1
864 0 sde
880 0 sdf
896 0 sdg
8   112 0 sdh

Seems all right on this end.


-- 
With best regards,
Andrey Repin
Friday, September 20, 2019 1:36:47

Sorry for my terrible english...


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: win-mounts no longer displays anything when doing "cat /proc/partitions"

2019-09-19 Thread Brian Inglis
On 2019-09-19 13:51, Hashim Aziz wrote:
> I've been using Cygwin loyally for almost 5 years now, and throughout that
> time have found the win-mounts column invaluable to find a drive or USB's
> /dev/sdX mapping, by doing cat /proc/partitions.

> I haven't run that command in a while, however, and today I realised that
> this functionality no longer seems to work - no Windows drive mapping
> information displays in the win-mounts column, so now I'm unable to determine
> which drive /dev/sdX corresponds to.
> corresponds to. See here for 
> another user who also found this functionality no longer worked for them, 
> which was my impetus in reporting this bug. That user is on Windows XP, and 
> I'm on Windows 7.

XP is unsupported, but I believe Vista, 7, and 8 are still supported so far;
although Vista is no longer supported by MS, and W7 stops next January: Cygwin
support may go after that, if test systems are unavailable to developers.

> Maybe some testing could be done to confirm whether this problem is limited
> to those systems, or whether this really is a Cygwin-wide bug introduced in
> the last year or so.
Please run the following command and post the output, which looks okay on my
Win10 Home Cygwin 64 and 32 (may be redacted/tweaked for provacy/security):

$ head -n99 /proc/{mounts,partitions,version}
==> /proc/mounts <==
C:/.../cygwin64/bin /usr/bin ntfs binary,auto 1 1
C:/.../cygwin64/lib /usr/lib ntfs binary,auto 1 1
C:/.../cygwin64 / ntfs binary,auto 1 1
C: /proc/cygdrive/c ntfs binary,posix=0,user,noumount,auto 1 1
D: /proc/cygdrive/d ntfs binary,posix=0,user,noumount,auto 1 1
G: /proc/cygdrive/g ntfs binary,posix=0,user,noumount,auto 1 1

==> /proc/partitions <==
major minor  #blocks  name   win-mounts

8 0 976762584 sda
8 1102400 sda1
8 2 16384 sda2
8 3 975593472 sda3   D:\
8 4   1048576 sda4
816 976762584 sdb
817131072 sdb1
818102400 sdb2
819 975561267 sdb3   C:\
820498688 sdb4
821465920 sdb5   G:\
832 0 sdc

==> /proc/version <==
CYGWIN_NT-10.0-17763 version 3.0.7-338.x86_64 (corinna@calimero) (gcc version
7.4.0 20181206 (Fedora Cygwin 7.4.0-1) (GCC) ) 2019-04-30 18:08 UTC


$ head -n99 /proc/{mounts,partitions,version}
==> /proc/mounts <==
C:/.../cygwin32/bin /usr/bin ntfs binary,auto 1 1
C:/.../cygwin32/lib /usr/lib ntfs binary,auto 1 1
C:/.../cygwin32 / ntfs binary,auto 1 1
C: /proc/cygdrive/c ntfs binary,posix=0,user,noumount,auto 1 1
D: /proc/cygdrive/d ntfs binary,posix=0,user,noumount,auto 1 1
G: /proc/cygdrive/g ntfs binary,posix=0,user,noumount,auto 1 1

==> /proc/partitions <==
major minor  #blocks  name   win-mounts

8 0 976762584 sda
8 1102400 sda1
8 2 16384 sda2
8 3 975593472 sda3   D:\
8 4   1048576 sda4
816 976762584 sdb
817131072 sdb1
818102400 sdb2
819 975561267 sdb3   C:\
820498688 sdb4
821465920 sdb5   G:\
832 0 sdc

==> /proc/version <==
CYGWIN_NT-10.0-17763-WOW64 version 3.0.7-338.i686 (corinna@calimero) (gcc
version 7.4.0 20181206 (Fedora Cygwin 7.4.0-1) (GCC) ) 2019-04-30 18:04 UTC

You could also run the command below and post the output:

$ for disk in /dev/sd*; do echo -n $disk$'\t'; cygpath -m $disk; done
/dev/sda//./Disk{4bd9b009-5d00-03ab-9832-ead73d535cfc}
/dev/sda1
//./STORAGE#Volume#{a999e3b3-bde9-11e8-aaeb-806e6f6e6963}#0010#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}
/dev/sda2   //./HarddiskVolume2
/dev/sda3   //./D:
/dev/sda4
//./STORAGE#Volume#{a999e3b3-bde9-11e8-aaeb-806e6f6e6963}#00E8A0D0#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}
/dev/sdb//./Disk{5587aa19-93e2-7ba5-b246-3a88699f35dd}
/dev/sdb1   //./HarddiskVolume5
/dev/sdb2   //./Volume{a0840694-a9dc-4fcf-b01d-b16e175ba289}
/dev/sdb3   //./C:
/dev/sdb4   //./Volume{b89ebfd5-ce50-4e31-acc2-43bc66448219}
/dev/sdb5   //./G:
/dev/sdc//./Disk{6f5f36e2-87ce-3295-78af-8635d1fc904b}
/dev/sdc1   //./E:

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: My C arrays are too large

2019-09-19 Thread Brian Inglis
On 2019-09-18 14:35, Jose Isaias Cabrera wrote:
> Joel Rees, on Wednesday, September 18, 2019 02:38 PM, wrote...
>> 2019年9月14日(土) 3:50 Jose Isaias Cabrera, on
>>> Achim Gratz, on Friday, September 13, 2019 02:39 PM, wrote...
 Blair, Charles E III writes:
> My apologies for failing to reply on-list.  I don't know how :(
> My machine is 64 bit, and I hope I installed the correct version of 
> cygwin.
> This program:
> #include
> int main(){char *a[50][8192];
> return 0;}
> compiles with gcc  (no special options) but gives "Segmentation fault".

 You are creating an automatic variable that's larger than the default
 stack.  You need to enlarge the stack, either during link time or later
 e.g. via
 peflags -x0x80 a.out
>>> This is great! Thanks.

>>> But, let's talk about this a bit... Shouldn't the compiler provide some
>>> warning, and also, it should never blow up with a "Segmentation fault".  I
>>> believe there should be some type of Out Of Memory error, or something like
>>> it.  But now just blow up.  Anyone thinks like me?  Just my 102 Dominican
>>> cents ($1 = $51 Dominican). :-)
>>
>> Well, the behavior of the compiler itself is better discussed on the
>> compiler's forums, although you may need your asbestos suit when you do so.
>>
>> That said, why do you want this variable to be automatic? Why do you want
>> it allocated on the stack?
> 
> I did not say automatically.  I said that the compiler should provide some
> warning about the allocation being larger than the default stack.  And, it
> should not result in a segmentation fault, but instead, the program should 
> error
> out with out of memory, or, at least, "memory allocation is larger than 
> default
> stack."  Not just blow up.

Arrays over about 4KB on the stack are not portable: developers either make them
static local or global arrays for singletons, or malloc(3) dynamic arrays to
allow multiple instances.

As usual with C, gcc makes few default decisions about how compilations should
be performed, as that is very dependent on the target runtime environment,
leaving it to the developer to set the appropriate options for their application
and target environment.

Most development environments are heavy weight systems with GB of memory and
disk, where the final target could be an embedded POS terminal, running some
embedded Windows or Linux, or maybe just QNX or RTEMS.

If you look at Cygwin gcc -v or -### you will see it was configured with
--disable-libssp as default, leaving use of it to the developer's choice.

If you want stack smashing protection (ssp) -fstack-protector look at all the
gcc -fstack-... and -Wstack-... options: you may have to disable optimizations
or selection of some options may be incompatible with some optimizations, set
some warning levels depending on your environment, and add some libraries -lssp.

Cygwin is a popular environment supporting development on Windows for all kinds
of hardware e.g. FPGAs and SoCs, and systems e.g. BSD and Linux, and shares the
same newlib libc/libm libraries used by RTEMS and other embedded systems, except
OS-dependent functions which have to be emulated under Windows.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



win-mounts no longer displays anything when doing "cat /proc/partitions"

2019-09-19 Thread Hashim Aziz
I've been using Cygwin loyally for almost 5 years now, and throughout that time 
have found the win-mounts column invaluable to find a drive or USB's /dev/sdX 
mapping, by doing cat /proc/partitions. I haven't run that command in a while, 
however, and today I realised that this functionality no longer seems to work - 
no Windows drive mapping information displays in the win-mounts column, so now 
I'm unable to determine which drive /dev/sdX corresponds to. See 
here for another user who also 
found this functionality no longer worked for them, which was my impetus in 
reporting this bug. That user is on Windows XP, and I'm on Windows 7. Maybe 
some testing could be done to confirm whether this problem is limited to those 
systems, or whether this really is a Cygwin-wide bug introduced in the last 
year or so.

Thanks,
Hashim

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Odd, is it not? mkdir 'e:\' cannot be undone by rmdir 'e:\' ...

2019-09-19 Thread Ken Brown
On 9/1/2019 1:38 PM, Houder wrote:
> On Fri, 30 Aug 2019 11:54:27, Houder  wrote:

[...]

> As the directory "/foo" had been correctly created, I turned to
> path_conv::check(), which is called when build_fhname() creates
> the path_conv object (also called pc) -- see dtable.cc.
> 
> Examining this (obsure) method in path.cc, I corrected the code
> in 2 places:
> 
> ---
>if (dev.isfs ())
>  {
>//if (strncmp (path, ".\\", 4)) < 1171
>if ( ! strncmp (path, ".\\", 4)) // < [1]
>  {
>if (!tail || tail == path)
>  /* nothing */;
>else if (tail[-1] != '\\')
>  *tail = '\0'; < Ah! (you should not do that!)
>else
>  {
>error = ENOENT;
>return;
>  }
>  }
> 
> [1] this code should be executed only if path == '\\.\' !!

I don't agree with your analysis here.

First, the strncmp() call is testing whether path *starts with* '\\.\', not 
whether path == '\\.\'.  For example, path might be a UNC device name like 
'\\.\c:'.  Second, as the original code indicates (before your correction), we 
do *not* want to execute the code in that case, since we might be mutilating 
the 
device name or incorrectly setting ENOENT.

On the other hand, I agree that there's something wrong with that code snippet. 
Comparing tail with path [which is the class member this->path] makes no sense 
here, because tail is a pointer into path_copy.  So I think line 1173 should 
read

  if (!tail || tail == path_copy)

If this condition fails, then it's legitimate to refer to tail[-1] two lines 
later.

Observe next that path_copy contains no backslashes, so I think line 1175 
should 
probably be

  else if (tail[-1] != '/')

I don't immediately see why we would then set *tail = '\0' in this case, 
because 
I think *tail is already 0 if we get here and tail[-1] != '/'.  But maybe I'm 
missing something.

I need to think about this further, but I wanted to write down my initial 
thoughts before your bug report gets forgotten.

To be continued.

Ken

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: My C arrays are too large

2019-09-19 Thread Jose Isaias Cabrera
>
>
> From: Joel Rees, on Wednesday, September 18, 2019 07:09 PM, wrote...
> 2019年9月19日(木) 5:35 Jose Isaias Cabrera, on
>
>
> Joel Rees, on Wednesday, September 18, 2019 02:38 PM, wrote...
> >
> > 2019年9月14日(土) 3:50 Jose Isaias Cabrera, on
> >
> > >
> > > Achim Gratz, on Friday, September 13, 2019 02:39 PM, wrote...
> > > >
> > > > Blair, Charles E III writes:
> > > > > My apologies for failing to reply on-list.  I don't know how :(
> > > > >
> > > > > My machine is 64 bit, and I hope I installed the correct version 
> of
> > > cygwin.
> > > > >
> > > > > This program:
>
> > > > >
> > > > > #include
> > > > > int main(){char *a[50][8192];
> > > > > return 0;}
> > > > >
>
>
>
> /* programmatic example by Jose Isaias Cabrera
> // reformatting and annotation by Joel Rees
> */
>
> #include, on
>
>
> int main( void )
> {
>char *a[50][8192];
>/* Note that variables declared here are default "auto" allocated. */
>
>return 0;
>/* Note that some optimization settings might
>// entirely optimize the allocation out in recent compilers,
>// or optimize main() to just return 0 to the calling environment,
>// completely removing the allocation.
>*/
> }
>
> > > > > compiles with gcc  (no special options) but gives "Segmentation 
> fault".
> > > >
> > > > You are creating an automatic variable that's larger than the 
> default
> > > > stack.  You need to enlarge the stack, either during link time or 
> later
> > > > e.g. via
> > > >
> > > > peflags -x0x80 a.out
> > >
> > > This is great! Thanks.
> > >
> > > But, let's talk about this a bit... Shouldn't the compiler provide 
> some
> > > warning,
>
>
> It would be nice, yes.
>
> > > and also, it should never blow up with a "Segmentation fault".
>
>
> But we are discussing C, and, frankly, I'd prefer segementation faults to 
> some of
> the possibilities that have been discussed by the engineering teams that work 
> on C
> compilers.
>
> Ada, yes, the compiler is supposed to (mostly) prevent you from writing 
> things that
> give segmentation faults. C, no. It's within the nature of the language 
> itself.
>
> C is specifically designed to allow the programmer to shoot him/herself in 
> the foot,
> and with good reason.
>
> Lately, some reasonable protection is provided, according to the engineering 
> teams'
> consideration of what is reasonable, and there is a lot of argument about 
> what level
> of protection is too much.
>
> > > I
> > > believe there should be some type of Out Of Memory error, or 
> something like
> > > it.  But now just blow up.  Anyone thinks like me?  Just my 102 
> Dominican
> > > cents ($1 = $51 Dominican). :-)
> > >
> >
> > Well, the behavior of the compiler itself is better discussed on the
> > compiler's forums, although you may need your asbestos suit when you do 
> so.
> >
> > That said, why do you want this variable to be automatic?
>
>
> As Eliot says, it might have been more clear if I had said "auto".
>
> Auto in C means local to the function in both visibility and duration, which
> essentially translates to allocation that looks like it's on a stack.
>
> > Why do you want
> > it allocated on the stack?
>
>
> Now, a good introductory software engineering course will usually encourage 
> you to use
> local visibility and duration unless you have a good reason not to. But the 
> larger a
> variable is, the more likely there is to be a good reason for declaring the 
> variable to
> have different scope.
>
> Buffers, for instance, should persist between calls (static duration), and 
> symbol tables
> should usually be visible to all functions that refer to them (extern 
> visibility).
>
> All of that said, you are right to wonder at this behavior.
>
> Modern compilers inherit a lot of anti-optimal best worst practices from the 
> days of
> sixteen-bit addresses.
>
> One of those is combining the flow-of-control stack with the parameter stack 
> in an
> interleaved linked list of local allocations, enabling simple stack-smash 
> attacks.
>
> Locating that overloaded stack in as small a corner of address space as 
> possible is
> another, and it results in trouble anytime you allocate large things on the 
> stack, with
> local visibility, local duration, thus, auto. (This practice is more in the 
> operating
> system scope than in the compiler scope, but the libraries the compiler links 
> in define
> the behavior and give the error messages.)
>
> Yeah, this is a favorite topic of mine, occupying a bit of space in my 
> programming and
> computing related blogs. Non-optimal, but it is what you get:
>
> Either don't allocate large variables and structures on the stack, or use 
> compiler or
> linker flags, or command line tools, to set the object to allocate a large 
> stack.
>
> Or hope you get segment violations instead of silent error