Changeset 2466

Show
Ignore:
Timestamp:
01/21/07 09:02:44 (2 years ago)
Author:
dhozac
Message:

If it doesn't exist, only error if requested.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/scripts/vserver.start

    r2458 r2466  
    137137    $_VLIMIT     --dir "$VSERVER_DIR"/rlimits --missingok -- \ 
    138138    $_VSCHED     --xid self --force "${OPTS_VSCHED[@]}" -- \ 
    139     $_VSYSCTL    --xid self --dir "$VSERVER_DIR"/sysctl --
    140     $_VUNAME     --xid self --dir "$VSERVER_DIR"/uts    --missingok -- \ 
     139    $_VSYSCTL    --xid self --dir "$VSERVER_DIR"/sysctl --missingok --
     140    $_VUNAME     --xid self --dir "$VSERVER_DIR"/uts    --missingok -- \ 
    141141    "${VSERVER_EXTRA_CMDS[@]}" \ 
    142142    $_VUNAME     --xid self --set -t context="$VSERVER_DIR" -- \ 
  • trunk/src/vsysctl.c

    r2459 r2466  
    4949#define CMD_XID                 0x4000 
    5050#define CMD_DIR                 0x4001 
     51#define CMD_MISSINGOK           0x4002 
    5152 
    5253int             wrapper_exit_code  =  1; 
     
    5859  { "xid",        required_argument, 0, CMD_XID }, 
    5960  { "dir",        required_argument, 0, CMD_DIR }, 
     61  { "missingok",  no_argument,       0, CMD_MISSINGOK }, 
    6062  {0,0,0,0} 
    6163}; 
     
    6769  WRITE_STR(fd, cmd); 
    6870  WRITE_MSG(fd, 
    69             " --xid <xid> --dir <directory> -- <command> <args>*\n" 
     71            " --xid <xid> --dir <directory> [--missingok] -- <command> <args>*\n" 
    7072            "\n" 
    7173            "Please report bugs to " PACKAGE_BUGREPORT "\n"); 
     
    129131  xid_t         xid     = VC_NOCTX; 
    130132  const char    *dir    = NULL; 
     133  bool          missing = false; 
    131134   
    132135  while (1) { 
     
    139142      case CMD_XID      :  xid = Evc_xidopt2xid(optarg, true);  break; 
    140143      case CMD_DIR      :  dir = optarg;                        break; 
     144      case CMD_MISSINGOK:  missing = true;                      break; 
    141145 
    142146      default           : 
     
    156160    Echdir(PROC_SYS_DIRECTORY); 
    157161 
    158     dp = Eopendir(dir); 
    159     while ((de = Ereaddir(dp)) != NULL) { 
    160       if (*de->d_name == '.') 
    161         continue; 
    162       handle_setting(dir, de->d_name); 
     162    dp = opendir(dir); 
     163    if (dp != NULL) { 
     164      while ((de = Ereaddir(dp)) != NULL) { 
     165        if (*de->d_name == '.') 
     166          continue; 
     167        handle_setting(dir, de->d_name); 
     168      } 
     169      Eclosedir(dp); 
    163170    } 
    164     Eclosedir(dp); 
     171    else if (!missing) { 
     172      perror(ENSC_WRAPPERS_PREFIX "opendir"); 
     173      exit(wrapper_exit_code); 
     174    } 
    165175 
    166176    Efchdir(curdir);