Web lists-archives.com

Re: Symlink file size




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