Print this page
6198 Let's EOL cachefs

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/fs.d/autofs/autod_parse.c
          +++ new/usr/src/cmd/fs.d/autofs/autod_parse.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  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   20   */
  21   21  /*
  22   22   *      autod_parse.c
  23   23   *
  24   24   *      Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  25   25   *      Use is subject to license terms.
       26 + *      Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  26   27   */
  27   28  
  28   29  #include <stdio.h>
  29   30  #include <ctype.h>
  30   31  #include <string.h>
  31   32  #include <syslog.h>
  32   33  #include <sys/types.h>
  33   34  #include <sys/stat.h>
  34   35  #include <sys/param.h>
  35   36  #include <errno.h>
↓ open down ↓ 518 lines elided ↑ open up ↑
 554  555                                  err = MAPENT_UATFS;
 555  556                          if ((rc = push_options(node->subdir, defaultopts,
 556  557                              mapopts, err)) != PARSE_OK)
 557  558                                  return (rc);
 558  559                  }
 559  560                  node = node->leveldir;
 560  561          }
 561  562          return (rc);
 562  563  }
 563  564  
 564      -#define BACKFSTYPE "backfstype" /* used in cachefs options */
 565      -#define BACKFSTYPE_EQ "backfstype="
 566  565  #define FSTYPE "fstype"
 567  566  #define FSTYPE_EQ "fstype="
 568  567  #define NO_OPTS ""
 569  568  
 570  569  /*
 571  570   * set_mapent_opts(struct mapent *me, char *opts, char *defaultopts,
 572  571   *                      char *mapopts)
 573  572   * sets the mapentry's options, fstype and mounter fields by separating
 574  573   * out the fstype part from the opts. Use default options if opts is NULL.
 575  574   * Note taht defaultopts may be the same as mapopts.
↓ open down ↓ 25 lines elided ↑ open up ↑
 601  600          get_opts(opts,  entryopts, fstype, &fstype_opt);
 602  601  
 603  602          /* replace any existing opts */
 604  603          if (me->map_mntopts != NULL)
 605  604                  free(me->map_mntopts);
 606  605          if ((me->map_mntopts = strdup(entryopts)) == NULL)
 607  606                  return (ENOMEM);
 608  607          strcpy(mounter, fstype);
 609  608  
 610  609          /*
 611      -         * The following ugly chunk of code crept in as a result of
 612      -         * cachefs.  If it's a cachefs mount of an nfs filesystem, then
 613      -         * it's important to parse the nfs special field.  Otherwise,
 614      -         * just hand the special field to the fs-specific mount
 615      -         */
 616      -        if (strcmp(fstype, MNTTYPE_CACHEFS) ==  0) {
 617      -                struct mnttab m;
 618      -                char *p;
 619      -
 620      -                m.mnt_mntopts = entryopts;
 621      -                if ((p = hasmntopt(&m, BACKFSTYPE)) != NULL) {
 622      -                        int len = strlen(MNTTYPE_NFS);
 623      -
 624      -                        p += strlen(BACKFSTYPE_EQ);
 625      -
 626      -                        if (strncmp(p, MNTTYPE_NFS, len) ==  0 &&
 627      -                            (p[len] == '\0' || p[len] == ',')) {
 628      -                                /*
 629      -                                 * Cached nfs mount
 630      -                                 */
 631      -                                (void) strcpy(fstype, MNTTYPE_NFS);
 632      -                                (void) strcpy(mounter, MNTTYPE_CACHEFS);
 633      -                        }
 634      -                }
 635      -        }
 636      -
 637      -        /*
 638  610           * child options are exactly fstype = somefs, we need to do some
 639  611           * more option pushing work.
 640  612           */
 641  613          if (fstype_opt == TRUE &&
 642  614              (strcmp(me->map_mntopts, NO_OPTS) == 0)) {
 643  615                  free(me->map_mntopts);
 644  616                  if ((rc = fstype_opts(me, opts, defaultopts,
 645  617                      mapopts)) != PARSE_OK)
 646  618                          return (rc);
 647  619          }
↓ open down ↓ 9 lines elided ↑ open up ↑
 657  629  
 658  630          return (rc);
 659  631  }
 660  632  
 661  633  /*
 662  634   * Check the option string for an "fstype"
 663  635   * option.  If found, return the fstype
 664  636   * and the option string with the fstype
 665  637   * option removed, e.g.
 666  638   *
 667      - *  input:  "fstype=cachefs,ro,nosuid"
      639 + *  input:  "fstype=nfs,ro,nosuid"
 668  640   *  opts:   "ro,nosuid"
 669      - *  fstype: "cachefs"
      641 + *  fstype: "nfs"
 670  642   *
 671  643   * Also indicates if the fstype option was present
 672  644   * by setting a flag, if the pointer to the flag
 673  645   * is not NULL.
 674  646   */
 675  647  static void
 676  648  get_opts(input, opts, fstype, fstype_opt)
 677  649          char *input;
 678  650          char *opts;     /* output */
 679  651          char *fstype;   /* output */
↓ open down ↓ 23 lines elided ↑ open up ↑
 703  675  /*
 704  676   * fstype_opts(struct mapent *me, char *opts, char *defaultopts,
 705  677   *                              char *mapopts)
 706  678   * We need to push global options to the child entry if it is exactly
 707  679   * fstype=somefs.
 708  680   */
 709  681  static int
 710  682  fstype_opts(struct mapent *me, char *opts, char *defaultopts,
 711  683                                  char *mapopts)
 712  684  {
 713      -        char pushopts[AUTOFS_MAXOPTSLEN];
 714  685          char pushentryopts[AUTOFS_MAXOPTSLEN];
 715  686          char pushfstype[MAX_FSLEN];
 716  687  
 717  688          if (defaultopts && *defaultopts == '-')
 718  689                  defaultopts++;
 719  690  
 720  691          /*
 721  692           * the options to push are the global defaults for the entry,
 722  693           * if they exist, or mapopts, if the global defaults for the
 723  694           * entry does not exist.
 724  695           */
 725  696          if (strcmp(defaultopts, opts) == 0) {
 726  697                  if (*mapopts == '-')
 727  698                          mapopts++;
 728  699                  get_opts(mapopts, pushentryopts, pushfstype, NULL);
 729      -                strcpy(pushopts, mapopts);
 730  700          } else {
 731  701                  get_opts(defaultopts, pushentryopts, pushfstype, NULL);
 732      -                strcpy(pushopts, defaultopts);
 733  702          }
 734  703  
 735      -        if (strcmp(pushfstype, MNTTYPE_CACHEFS) == 0)
 736      -                me->map_mntopts = strdup(pushopts);
 737      -        else
 738      -                me->map_mntopts = strdup(pushentryopts);
      704 +        me->map_mntopts = strdup(pushentryopts);
 739  705  
 740  706          if (!me->map_mntopts) {
 741  707                  syslog(LOG_ERR, "fstype_opts: No memory");
 742  708                  return (ENOMEM);
 743  709          }
 744  710  
 745  711          return (PARSE_OK);
 746  712  }
 747  713  
 748  714  /*
↓ open down ↓ 1233 lines elided ↑ open up ↑
1982 1948                                  break;
1983 1949                          }
1984 1950                  }
1985 1951                  if (!duplicate) {
1986 1952                          ex->ex_next = *texp;
1987 1953                          *texp = ex;
1988 1954                  }
1989 1955          }
1990 1956          exlist = texlist;
1991 1957  
1992      -        /*
1993      -         * The following ugly chunk of code crept in as
1994      -         * a result of cachefs.  If it's a cachefs mount
1995      -         * of an nfs filesystem, then have it handled as
1996      -         * an nfs mount but have cachefs do the mount.
1997      -         */
1998 1958          (void) strcpy(fstype, MNTTYPE_NFS);
1999 1959          get_opts(mapopts, entryopts, fstype, NULL);
2000 1960          (void) strcpy(mounter, fstype);
2001      -        if (strcmp(fstype, MNTTYPE_CACHEFS) == 0) {
2002      -                struct mnttab m;
2003      -                char *p;
2004 1961  
2005      -                m.mnt_mntopts = entryopts;
2006      -                if ((p = hasmntopt(&m, "backfstype")) != NULL) {
2007      -                        int len = strlen(MNTTYPE_NFS);
2008      -
2009      -                        p += 11;
2010      -                        if (strncmp(p, MNTTYPE_NFS, len) == 0 &&
2011      -                            (p[len] == '\0' || p[len] == ',')) {
2012      -                                /*
2013      -                                 * Cached nfs mount
2014      -                                 */
2015      -                                (void) strcpy(fstype, MNTTYPE_NFS);
2016      -                                (void) strcpy(mounter, MNTTYPE_CACHEFS);
2017      -                        }
2018      -                }
2019      -        }
2020      -
2021 1962          /* Now create a mapent from the export list */
2022 1963          ms = NULL;
2023 1964          me = NULL;
2024 1965  
2025 1966          for (ex = exlist; ex; ex = ex->ex_next) {
2026 1967                  mp = me;
2027 1968                  me = (struct mapent *)malloc(sizeof (*me));
2028 1969                  if (me == NULL)
2029 1970                          goto alloc_failed;
2030 1971                  (void) memset((char *)me, 0, sizeof (*me));
↓ open down ↓ 122 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX