J
J Krugman
It was my understanding that the mode "field" returned by stat()
(more precisely, the third element in the array returned by stat)
reflects whether a file is a link or not, but I find that this is
not the case, at least on Linux. For example:
$ mkdir test_stat
$ cd test_stat
$ touch file
$ ln file hard
$ ln -s file soft
$ /bin/ls -l
total 0
-rw-r--r-- 2 krugman krugman 0 Jan 12 11:37 file
-rw-r--r-- 2 krugman krugman 0 Jan 12 11:37 hard
lrwxrwxrwx 1 krugman krugman 4 Jan 12 11:37 soft -> file
$ perl -e 'printf "%o\n", (stat)[2] for @ARGV' *
100644
100644
100644
As this shows, a file and links, whether hard or soft, pointing to
it all have the same value for stat's mode "field". What's am I
missing?
How can I tell whether a file is a link or not?
Thanks,
jill
(more precisely, the third element in the array returned by stat)
reflects whether a file is a link or not, but I find that this is
not the case, at least on Linux. For example:
$ mkdir test_stat
$ cd test_stat
$ touch file
$ ln file hard
$ ln -s file soft
$ /bin/ls -l
total 0
-rw-r--r-- 2 krugman krugman 0 Jan 12 11:37 file
-rw-r--r-- 2 krugman krugman 0 Jan 12 11:37 hard
lrwxrwxrwx 1 krugman krugman 4 Jan 12 11:37 soft -> file
$ perl -e 'printf "%o\n", (stat)[2] for @ARGV' *
100644
100644
100644
As this shows, a file and links, whether hard or soft, pointing to
it all have the same value for stat's mode "field". What's am I
missing?
How can I tell whether a file is a link or not?
Thanks,
jill