Print this page
4833 Remove volrmmount
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.


  24  */
  25 
  26 /*
  27  * rmf_menu.c :
  28  *      Command line options to rmformat are processed in this file.
  29  */
  30 
  31 #include "rmformat.h"
  32 #include <sys/smedia.h>
  33 #include <priv_utils.h>
  34 
  35 extern int32_t D_flag;
  36 extern int32_t e_flag;
  37 extern int32_t H_flag;
  38 extern int32_t U_flag;
  39 extern int32_t V_flag;
  40 extern int32_t b_flag;
  41 extern int32_t w_flag;
  42 extern int32_t W_flag;
  43 extern int32_t s_flag;


 291         if (l_flag) {
 292                 process_l_flag();
 293         }
 294 
 295         (void) smedia_release_handle(handle);
 296         (void) close(fd);
 297 }
 298 
 299 /*
 300  * This routine handles the F_flag.
 301  * This options should not be used for floppy. However,
 302  * if this option is used for floppy, the option will
 303  * be forced to SM_FORMAT_HD and smedia_format is called.
 304  * Note that smedia_format is a blocked mode format and it
 305  * returns only after the complete formatting is over.
 306  */
 307 
 308 static void
 309 process_F_flag(smedia_handle_t handle, int32_t fd)
 310 {
 311         uint32_t format_flag;
 312         int32_t old_per = 0;
 313         int32_t new_per, ret_val;
 314 
 315         if (force_format) {
 316                 (void) fprintf(stderr,
 317                     gettext("Formatting disk.\n"));
 318         } else {
 319                 (void) fprintf(stderr,
 320                     gettext("Formatting will erase all the data on disk.\n"));
 321                 if (!get_confirmation())
 322                         return;
 323         }
 324 
 325         if (quick_format)
 326                 format_flag = SM_FORMAT_QUICK;
 327         else if (long_format)
 328                 format_flag = SM_FORMAT_LONG;
 329         else if (force_format)
 330                 format_flag = SM_FORMAT_FORCE;
 331 


 398 
 399                 if (quick_format)
 400                         overwrite_metadata(fd, handle);
 401 
 402                 (void) write_default_label(handle, fd);
 403         }
 404 
 405         release_SIGINT();
 406 }
 407 
 408 /*
 409  * List removable devices.
 410  */
 411 static void
 412 process_l_flag()
 413 {
 414         int retry;
 415         int removable;
 416         int total_devices_found_last_time;
 417         int defer = 0;
 418         char *tmpstr;
 419 
 420 #define MAX_RETRIES_FOR_SCANNING 3
 421 
 422         vol_running = volmgt_running();
 423         if (vol_running)
 424                 defer = 1;
 425         (void) printf(gettext("Looking for devices...\n"));
 426         total_devices_found_last_time = 0;
 427 
 428         /*
 429          * Strip out any leading path.  For example, /dev/rdsk/c3t0d0s2
 430          * will result in tmpstr = c3t0d0s2.  dev_name is given as input
 431          * argument.
 432          */
 433         if (dev_name) {
 434                 if ((tmpstr = strrchr(dev_name, '/')) != NULL) {
 435                         tmpstr += sizeof (char);
 436                 } else {
 437                         tmpstr = dev_name;
 438                 }


   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  *
  21  *
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  *
  25  * Copyright 2014 Andrew Stormont.
  26  */
  27 
  28 /*
  29  * rmf_menu.c :
  30  *      Command line options to rmformat are processed in this file.
  31  */
  32 
  33 #include "rmformat.h"
  34 #include <sys/smedia.h>
  35 #include <priv_utils.h>
  36 
  37 extern int32_t D_flag;
  38 extern int32_t e_flag;
  39 extern int32_t H_flag;
  40 extern int32_t U_flag;
  41 extern int32_t V_flag;
  42 extern int32_t b_flag;
  43 extern int32_t w_flag;
  44 extern int32_t W_flag;
  45 extern int32_t s_flag;


 293         if (l_flag) {
 294                 process_l_flag();
 295         }
 296 
 297         (void) smedia_release_handle(handle);
 298         (void) close(fd);
 299 }
 300 
 301 /*
 302  * This routine handles the F_flag.
 303  * This options should not be used for floppy. However,
 304  * if this option is used for floppy, the option will
 305  * be forced to SM_FORMAT_HD and smedia_format is called.
 306  * Note that smedia_format is a blocked mode format and it
 307  * returns only after the complete formatting is over.
 308  */
 309 
 310 static void
 311 process_F_flag(smedia_handle_t handle, int32_t fd)
 312 {
 313         uint32_t format_flag = 0;
 314         int32_t old_per = 0;
 315         int32_t new_per, ret_val;
 316 
 317         if (force_format) {
 318                 (void) fprintf(stderr,
 319                     gettext("Formatting disk.\n"));
 320         } else {
 321                 (void) fprintf(stderr,
 322                     gettext("Formatting will erase all the data on disk.\n"));
 323                 if (!get_confirmation())
 324                         return;
 325         }
 326 
 327         if (quick_format)
 328                 format_flag = SM_FORMAT_QUICK;
 329         else if (long_format)
 330                 format_flag = SM_FORMAT_LONG;
 331         else if (force_format)
 332                 format_flag = SM_FORMAT_FORCE;
 333 


 400 
 401                 if (quick_format)
 402                         overwrite_metadata(fd, handle);
 403 
 404                 (void) write_default_label(handle, fd);
 405         }
 406 
 407         release_SIGINT();
 408 }
 409 
 410 /*
 411  * List removable devices.
 412  */
 413 static void
 414 process_l_flag()
 415 {
 416         int retry;
 417         int removable;
 418         int total_devices_found_last_time;
 419         int defer = 0;
 420         char *tmpstr = NULL;
 421 
 422 #define MAX_RETRIES_FOR_SCANNING 3
 423 
 424         vol_running = volmgt_running();
 425         if (vol_running)
 426                 defer = 1;
 427         (void) printf(gettext("Looking for devices...\n"));
 428         total_devices_found_last_time = 0;
 429 
 430         /*
 431          * Strip out any leading path.  For example, /dev/rdsk/c3t0d0s2
 432          * will result in tmpstr = c3t0d0s2.  dev_name is given as input
 433          * argument.
 434          */
 435         if (dev_name) {
 436                 if ((tmpstr = strrchr(dev_name, '/')) != NULL) {
 437                         tmpstr += sizeof (char);
 438                 } else {
 439                         tmpstr = dev_name;
 440                 }