public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Symlink file size
@ 2017-03-08  3:38 Steven Penny
  2017-03-08  4:05 ` Ken Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Penny @ 2017-03-08  3:38 UTC (permalink / raw)
  To: cygwin

Cygwin seems to have no way to print an accurate size of a symlink. Consider
this command:

    $ touch alfa.txt
    $ CYGWIN= ln -s alfa.txt bravo.txt

Now cmd.exe can print the correct size just fine:

    > dir /AS
    2017-03-07  09:26 PM                30 bravo.txt

However Cygwin prints incorrect 8 bytes with ls:

    $ ls -l
    total 2
    -rw-r--r-- 1 Steven None 0 Mar  7 21:26 alfa.txt
    lrwxrwxrwx 1 Steven None 8 Mar  7 21:26 bravo.txt -> alfa.txt

and stat:

    $ stat --format %s bravo.txt
    8

and du:

    $ du -b bravo.txt
    8       bravo.txt

and find:

    $ find bravo.txt -printf %s
    8

wc seems to draw from the source file:

    $ wc -c bravo.txt
    0 bravo.txt

What gives?


--
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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Symlink file size
  2017-03-08  3:38 Symlink file size Steven Penny
@ 2017-03-08  4:05 ` Ken Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Ken Brown @ 2017-03-08  4:05 UTC (permalink / raw)
  To: cygwin

On 3/7/2017 10:37 PM, Steven Penny wrote:
> Cygwin seems to have no way to print an accurate size of a symlink.
> Consider
> this command:
>
>    $ touch alfa.txt
>    $ CYGWIN= ln -s alfa.txt bravo.txt
>
> Now cmd.exe can print the correct size just fine:
>
>    > dir /AS
>    2017-03-07  09:26 PM                30 bravo.txt
>
> However Cygwin prints incorrect 8 bytes with ls:
>
>    $ ls -l
>    total 2
>    -rw-r--r-- 1 Steven None 0 Mar  7 21:26 alfa.txt
>    lrwxrwxrwx 1 Steven None 8 Mar  7 21:26 bravo.txt -> alfa.txt

8 is the length of the file name "alfa.txt".  From 
https://linux.die.net/man/2/stat:  "The size of a symbolic link is the 
length of the pathname it contains, without a terminating null byte."

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-08  4:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-08  3:38 Symlink file size Steven Penny
2017-03-08  4:05 ` Ken Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).