Print this page
6198 Let's EOL cachefs


   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 /*
  23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.

  25  */
  26 
  27 #pragma ident   "%Z%%M% %I%     %E% SMI"
  28 
  29 /*
  30  * This program does the following:
  31  *
  32  * a) Returns:
  33  *      0       - if the program successfully determined the net strategy.
  34  *      !0      - if an error occurred.
  35  *
  36  * b) If the program is successful, it prints three tokens to
  37  *    stdout: <root fs type> <interface name> <net config strategy>.
  38  *    where:
  39  *      <root fs type>            -       "nfs" or "ufs"
  40  *      <interface name>  -       "hme0" or "none"
  41  *      <net config strategy>     -       "dhcp", "rarp", "bootprops"
  42  *                                      or "none"
  43  *
  44  *    Eg:
  45  *      # /sbin/netstrategy
  46  *      ufs hme0 dhcp
  47  *
  48  *    <root fs type> identifies the system's root file system type.
  49  *
  50  *    <interface name> is the 16 char name of the root interface, and is only
  51  *      set if rarp/dhcp was used to configure the interface.
  52  *
  53  *    <net config strategy> can be either "rarp", "dhcp", "bootprops", or
  54  *      "none" depending on which strategy was used to configure the
  55  *      interface. Is "none" if no interface was configured using a
  56  *      net-based strategy.
  57  *
  58  * CAVEATS: what about autoclient systems? XXX
  59  *


 291 
 292         /*
 293          * Handle the simple case where diskless dhcp tells us everything
 294          * we need to know.
 295          */
 296         if ((len = sysinfo(SI_DHCP_CACHE, &dummy, sizeof (dummy))) > 1) {
 297                 /* interface is first thing in cache. */
 298                 strategy = "dhcp";
 299                 interface = alloca(len);
 300                 (void) sysinfo(SI_DHCP_CACHE, interface, len);
 301                 (void) printf("%s %s %s\n", root, interface, strategy);
 302                 close_sockets();
 303                 return (0);
 304         }
 305 
 306         /*
 307          * We're not "nfs dhcp", "nfs none" is impossible, and we don't handle
 308          * "ufs rarp" (consumers are coded to deal with this reality), so
 309          * there are three possible situations:
 310          *
 311          *      1. We're "ufs dhcp" if there are any interfaces which have
 312          *         obtained their addresses through DHCP.  That is, if there
 313          *         are any IFF_UP and non-IFF_VIRTUAL interfaces also have
 314          *         IFF_DHCPRUNNING set.
 315          *
 316          *      2. We're "ufs none" if our filesystem is local and there
 317          *         are no interfaces which have obtained their addresses
 318          *         through DHCP.
 319          *
 320          *      3. We're "nfs rarp" if our filesystem is remote and there's
 321          *         at least IFF_UP non-IFF_VIRTUAL interface (which there
 322          *         *must* be, since we're running over NFS somehow), then
 323          *         it must be RARP since SI_DHCP_CACHE call above failed.
 324          *         It's too bad there isn't an IFF_RARPRUNNING flag.
 325          */
 326 
 327         interface = get_first_interface(&dhcp_running);
 328 
 329         if (dhcp_running)
 330                 strategy = "dhcp";
 331 
 332         if (strcmp(root, "nfs") == 0 || strcmp(root, "cachefs") == 0) {
 333                 if (interface == NULL) {
 334                         (void) fprintf(stderr,
 335                             "%s: cannot identify root interface.\n", program);
 336                         close_sockets();
 337                         return (2);
 338                 }
 339                 if (strategy == NULL)
 340                         strategy = "rarp";      /*  must be rarp/bootparams */
 341         } else {
 342                 if (interface == NULL || strategy == NULL)
 343                         interface = strategy = "none";
 344         }
 345 
 346         (void) printf("%s %s %s\n", root, interface, strategy);
 347         close_sockets();
 348         return (0);
 349 }


   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 /*
  23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  26  */
  27 

  28 
  29 /*
  30  * This program does the following:
  31  *
  32  * a) Returns:
  33  *      0       - if the program successfully determined the net strategy.
  34  *      !0      - if an error occurred.
  35  *
  36  * b) If the program is successful, it prints three tokens to
  37  *    stdout: <root fs type> <interface name> <net config strategy>.
  38  *    where:
  39  *      <root fs type>            -       "nfs", "ufs" or "zfs"
  40  *      <interface name>  -       "hme0" or "none"
  41  *      <net config strategy>     -       "dhcp", "rarp", "bootprops"
  42  *                                      or "none"
  43  *
  44  *    Eg:
  45  *      # /sbin/netstrategy
  46  *      ufs hme0 dhcp
  47  *
  48  *    <root fs type> identifies the system's root file system type.
  49  *
  50  *    <interface name> is the 16 char name of the root interface, and is only
  51  *      set if rarp/dhcp was used to configure the interface.
  52  *
  53  *    <net config strategy> can be either "rarp", "dhcp", "bootprops", or
  54  *      "none" depending on which strategy was used to configure the
  55  *      interface. Is "none" if no interface was configured using a
  56  *      net-based strategy.
  57  *
  58  * CAVEATS: what about autoclient systems? XXX
  59  *


 291 
 292         /*
 293          * Handle the simple case where diskless dhcp tells us everything
 294          * we need to know.
 295          */
 296         if ((len = sysinfo(SI_DHCP_CACHE, &dummy, sizeof (dummy))) > 1) {
 297                 /* interface is first thing in cache. */
 298                 strategy = "dhcp";
 299                 interface = alloca(len);
 300                 (void) sysinfo(SI_DHCP_CACHE, interface, len);
 301                 (void) printf("%s %s %s\n", root, interface, strategy);
 302                 close_sockets();
 303                 return (0);
 304         }
 305 
 306         /*
 307          * We're not "nfs dhcp", "nfs none" is impossible, and we don't handle
 308          * "ufs rarp" (consumers are coded to deal with this reality), so
 309          * there are three possible situations:
 310          *
 311          *      1. We're either "ufs dhcp" or "zfs dhcp" if there are any
 312          *         interfaces which have obtained their addresses through DHCP.
 313          *         That is, if there are any IFF_UP and non-IFF_VIRTUAL
 314          *         interfaces also have IFF_DHCPRUNNING set.
 315          *
 316          *      2. We're either "ufs none" or "zfs none" if our filesystem
 317          *         is local and there are no interfaces which have obtained
 318          *         their addresses through DHCP.
 319          *
 320          *      3. We're "nfs rarp" if our filesystem is remote and there's
 321          *         at least IFF_UP non-IFF_VIRTUAL interface (which there
 322          *         *must* be, since we're running over NFS somehow), then
 323          *         it must be RARP since SI_DHCP_CACHE call above failed.
 324          *         It's too bad there isn't an IFF_RARPRUNNING flag.
 325          */
 326 
 327         interface = get_first_interface(&dhcp_running);
 328 
 329         if (dhcp_running)
 330                 strategy = "dhcp";
 331 
 332         if (strcmp(root, "nfs") == 0) {
 333                 if (interface == NULL) {
 334                         (void) fprintf(stderr,
 335                             "%s: cannot identify root interface.\n", program);
 336                         close_sockets();
 337                         return (2);
 338                 }
 339                 if (strategy == NULL)
 340                         strategy = "rarp";      /*  must be rarp/bootparams */
 341         } else {
 342                 if (interface == NULL || strategy == NULL)
 343                         interface = strategy = "none";
 344         }
 345 
 346         (void) printf("%s %s %s\n", root, interface, strategy);
 347         close_sockets();
 348         return (0);
 349 }