annotate toys/posix/mkfifo.c @ 941:62ba5ce62e9d 0.4.5

Make ls output major, minor for block devices.
author Rob Landley <rob@landley.net>
date Mon, 01 Jul 2013 00:10:28 -0500
parents 6cc69be43c42
children 57f2a26fa92c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
1 /* mkfifo.c - Create FIFOs (named pipes)
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
2 *
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
3 * Copyright 2012 Georgi Chorbadzhiyski <georgi@unixsol.org>
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
4 *
656
6df4ccc0acbe Regularize command headers, update links to standards documents.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
5 * See http://opengroup.org/onlinepubs/9699919799/utilities/mkfifo.html
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
6
551
2548e6e590b2 Add string to mode_t parser
Daniel Walter <d.walter@0x90.at>
parents: 531
diff changeset
7 USE_MKFIFO(NEWTOY(mkfifo, "<1m:", TOYFLAG_BIN))
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
8
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
9 config MKFIFO
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
10 bool "mkfifo"
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
11 default y
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
12 help
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
13 usage: mkfifo [fifo_name...]
531
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
14
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
15 Create FIFOs (named pipes).
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
16 */
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
17
674
7e846e281e38 New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
18 #define FOR_mkfifo
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
19 #include "toys.h"
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
20
674
7e846e281e38 New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
21 GLOBALS(
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
22 char *m_string;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
23 mode_t mode;
531
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
24 )
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
25
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
26 void mkfifo_main(void)
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
27 {
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
28 char **s;
531
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
29
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
30 TT.mode = 0666;
771
4ca4134dad17 mkfifo -m is already implemented.
Felix Janda <felix.janda@posteo.de>
parents: 694
diff changeset
31 if (toys.optflags & FLAG_m) TT.mode = string_to_mode(TT.m_string, 0);
531
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
32
780
6cc69be43c42 Have error_msg() and friends set TT.exitval to 1 if it's still 0, clean out other places that were setting it that no longer need to.
Rob Landley <rob@landley.net>
parents: 771
diff changeset
33 for (s = toys.optargs; *s; s++)
6cc69be43c42 Have error_msg() and friends set TT.exitval to 1 if it's still 0, clean out other places that were setting it that no longer need to.
Rob Landley <rob@landley.net>
parents: 771
diff changeset
34 if (mknod(*s, S_IFIFO | TT.mode, 0) < 0) perror_msg("%s", *s);
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
35 }