Print this page
6727 lofiadm: remove "o:" from getopt argument
Reviewed by: Robert Mustacchi <rm@joyent.com>


   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  * Copyright 2012 Joyent, Inc.  All rights reserved.
  25  *
  26  * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
  27  * Copyright (c) 2014 Gary Mills

  28  */
  29 
  30 /*
  31  * lofiadm - administer lofi(7d). Very simple, add and remove file<->device
  32  * associations, and display status. All the ioctls are private between
  33  * lofi and lofiadm, and so are very simple - device information is
  34  * communicated via a minor number.
  35  */
  36 
  37 #include <sys/types.h>
  38 #include <sys/param.h>
  39 #include <sys/lofi.h>
  40 #include <sys/stat.h>
  41 #include <sys/sysmacros.h>
  42 #include <netinet/in.h>
  43 #include <stdio.h>
  44 #include <fcntl.h>
  45 #include <locale.h>
  46 #include <string.h>
  47 #include <strings.h>


1815         boolean_t rdflag = B_FALSE;
1816         boolean_t deleteflag = B_FALSE;
1817         boolean_t ephflag = B_FALSE;
1818         boolean_t compressflag = B_FALSE;
1819         boolean_t uncompressflag = B_FALSE;
1820         /* the next two work together for -c, -k, -T, -e options only */
1821         boolean_t need_crypto = B_FALSE;        /* if any -c, -k, -T, -e */
1822         boolean_t cipher_only = B_TRUE;         /* if -c only */
1823         const char *keyfile = NULL;
1824         mech_alias_t *cipher = NULL;
1825         token_spec_t *token = NULL;
1826         char    *rkey = NULL;
1827         size_t  rksz = 0;
1828         char realfilename[MAXPATHLEN];
1829 
1830         pname = getpname(argv[0]);
1831 
1832         (void) setlocale(LC_ALL, "");
1833         (void) textdomain(TEXT_DOMAIN);
1834 
1835         while ((c = getopt(argc, argv, "a:c:Cd:efk:o:rs:T:U")) != EOF) {
1836                 switch (c) {
1837                 case 'a':
1838                         addflag = B_TRUE;
1839                         if ((filename = realpath(optarg, realfilename)) == NULL)
1840                                 die("%s", optarg);
1841                         if (((argc - optind) > 0) && (*argv[optind] != '-')) {
1842                                 /* optional device */
1843                                 devicename = argv[optind];
1844                                 optind++;
1845                         }
1846                         break;
1847                 case 'C':
1848                         compressflag = B_TRUE;
1849                         if (((argc - optind) > 1) && (*argv[optind] != '-')) {
1850                                 /* optional algorithm */
1851                                 algname = argv[optind];
1852                                 optind++;
1853                         }
1854                         check_algorithm_validity(algname, &compress_index);
1855                         break;




   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  * Copyright 2012 Joyent, Inc.  All rights reserved.
  25  *
  26  * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
  27  * Copyright (c) 2014 Gary Mills
  28  * Copyright (c) 2016 Andrey Sokolov
  29  */
  30 
  31 /*
  32  * lofiadm - administer lofi(7d). Very simple, add and remove file<->device
  33  * associations, and display status. All the ioctls are private between
  34  * lofi and lofiadm, and so are very simple - device information is
  35  * communicated via a minor number.
  36  */
  37 
  38 #include <sys/types.h>
  39 #include <sys/param.h>
  40 #include <sys/lofi.h>
  41 #include <sys/stat.h>
  42 #include <sys/sysmacros.h>
  43 #include <netinet/in.h>
  44 #include <stdio.h>
  45 #include <fcntl.h>
  46 #include <locale.h>
  47 #include <string.h>
  48 #include <strings.h>


1816         boolean_t rdflag = B_FALSE;
1817         boolean_t deleteflag = B_FALSE;
1818         boolean_t ephflag = B_FALSE;
1819         boolean_t compressflag = B_FALSE;
1820         boolean_t uncompressflag = B_FALSE;
1821         /* the next two work together for -c, -k, -T, -e options only */
1822         boolean_t need_crypto = B_FALSE;        /* if any -c, -k, -T, -e */
1823         boolean_t cipher_only = B_TRUE;         /* if -c only */
1824         const char *keyfile = NULL;
1825         mech_alias_t *cipher = NULL;
1826         token_spec_t *token = NULL;
1827         char    *rkey = NULL;
1828         size_t  rksz = 0;
1829         char realfilename[MAXPATHLEN];
1830 
1831         pname = getpname(argv[0]);
1832 
1833         (void) setlocale(LC_ALL, "");
1834         (void) textdomain(TEXT_DOMAIN);
1835 
1836         while ((c = getopt(argc, argv, "a:c:Cd:efk:rs:T:U")) != EOF) {
1837                 switch (c) {
1838                 case 'a':
1839                         addflag = B_TRUE;
1840                         if ((filename = realpath(optarg, realfilename)) == NULL)
1841                                 die("%s", optarg);
1842                         if (((argc - optind) > 0) && (*argv[optind] != '-')) {
1843                                 /* optional device */
1844                                 devicename = argv[optind];
1845                                 optind++;
1846                         }
1847                         break;
1848                 case 'C':
1849                         compressflag = B_TRUE;
1850                         if (((argc - optind) > 1) && (*argv[optind] != '-')) {
1851                                 /* optional algorithm */
1852                                 algname = argv[optind];
1853                                 optind++;
1854                         }
1855                         check_algorithm_validity(algname, &compress_index);
1856                         break;