From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu Subject: Re: [9fans] how to delete directories prefixed with a dash From: Charles Forsyth Date: Wed, 16 Jun 2004 06:39:32 +0100 In-Reply-To: <84f5cde727c85591db7049828fdae03f@9netics.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: a29f8a9e-eacd-11e9-9e20-41e7f4b1d025 -p is one thing i suppose, but -m 777 seems a little pointless. actually, -m probably is fairly pointless all round. as on Unix, on Plan 9 it probably doesn't do what you might think, although Unix and Plan 9 don't do that in different ways. on Unix it applies only to the last component and is subject to umask, and intervening directories get -m $(umask -S),u+wx; on Plan 9 the mode applies to all directories (so -m 555 -p not/there/yet won't work at all) and in each case is subject to masking by the parent directory permissions, so -m 777 produces completely-writable directories only if the old create(..., DMDIR|0777) would have done anyway. now on Plan 9, mkdir -p -m 700 ... does make a difference (starting in a directory with mode 755 say) and will set the mode 700 on each new directory; although that differs from Unix where with my umask 022 i get 755 directories up to the last created, which is 700. of course in all cases, on Plan 9 and Unix, if mkdir doesn't create the directory (eg, intervening ones with -p), it doesn't change the mode, so be sure to do rm -r or rm -r -- first. that's presumably why the Unix one has the definition it's got. it's not that useful but it behaves consistently not-that-usefully with -p regardless whether the directories are created or not. at least i think so; that's what the Unix manual pages and code suggests, supported by experiment on Plan 9 and Unix. all in all, i confess i did wonder when it appeared several months ago why -m was in Plan 9 outside APE. still it's only 80 lines compared with 212 on FreeBSD (but then that includes the BSD copyright and licence, and /* * POSIX 1003.2: * For each dir operand that does not name an existing * directory, effects equivalent to those cased by the * following command shall occcur: * * mkdir -p man 2 $(dirname dir) && * mkdir [-m mode] dir * * We change the user's umask and then restore it, * instead of doing chmod's. */ and /* * The mkdir() and umask() calls both honor only the low * nine bits, so if you try to set a mode including the * sticky, setuid, setgid bits you lose them. Don't do * this unless the user has specifically requested a mode, * as chmod will (obviously) ignore the umask. */ i wonder why i got out of bed this morning. after the above, you'll probably wish i'd stayed there too!