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_menu.c
          +++ new/usr/src/cmd/rmformat/rmf_menu.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      -/*
       20 + *
       21 + *
  22   22   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
       24 + *
       25 + * Copyright 2014 Andrew Stormont.
  24   26   */
  25   27  
  26   28  /*
  27   29   * rmf_menu.c :
  28   30   *      Command line options to rmformat are processed in this file.
  29   31   */
  30   32  
  31   33  #include "rmformat.h"
  32   34  #include <sys/smedia.h>
  33   35  #include <priv_utils.h>
↓ open down ↓ 47 lines elided ↑ open up ↑
  81   83          char *buf, int32_t flag, int32_t blocksize, int32_t no_raw_rw);
  82   84  extern void my_perror(char *err_string);
  83   85  extern void write_default_label(smedia_handle_t, int32_t fd);
  84   86  extern int find_device(int defer, char *tmpstr);
  85   87  
  86   88  void overwrite_metadata(int32_t fd, smedia_handle_t handle);
  87   89  
  88   90  int32_t write_sunos_label(int32_t fd, int32_t media_type);
  89   91  
  90   92  int32_t my_open(char *device_name, int32_t flags);
  91      -int32_t check_and_unmount_vold(char *device_name, int32_t flag);
  92      -int32_t check_and_unmount_scsi(char *device_name, int32_t flag);
  93   93  
       94 +int32_t check_and_unmount_scsi(char *device_name, int32_t flag);
  94   95  int32_t check_and_unmount_floppy(int32_t fd, int32_t flag);
  95   96  int32_t get_confirmation(void);
  96   97  
  97   98  
  98   99  static void     process_F_flag(smedia_handle_t handle, int32_t fd);
  99  100  static void     process_w_flag(smedia_handle_t handle);
 100  101  static void     process_W_flag(smedia_handle_t handle);
 101  102  static void     process_R_flag(smedia_handle_t handle);
 102  103  void            process_p_flag(smedia_handle_t handle, int32_t fd);
 103  104  static void     process_c_flag(smedia_handle_t handle);
↓ open down ↓ 5 lines elided ↑ open up ↑
 109  110  static void     process_b_flag(int32_t fd);
 110  111  static void     process_l_flag(void);
 111  112  
 112  113  void
 113  114  process_options()
 114  115  {
 115  116          int32_t fd;
 116  117          smedia_handle_t handle;
 117  118          int32_t m_scsi_umount = 0;
 118  119          int32_t m_flp_umount = 0;
 119      -        int32_t v_device_umount = 0;
 120  120          int32_t umount_required = 0;
 121  121          int32_t removable;
 122  122          int32_t umount_failed = 0;
 123  123          struct dk_minfo media;
 124  124  
 125  125          check_invalid_combinations();
 126  126  
 127  127          if (l_flag && !dev_name) {
 128  128                  process_l_flag();
 129  129                  return;
↓ open down ↓ 32 lines elided ↑ open up ↑
 162  162  
 163  163          if (ioctl(fd, DKIOCGMEDIAINFO, &media) < 0) {
 164  164                  (void) fprintf(stderr,
 165  165                      gettext("No media in specified device\n"));
 166  166                  (void) close(fd);
 167  167                  exit(1);
 168  168          }
 169  169  
 170  170          /* Check if volume manager has mounted this */
 171  171          if (umount_required) {
 172      -                v_device_umount = check_and_unmount_vold(dev_name, U_flag);
 173      -                if (v_device_umount != 1) {
 174      -                        m_scsi_umount = check_and_unmount_scsi(dev_name,
 175      -                            U_flag);
 176      -                        if (m_scsi_umount != 1) {
 177      -                                m_flp_umount = check_and_unmount_floppy(fd,
 178      -                                    U_flag);
 179      -                                if (m_flp_umount != 1) {
 180      -                                        umount_failed = 1;
 181      -                                }
      172 +                m_scsi_umount = check_and_unmount_scsi(dev_name, U_flag);
      173 +                if (m_scsi_umount != 1) {
      174 +                        m_flp_umount = check_and_unmount_floppy(fd, U_flag);
      175 +                        if (m_flp_umount != 1) {
      176 +                                umount_failed = 1;
 182  177                          }
 183  178                  }
 184  179          }
 185  180  
 186  181          if (umount_required && U_flag && umount_failed) {
 187      -                if (v_device_umount || m_scsi_umount || m_flp_umount) {
      182 +                if (m_scsi_umount || m_flp_umount) {
 188  183                          (void) fprintf(stderr,
 189  184                              gettext("Could not unmount device.\n"));
 190  185                          (void) close(fd);
 191  186                          exit(1);
 192  187                  }
 193  188          }
 194  189  
 195  190          if (umount_required && !U_flag) {
 196      -                if (v_device_umount || m_scsi_umount || m_flp_umount) {
      191 +                if (m_scsi_umount || m_flp_umount) {
 197  192                          (void) fprintf(stderr, gettext("Device mounted.\n"));
 198  193                          (void) fprintf(stderr,
 199  194                              gettext("Requested operation can not be \
 200  195  performed on a mounted device.\n"));
 201  196                          (void) close(fd);
 202  197                          exit(1);
 203  198                  }
 204  199          }
 205  200          /* register the fd with the libsmedia */
 206  201          handle = smedia_get_handle(fd);
↓ open down ↓ 94 lines elided ↑ open up ↑
 301  296   * This options should not be used for floppy. However,
 302  297   * if this option is used for floppy, the option will
 303  298   * be forced to SM_FORMAT_HD and smedia_format is called.
 304  299   * Note that smedia_format is a blocked mode format and it
 305  300   * returns only after the complete formatting is over.
 306  301   */
 307  302  
 308  303  static void
 309  304  process_F_flag(smedia_handle_t handle, int32_t fd)
 310  305  {
 311      -        uint32_t format_flag;
      306 +        uint32_t format_flag = 0;
 312  307          int32_t old_per = 0;
 313  308          int32_t new_per, ret_val;
 314  309  
 315  310          if (force_format) {
 316  311                  (void) fprintf(stderr,
 317  312                      gettext("Formatting disk.\n"));
 318  313          } else {
 319  314                  (void) fprintf(stderr,
 320  315                      gettext("Formatting will erase all the data on disk.\n"));
 321  316                  if (!get_confirmation())
↓ open down ↓ 86 lines elided ↑ open up ↑
 408  403  /*
 409  404   * List removable devices.
 410  405   */
 411  406  static void
 412  407  process_l_flag()
 413  408  {
 414  409          int retry;
 415  410          int removable;
 416  411          int total_devices_found_last_time;
 417  412          int defer = 0;
 418      -        char *tmpstr;
      413 +        char *tmpstr = NULL;
 419  414  
 420  415  #define MAX_RETRIES_FOR_SCANNING 3
 421  416  
 422  417          vol_running = volmgt_running();
 423  418          if (vol_running)
 424  419                  defer = 1;
 425  420          (void) printf(gettext("Looking for devices...\n"));
 426  421          total_devices_found_last_time = 0;
 427  422  
 428  423          /*
↓ open down ↓ 781 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX