Print this page
PSARC 2008/290 lofi mount
6384817 Need persistent lofi based mounts and direct mount(1m) support for lofi

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/fs.d/fslib.c
          +++ new/usr/src/cmd/fs.d/fslib.c
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5      - * Common Development and Distribution License, Version 1.0 only
   6      - * (the "License").  You may not use this file except in compliance
   7      - * with the License.
        5 + * Common Development and Distribution License (the "License").
        6 + * You may not use this file except in compliance with the License.
   8    7   *
   9    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10    9   * or http://www.opensolaris.org/os/licensing.
  11   10   * See the License for the specific language governing permissions
  12   11   * and limitations under the License.
  13   12   *
  14   13   * When distributing Covered Code, include this CDDL HEADER in each
  15   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16   15   * If applicable, add the following below this CDDL HEADER, with the
  17   16   * fields enclosed by brackets "[]" replaced with your own identifying
  18   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   18   *
  20   19   * CDDL HEADER END
  21   20   */
  22   21  /*
  23      - * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
       22 + * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24   23   * Use is subject to license terms.
  25   24   */
  26   25  
  27      -#pragma ident   "@(#)fslib.c    1.25    05/06/08 SMI"
       26 +#pragma ident   "@(#)fslib.c    1.26    08/05/07 SMI"
  28   27  
  29   28  #include        <stdio.h>
  30   29  #include        <stdarg.h>
  31   30  #include        <stdlib.h>
  32   31  #include        <unistd.h>
  33   32  #include        <libintl.h>
  34   33  #include        <string.h>
  35   34  #include        <fcntl.h>
  36   35  #include        <errno.h>
  37   36  #include        <syslog.h>
↓ open down ↓ 129 lines elided ↑ open up ↑
 167  166  fsmkmntlist(FILE *mfp)
 168  167  {
 169  168          struct extmnttab        mnt;
 170  169          mntlist_t       *mhead, *mtail;
 171  170          int             ret;
 172  171  
 173  172          mhead = mtail = NULL;
 174  173  
 175  174          resetmnttab(mfp);
 176  175          while ((ret = getextmntent(mfp, &mnt, sizeof (struct extmnttab)))
 177      -                != -1) {
      176 +            != -1) {
 178  177                  mntlist_t       *mp;
 179  178  
 180  179                  if (ret != 0)           /* bad entry */
 181  180                          continue;
 182  181  
 183  182                  mp = (mntlist_t *)malloc(sizeof (*mp));
 184  183                  if (mp == NULL)
 185  184                          goto alloc_failed;
 186  185                  if (mhead == NULL)
 187  186                          mhead = mp;
↓ open down ↓ 21 lines elided ↑ open up ↑
 209  208  fsgetmlast(mntlist_t *ml, struct mnttab *mntin)
 210  209  {
 211  210          mntlist_t       *delete = NULL;
 212  211  
 213  212          for (; ml; ml = ml->mntl_next) {
 214  213                  if (mntin->mnt_mountp && mntin->mnt_special) {
 215  214                          /*
 216  215                           * match if and only if both are equal.
 217  216                           */
 218  217                          if ((strcmp(ml->mntl_mnt->mnt_mountp,
 219      -                                        mntin->mnt_mountp) == 0) &&
      218 +                            mntin->mnt_mountp) == 0) &&
 220  219                              (strcmp(ml->mntl_mnt->mnt_special,
 221      -                                        mntin->mnt_special) == 0))
      220 +                            mntin->mnt_special) == 0))
 222  221                                  delete = ml;
 223  222                  } else if (mntin->mnt_mountp) {
 224  223                          if (strcmp(ml->mntl_mnt->mnt_mountp,
 225      -                                        mntin->mnt_mountp) == 0)
      224 +                            mntin->mnt_mountp) == 0)
 226  225                                  delete = ml;
 227  226                  } else if (mntin->mnt_special) {
 228  227                          if (strcmp(ml->mntl_mnt->mnt_special,
 229      -                                        mntin->mnt_special) == 0)
      228 +                            mntin->mnt_special) == 0)
 230  229                                  delete = ml;
 231      -            }
      230 +                }
 232  231          }
 233  232          return (delete);
 234  233  }
 235  234  
 236  235  
 237  236  /*
 238  237   * Returns the mountlevel of the pathname in cp.  As examples,
 239  238   * / => 1, /bin => 2, /bin/ => 2, ////bin////ls => 3, sdf => 0, etc...
 240  239   */
 241  240  int
↓ open down ↓ 60 lines elided ↑ open up ↑
 302  301          int     found;
 303  302          char    *actual_opt_hold, *bufp;
 304  303  
 305  304          if (requested_opts == NULL)
 306  305                  return;
 307  306  
 308  307          bufp = alloca(strlen(actual_opts) + 1);
 309  308  
 310  309          while (*requested_opts != '\0') {
 311  310                  (void) getsubopt(&requested_opts, empty_opt_vector,
 312      -                        &option_ptr);
      311 +                    &option_ptr);
 313  312  
 314  313                  /*
 315  314                   * Truncate any "=<value>" string from the end of
 316  315                   * the option.
 317  316                   */
 318  317                  if ((equalptr = strchr(option_ptr, '=')) != NULL)
 319  318                          *equalptr = '\0';
 320  319  
 321  320                  if (*option_ptr == '\0')
 322  321                          continue;
 323  322  
 324  323                  /*
      324 +                 * Whilst we don't need this option to perform a lofi
      325 +                 * mount, let's not be mendacious enough to complain
      326 +                 * about it.
      327 +                 */
      328 +                if (strcmp(option_ptr, "loop") == 0)
      329 +                        continue;
      330 +
      331 +                /*
 325  332                   * Search for the requested option in the list of options
 326  333                   * actually supported.
 327  334                   */
 328  335                  found = 0;
 329  336  
 330  337                  /*
 331  338                   * Need to use a copy of actual_opts because getsubopt
 332  339                   * is destructive and we need to scan the actual_opts
 333  340                   * string more than once.
 334  341                   *
↓ open down ↓ 2 lines elided ↑ open up ↑
 337  344                   * actual_opt_hold (the pointer).
 338  345                   */
 339  346                  actual_opt_hold = bufp;
 340  347                  if (actual_opts != NULL)
 341  348                          (void) strcpy(actual_opt_hold, actual_opts);
 342  349                  else
 343  350                          *actual_opt_hold = '\0';
 344  351  
 345  352                  while (*actual_opt_hold != '\0') {
 346  353                          (void) getsubopt(&actual_opt_hold, empty_opt_vector,
 347      -                                &actopt);
      354 +                            &actopt);
 348  355  
 349  356                          /* Truncate the "=<value>", if any. */
 350  357                          if ((equalptr = strchr(actopt, '=')) != NULL)
 351  358                                  *equalptr = '\0';
 352  359  
 353  360                          if ((strcmp(option_ptr, actopt)) == 0) {
 354  361                                  found = 1;
 355  362                                  break;
 356  363                          }
 357  364                  }
↓ open down ↓ 63 lines elided ↑ open up ↑
 421  428  fs_get_zone_summaries(void)
 422  429  {
 423  430          uint_t numzones = 0, oldnumzones = 0;
 424  431          uint_t i, j;
 425  432          zoneid_t *ids = NULL;
 426  433          struct zone_summary *summaries;
 427  434          zoneid_t myzoneid = getzoneid();
 428  435  
 429  436          for (;;) {
 430  437                  if (zone_list(ids, &numzones) < 0) {
 431      -                            perror("unable to retrieve list of zones");
 432      -                            if (ids != NULL)
 433      -                                    free(ids);
 434      -                            return (NULL);
      438 +                        perror("unable to retrieve list of zones");
      439 +                        if (ids != NULL)
      440 +                                free(ids);
      441 +                        return (NULL);
 435  442                  }
 436  443                  if (numzones <= oldnumzones)
 437  444                          break;
 438  445                  if (ids != NULL)
 439  446                          free(ids);
 440  447                  ids = malloc(numzones * sizeof (*ids));
 441  448                  if (ids == NULL) {
 442  449                          perror("malloc failed");
 443  450                          return (NULL);
 444  451                  }
↓ open down ↓ 108 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX