Unix Technical Forum

Re: patch for mkdir: specifying mode for intermediate dirs created by -p

This is a discussion on Re: patch for mkdir: specifying mode for intermediate dirs created by -p within the lucky.openbsd.tech forums, part of the OpenBSD category; --> This is a bad idea. It is an incompatible extension. Then people use it in scripts. Then their scripts ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > lucky.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-22-2008, 12:28 PM
Theo de Raadt
 
Posts: n/a
Default Re: patch for mkdir: specifying mode for intermediate dirs created by -p

This is a bad idea.

It is an incompatible extension.

Then people use it in scripts.

Then their scripts become non-portable.

> Here is a patch for mkdir to add in a -i <mode> option to specify the
> mode of intermediate directories when using -p. This would come in
> very handy for me, don't know if anyone else would even want this, but
> didn't take long to write.
>
> Index: mkdir.c
> ================================================== =================
> RCS file: /home/cvs/src/bin/mkdir/mkdir.c,v
> retrieving revision 1.17
> diff -u -r1.17 mkdir.c
> --- mkdir.c 1 Jul 2004 18:25:47 -0000 1.17
> +++ mkdir.c 21 Apr 2005 20:43:55 -0000
> @@ -79,7 +79,7 @@
> dir_mode = mode | S_IWUSR | S_IXUSR;
>
> pflag = 0;
> - while ((ch = getopt(argc, argv, "m")) != -1)
> + while ((ch = getopt(argc, argv, "i:m")) != -1)
> switch(ch) {
> case 'p':
> pflag = 1;
> @@ -90,6 +90,12 @@
> mode = getmode(set, S_IRWXU | S_IRWXG | S_IRWXO);
> free(set);
> break;
> + case 'i':
> + if ((set = setmode(optarg)) == NULL)
> + errx(1, "invalid file mode: %s", optarg);
> + dir_mode = getmode(set, S_IRWXU | S_IRWXG | S_IRWXO);
> + free(set);
> + break;
> default:
> usage();
> }
> @@ -175,6 +181,6 @@
> void
> usage(void)
> {
> - (void)fprintf(stderr, "usage: %s [-p] [-m mode] dirname
> ...\n", __progname);
> + (void)fprintf(stderr, "usage: %s [-p] [-m mode] [-i imode]
> dirname ...\n", __progname);
> exit(1);
> }


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:28 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com