Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Oct 2006 15:24:14 +0200
From:      "Alex Unleashed" <unledev@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   mkdir -m option POSIX compliance
Message-ID:  <5e4707340610100624j38ce9f8du7741bd027eb8cb1b@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
------=_Part_3114_11217464.1160486654346
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi all,

"mkdir -m mode -p /some/directory" calls chmod() on /some/directory even if
it already exists, effectively changing the mode. POSIX specifies that this
mode may only be applied to newly created directories. Patch attached.
Please look at the URLs referenced in the patch for further information.

Thanks,

Alex

------=_Part_3114_11217464.1160486654346
Content-Type: text/x-patch; name=mkdir-posixize-mode-option.patch; 
	charset=ANSI_X3.4-1968
Content-Transfer-Encoding: base64
X-Attachment-Id: f_et4bluig
Content-Disposition: attachment; filename="mkdir-posixize-mode-option.patch"

LS0tIGJpbi9ta2Rpci9ta2Rpci5jCTIwMDYtMTAtMTAgMTM6NTg6NTMuMDAwMDAwMDAwICswMjAw
CisrKyBiaW4vbWtkaXIvbWtkaXIuYwkyMDA2LTEwLTEwIDE1OjA5OjMyLjAwMDAwMDAwMCArMDIw
MApAQCAtNjEsMTIgKzYxLDEyIEBACiBpbnQKIG1haW4oaW50IGFyZ2MsIGNoYXIgKmFyZ3ZbXSkK
IHsKLQlpbnQgY2gsIGV4aXR2YWwsIHN1Y2Nlc3MsIHBmbGFnOworCWludCBjaCwgZXhpdHZhbCwg
c3VjY2VzcywgcGZsYWcsIG9sZGRpcmZsYWc7CiAJbW9kZV90IG9tb2RlOwogCXZvaWQgKnNldCA9
IE5VTEw7CiAJY2hhciAqbW9kZTsKIAotCW9tb2RlID0gcGZsYWcgPSAwOworCW9tb2RlID0gcGZs
YWcgPSBvbGRkaXJmbGFnID0gMDsKIAltb2RlID0gTlVMTDsKIAl3aGlsZSAoKGNoID0gZ2V0b3B0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NjEsNyBAQAogCiAJcCA9IHBhdGg7CiAJ
b3VtYXNrID0gMDsKLQlyZXR2YWwgPSAwOworCXJldHZhbCA9IDE7CiAJaWYgKHBbMF0gPT0gJy8n
KQkJLyogU2tpcCBsZWFkaW5nICcvJy4gKi8KIAkJKytwOwogCWZvciAoZmlyc3QgPSAxLCBsYXN0
ID0gMDsgIWxhc3QgOyArK3ApIHsKQEAgLTE3NCw3ICsxOTYsNyBAQAogCQkJaWYgKGVycm5vID09
IEVFWElTVCB8fCBlcnJubyA9PSBFSVNESVIpIHsKIAkJCQlpZiAoc3RhdChwYXRoLCAmc2IpIDwg
MCkgewogCQkJCQl3YXJuKCIlcyIsIHBhdGgpOwotCQkJCQlyZXR2YWwgPSAxOworCQkJCQlyZXR2
YWwgPSAwOwogCQkJCQlicmVhazsKIAkJCQl9IGVsc2UgaWYgKCFTX0lTRElSKHNiLnN0X21vZGUp
KSB7CiAJCQkJCWlmIChsYXN0KQpAQCAtMTgyLDEyICsyMDQsMTUgQEAKIAkJCQkJZWxzZQogCQkJ
CQkJZXJybm8gPSBFTk9URElSOwogCQkJCQl3YXJuKCIlcyIsIHBhdGgpOwotCQkJCQlyZXR2YWwg
PSAxOworCQkJCQlyZXR2YWwgPSAwOwogCQkJCQlicmVhazsKIAkJCQl9CisJCQkJLyogSXQncyBh
IGRpcmVjdG9yeSwgYW5kIHdlIGRpZG4ndCBjcmVhdGUgaXQgKi8KKwkJCQlpZiAobGFzdCkKKwkJ
CQkJcmV0dmFsID0gMjsKIAkJCX0gZWxzZSB7CiAJCQkJd2FybigiJXMiLCBwYXRoKTsKLQkJCQly
ZXR2YWwgPSAxOworCQkJCXJldHZhbCA9IDA7CiAJCQkJYnJlYWs7CiAJCQl9CiAJCX0gZWxzZSBp
ZiAodmZsYWcpCg==
------=_Part_3114_11217464.1160486654346--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5e4707340610100624j38ce9f8du7741bd027eb8cb1b>