Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^3: automounted directory status

by DrHyde (Prior)
on Feb 03, 2014 at 12:26 UTC ( #1073194=note: print w/replies, xml ) Need Help??

in reply to Re^2: automounted directory status
in thread automounted directory status

But it *is* answering the question asked. 'Is /mnt/blahblah' writeable now' is not the same question as 'is /mnt/blahblah writeable after it has been autommounted'. You are asking 'is it writeable now'. The canonical way of asking that question is a stat(2) call. As I demonstrated, that is what perl does. It's what your shell probably does too - mine certainly does:

$ strace sh -c "if [ -w /etc ]; then echo Writeable; fi" ... stat("/etc", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0 ...

Which clearly shows that perl is Doing The Right Thing by using stat(2) to check whether the directory is writeable.

Replies are listed 'Best First'.
Re^4: automounted directory status
by AlPaton (Novice) on Feb 03, 2014 at 14:05 UTC
    I am not asking 'What is the UNIX representation of it's status. I am asking 'If I write, will it succeed?' The answer is YES, so that is the answer I should get, not something conditional, like, 'well this is a UNIX system with automounted directories and this directory is not currently mounted so NO, but ask the right question and you will get YES'. Perl is supposed to be portable isnt it?

      I'm sorry, but you are *not* asking "If I write will it succeed". -w doesn't mean that. -w will also return true on filesystems that are full, or are out of inodes. All -w means is "does this resource have a write bit set for the current user".

      Yes, perl is portable. That doesn't mean that you don't have to care about portability. For example, to make your code work on both Windows and Unix you have to care about whether lines of text end in \n or \r\n and to be rather careful about how you open files. Well, dealing with automounters is apparently another of those things where you need to be careful about portability.

        Perhaps I should have said "If I write, is it possible I will succeed". My point is that the documentation (perldoc) clearly states " -w File is writable by effective uid/gid". It does not say "The write flag is set". I appreciate I am going to get nowhere with this argument. It is just irksome to have to revisit a mountain of code to take this into consideration now that our automounted filesystems are more frequently unmounted.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1073194]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2019-05-21 09:33 GMT
Find Nodes?
    Voting Booth?
    Do you enjoy 3D movies?

    Results (132 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!