~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to src/mknod.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* mknod -- make special files
2
 
   Copyright (C) 1990-1991, 1995-2011 Free Software Foundation, Inc.
 
2
   Copyright (C) 1990-2012 Free Software Foundation, Inc.
3
3
 
4
4
   This program is free software: you can redistribute it and/or modify
5
5
   it under the terms of the GNU General Public License as published by
28
28
#include "quote.h"
29
29
#include "xstrtol.h"
30
30
 
31
 
/* The official name of this program (e.g., no `g' prefix).  */
 
31
/* The official name of this program (e.g., no 'g' prefix).  */
32
32
#define PROGRAM_NAME "mknod"
33
33
 
34
34
#define AUTHORS proper_name ("David MacKenzie")
46
46
usage (int status)
47
47
{
48
48
  if (status != EXIT_SUCCESS)
49
 
    fprintf (stderr, _("Try `%s --help' for more information.\n"),
50
 
             program_name);
 
49
    emit_try_help ();
51
50
  else
52
51
    {
53
52
      printf (_("Usage: %s [OPTION]... NAME TYPE [MAJOR MINOR]\n"),
121
120
        }
122
121
    }
123
122
 
124
 
  newmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
 
123
  newmode = MODE_RW_UGO;
125
124
  if (specified_mode)
126
125
    {
127
126
      struct mode_change *change = mode_compile (specified_mode);
135
134
    }
136
135
 
137
136
  /* If the number of arguments is 0 or 1,
138
 
     or (if it's 2 or more and the second one starts with `p'), then there
 
137
     or (if it's 2 or more and the second one starts with 'p'), then there
139
138
     must be exactly two operands.  Otherwise, there must be four.  */
140
139
  expected_operands = (argc <= optind
141
140
                       || (optind + 1 < argc && argv[optind + 1][0] == 'p')
169
168
           quote (scontext));
170
169
 
171
170
  /* Only check the first character, to allow mnemonic usage like
172
 
     `mknod /dev/rst0 character 18 0'. */
 
171
     'mknod /dev/rst0 character 18 0'. */
173
172
 
174
173
  switch (argv[optind + 1][0])
175
174
    {
176
 
    case 'b':                   /* `block' or `buffered' */
 
175
    case 'b':                   /* 'block' or 'buffered' */
177
176
#ifndef S_IFBLK
178
177
      error (EXIT_FAILURE, 0, _("block special files not supported"));
179
178
#else
181
180
#endif
182
181
      goto block_or_character;
183
182
 
184
 
    case 'c':                   /* `character' */
185
 
    case 'u':                   /* `unbuffered' */
 
183
    case 'c':                   /* 'character' */
 
184
    case 'u':                   /* 'unbuffered' */
186
185
#ifndef S_IFCHR
187
186
      error (EXIT_FAILURE, 0, _("character special files not supported"));
188
187
#else
218
217
      }
219
218
      break;
220
219
 
221
 
    case 'p':                   /* `pipe' */
 
220
    case 'p':                   /* 'pipe' */
222
221
      if (mkfifo (argv[optind], newmode) != 0)
223
222
        error (EXIT_FAILURE, errno, "%s", quote (argv[optind]));
224
223
      break;