Print this page
4833 Remove volrmmount
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/rmformat/rmf_misc.c
          +++ new/usr/src/cmd/rmformat/rmf_misc.c
↓ open down ↓ 9 lines elided ↑ open up ↑
  10   10   * See the License for the specific language governing permissions
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20      - */
  21      -
  22      -/*
       20 + *
       21 + *
  23   22   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24   23   * Use is subject to license terms.
       24 + *
       25 + * Copyright 2014 Andrew Stormont.
  25   26   */
  26   27  
  27   28  /*
  28   29   * rmf_misc.c :
  29   30   *      Miscelleneous routines for rmformat.
  30   31   */
  31   32  
  32   33  #include <sys/types.h>
  33   34  #include <stdio.h>
  34   35  #include <sys/mnttab.h>
↓ open down ↓ 45 lines elided ↑ open up ↑
  80   81  
  81   82  /*
  82   83   * ON-private functions from libvolmgt
  83   84   */
  84   85  int     _dev_mounted(char *path);
  85   86  
  86   87  /*
  87   88   * Function prototypes.
  88   89   */
  89   90  static int              my_umount(char *mountp);
  90      -static int              my_volrmmount(char *real_name);
       91 +static int              my_rmmount(char *real_name);
  91   92  static int              vol_name_to_dev_node(char *vname, char *found);
  92   93  static int              vol_lookup(char *supplied, char *found);
  93   94  static device_t         *get_device(char *user_supplied, char *node);
  94   95  static char             *get_physical_name(char *path);
  95   96  static int              lookup_device(char *supplied, char *found);
  96   97  static void             fini_device(device_t *dev);
  97   98  static int              is_cd(char *node);
  98   99  void                    *my_zalloc(size_t size);
  99  100  void                    err_msg(char *fmt, ...);
 100  101  int                     inquiry(int fd, uchar_t *inq);
↓ open down ↓ 153 lines elided ↑ open up ↑
 254  255                  return (-1);
 255  256  
 256  257          /*
 257  258           * To find out whether the device has been mounted by
 258  259           * volume manager...
 259  260           *
 260  261           * Convert the real name to a block device address.
 261  262           * Do a partial match with the mnttab entries.
 262  263           * Make sure the match is in the beginning to avoid if
 263  264           * anybody puts a label similiar to volume manager path names.
 264      -         * Then use "volrmmount -e <dev_name>" if -U flag is set.
      265 +         * Then use "rmmount -u <dev_name>" if -U flag is set.
 265  266           */
 266  267  
 267  268          nl = strlen("/vol/dev/");
 268  269  
 269  270          if (strncmp(real_name, "/vol/dev/", nl) != 0)
 270  271                          return (0);
 271  272          if (real_name[nl] == 'r') {
 272  273                  (void) snprintf(tmp_path_name, PATH_MAX, "%s%s", "/vol/dev/",
 273  274                      &real_name[nl + 1]);
 274  275          } else {
↓ open down ↓ 34 lines elided ↑ open up ↑
 309  310                          continue;
 310  311                  } else {
 311  312                          DPRINTF1("Found!! %s\n", mntp->mnt_special);
 312  313                          ret_val = 1;
 313  314                          break;
 314  315                  }
 315  316          }
 316  317  
 317  318          if (ret_val == 1) {
 318  319                  if (flag) {
 319      -                        if (my_volrmmount(real_name) < 0) {
      320 +                        if (my_rmmount(real_name) < 0) {
 320  321                                  ret_val = -1;
 321  322                          }
 322  323                  } else {
 323  324                          ret_val = -1;
 324  325                  }
 325  326          }
 326  327          (void) fclose(fp);
 327  328          free(mntp);
 328  329          return (ret_val);
 329  330  }
↓ open down ↓ 731 lines elided ↑ open up ↑
1061 1062                          if (WEXITSTATUS(rval) == 0) {
1062 1063                                  DPRINTF("umount : Success\n");
1063 1064                                  return (1);
1064 1065                          }
1065 1066                  }
1066 1067          }
1067 1068          return (-1);
1068 1069  }
1069 1070  
1070 1071  static int
1071      -my_volrmmount(char *real_name)
     1072 +my_rmmount(char *real_name)
1072 1073  {
1073 1074          int pid, rval;
1074 1075  
1075 1076          /* Turn on the privileges. */
1076 1077          (void) __priv_bracket(PRIV_ON);
1077 1078  
1078 1079          pid = fork();
1079 1080  
1080 1081          /* Turn off the privileges. */
1081 1082          (void) __priv_bracket(PRIV_OFF);
1082 1083  
1083 1084          /* create a child to unmount the path */
1084 1085          if (pid < 0) {
1085 1086                  PERROR("fork failed");
1086 1087                  exit(0);
1087 1088          }
1088 1089  
1089 1090          if (pid == 0) {
1090 1091                  /* the child */
1091 1092                  /* get rid of those nasty err messages */
1092      -                DPRINTF1("call_unmount_prog: calling %s \n",
1093      -                    "/usr/bin/volrmmount");
     1093 +                DPRINTF1("call_unmount_prog: calling %s\n",
     1094 +                    "/usr/bin/rmmount");
1094 1095  
1095 1096                  /* Turn on the privileges. */
1096 1097                  (void) __priv_bracket(PRIV_ON);
1097      -                if (execl("/usr/bin/volrmmount", "/usr/bin/volrmmount", "-e",
     1098 +                if (execl("/usr/bin/rmmount", "/usr/bin/rmmount", "-u",
1098 1099                      real_name, NULL) < 0) {
1099      -                        PERROR("volrmmount exec failed");
     1100 +                        PERROR("rmmount exec failed");
1100 1101                          /* Turn off the privileges */
1101 1102                          (void) __priv_bracket(PRIV_OFF);
1102 1103                          exit(-1);
1103 1104                  }
1104 1105          } else if (waitpid(pid, &rval, 0) == pid) {
1105 1106                  if (WIFEXITED(rval)) {
1106 1107                          if (WEXITSTATUS(rval) == 0) {
1107      -                                DPRINTF("volrmmount: Success\n");
     1108 +                                DPRINTF("rmmount: Success\n");
1108 1109                                  return (1);
1109 1110                          }
1110 1111                  }
1111 1112          }
1112 1113          return (-1);
1113 1114  }
1114 1115  
1115 1116  int
1116 1117  find_device(int defer, char *tmpstr)
1117 1118  {
↓ open down ↓ 35 lines elided ↑ open up ↑
1153 1154  #endif
1154 1155                  if (!lookup_device(sdev, dev)) {
1155 1156                          continue;
1156 1157                  }
1157 1158                  if ((t_dev = get_device(NULL, dev)) == NULL) {
1158 1159                          continue;
1159 1160                  }
1160 1161                  total_devices_found++;
1161 1162  
1162 1163                  if ((!defer) && !found) {
1163      -                        char *sn, *tmpbuf;
     1164 +                        char *sn, *tmpbuf = NULL;
1164 1165                          /*
1165 1166                           * dev_name is an optional command line input.
1166 1167                           */
1167 1168                          if (dev_name) {
1168 1169                                  if (strstr(dirent->d_name, tmpstr)) {
1169 1170                                          found = 1;
1170 1171                                  } else if (!vol_running) {
1171 1172                                          continue;
1172 1173                                  }
1173 1174                          }
↓ open down ↓ 918 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX