Changeset 2615

Show
Ignore:
Timestamp:
10/11/07 22:37:56 (1 year ago)
Author:
dhozac
Message:

Add support for vc_unset_mapping introduced in 2.3.0.27.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/kernel/device_cmd.h

    r2427 r2615  
    66 
    77#define VCMD_set_mapping        VC_CMD(DEVICE, 1, 0) 
     8#define VCMD_unset_mapping      VC_CMD(DEVICE, 2, 0) 
    89 
    910struct  vcmd_set_mapping_v0 { 
  • trunk/lib/Makefile-files

    r2589 r2615  
    131131                                lib/syscall_setmapping.c \ 
    132132                                lib/syscall_setmapping-v21.hc \ 
     133                                lib/syscall_unsetmapping.c \ 
     134                                lib/syscall_unsetmapping-v21.hc \ 
    133135                                lib/syscall_schedinfo.c \ 
    134136                                lib/syscall_schedinfo-v21.hc \ 
  • trunk/lib/vserver.h

    r2589 r2615  
    814814    /* misc. syscalls */ 
    815815  int           vc_set_mapping(xid_t xid, const char *device, const char *target, uint32_t flags); 
     816  int           vc_unset_mapping(xid_t xid, const char *device, const char *target, uint32_t flags); 
    816817 
    817818 
  • trunk/scripts/vserver.functions

    r2613 r2615  
    12761276                        ${device:+--device "$device"} ${target:+--target "$target"} ) 
    12771277 
    1278         $_VDEVMAP --xid "$xid" "${vdevmap_opts[@]}" || return $? 
     1278        $_VDEVMAP --xid "$xid" --set "${vdevmap_opts[@]}" || return $? 
    12791279    done 
    12801280} 
  • trunk/src/vdevmap.c

    r2490 r2615  
    4444  { "version",    no_argument,       0, CMD_VERSION }, 
    4545  { "xid",        required_argument, 0, 'x' }, 
     46  { "set",        no_argument,       0, 's' }, 
     47  { "unset",      no_argument,       0, 'u' }, 
    4648  { "open",       no_argument,       0, 'o' }, 
    4749  { "create",     no_argument,       0, 'c' }, 
     
    5961  WRITE_STR(fd, cmd); 
    6062  WRITE_MSG(fd, 
    61             " --xid <xid> [--flags <flags>] [--open] [--create] [--remap] [--device <dev>] [--target <dev>]\n" 
     63            " --xid <xid> {--set|--unset} [--flags <flags>] [--open] [--create]\n" 
     64            "        [--device <dev>] [--remap --target <dev>]\n" 
     65            "\n" 
     66            "    --flags <flags>     Set the specified flags\n" 
     67            "    --open              Allow opening of the device\n" 
     68            "    --create            If SECURE_MKNOD is given, allow mknod(2)\n" 
     69            "    --device <dev>      Device to apply the command to\n" 
     70            "    --remap             Remap the device to the target\n" 
     71            "    --target <dev>      Target for --remap\n" 
    6272            "\n" 
    6373            "Please report bugs to " PACKAGE_BUGREPORT "\n"); 
     
    8696  char          *device         = NULL; 
    8797  char          *target         = NULL; 
     98  bool          set             = true; 
    8899  unsigned long tmp             = 0; 
    89100   
    90101  while (1) { 
    91     int         c = getopt_long(argc, argv, "+x:ocrf:d:t:", CMDLINE_OPTIONS, 0); 
     102    int         c = getopt_long(argc, argv, "+x:suocrf:d:t:", CMDLINE_OPTIONS, 0); 
    92103    if (c==-1) break; 
    93104 
     
    101112      case 'd'          :  device = optarg;                     break; 
    102113      case 't'          :  target = optarg;                     break; 
     114      case 's'          :  set = 1;                             break; 
     115      case 'u'          :  set = 0;                             break; 
    103116      case 'f'          : 
    104117        if (!isNumberUnsigned(optarg, &tmp, false)) { 
     
    124137  if (do_remap)         flags |= VC_DATTR_REMAP; 
    125138 
    126   if (xid==VC_NOCTX) 
     139  if (target && !do_remap) 
     140    WRITE_MSG(2, "Target specified without --remap; try '--help' for more information\n"); 
     141  else if (xid==VC_NOCTX) 
    127142    WRITE_MSG(2, "No xid specified; try '--help' for more information\n"); 
    128143  else if (optind!=argc) 
    129144    WRITE_MSG(2, "Unused argument(s); try '--help' for more information\n"); 
    130   else if (vc_set_mapping(xid, device, target, flags)==-1) 
     145  else if (set && vc_set_mapping(xid, device, target, flags)==-1) 
    131146      perror("vc_set_mapping()"); 
     147  else if (!set && vc_unset_mapping(xid, device, target, flags)==-1) 
     148      perror("vc_unset_mapping()"); 
    132149  else 
    133150    return EXIT_SUCCESS;