[PATCH] stat: reformat quoted file names

Seb sbb at tuxfamily.org
Sat Jun 12 15:45:15 UTC 2010


Hello,

I noticed that the stat "quoted filename with dereferenced symbolic link" format
significantly differs with the GNU implementation (in "_install/" is the Busybox
implementation):

$ _install/bin/stat /dev/cdrom
  File: "/dev/cdrom -> hdb"
  Size: 3               Blocks: 0          IO Block: 4096   symbolic link
Device: ch/12d  Inode: 5325        Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2010-06-12 16:21:31.000000000
Modify: 2010-06-12 18:21:28.000000000
Change: 2010-06-12 18:21:28.000000000

$ /bin/stat /dev/cdrom
  File: `/dev/cdrom' -> `hdb'
  Size: 3               Blocks: 0          IO Block: 4096   symbolic link
Device: ch/12d  Inode: 5325        Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2010-06-12 17:23:51.278714942 +0200
Modify: 2010-06-12 18:21:28.187900425 +0200
Change: 2010-06-12 18:21:28.187900425 +0200

$ _install/bin/stat -c "%N" /dev/cdrom
/tmp -> /dev/shm

$ /bin/stat -c "%N" /dev/cdrom
`/dev/cdrom' -> `hdb'

As most of the scripts that rely on the stat output will certainly expect a GNU
stat fashion, maybe it would be a good idea to follow this one.

To help in this way, I tried to make a patch (in attachment). It seems to work,
but my C skill does not allow me to be sure of anything, so probably there is
better code to do if you find the suggestion acceptable. :)

++
Seb.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: busybox-1.16.2-stat.patch
Type: application/octet-stream
Size: 2897 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20100612/245c16e8/attachment.obj>


More information about the busybox mailing list