FAQ SearchLogin
Tuxera Home
View unanswered posts | View active topics It is currently Sat Jul 24, 2021 15:06



Post new topic Reply to topic  [ 2 posts ] 
stat returns wrong symlink size 
Author Message

Joined: Mon Sep 05, 2016 18:32
Posts: 1
Post stat returns wrong symlink size
man 2 stat wrote:
The st_size field gives the size of the file (if it is a regular file
or a symbolic link) in bytes. The size of a symbolic link is the
length of the pathname it contains, without a terminating null byte.

Code:
ubuntu@ubuntu:~$ ntfs-3g --version
ntfs-3g 2015.3.14AR.1 integrated FUSE 28
ubuntu@ubuntu:~$ sudo mkfs.ntfs /dev/vdb1 -Q
Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
ubuntu@ubuntu:~$ sudo mount /dev/vdb1 /mnt
ubuntu@ubuntu:~$ cd /mnt
ubuntu@ubuntu:/mnt$ ln -s foobar baz
ubuntu@ubuntu:/mnt$ stat baz
  File: 'baz' -> 'foobar'
  Size: 20           Blocks: 1          IO Block: 4096   symbolic link
Device: fd11h/64785d   Inode: 64          Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-09-05 18:36:15.066261800 +0200
Modify: 2016-09-05 18:36:15.066261800 +0200
Change: 2016-09-05 18:36:15.066261800 +0200
Birth: -

It reported "Size: 20". It should have reported "Size: 6", length of "foobar".
Confirmed on ntfs-3g 2015.3.14AR.1 and ntfs-3g 2016.2.22.


Mon Sep 05, 2016 18:41
Profile

Joined: Fri Aug 24, 2012 21:18
Posts: 30
Post Re: stat returns wrong symlink size
Yes, this does appear to be a bug. NTFS-3G currently uses different conventions for symlinks' st_size in different situations, such as using the size of the reparse point attribute for symlink and junction reparse points. I'm not aware of a good reason why the standard POSIX behavior isn't used. So I've sent a patch to the mailing list to update NTFS-3G to use the standard behavior.


Wed Sep 21, 2016 10:30
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Original forum style by Vjacheslav Trushkin.