Print this page
    
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_path.c
          +++ new/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_path.c
   1    1  /*
   2    2   * This file and its contents are supplied under the terms of the
   3    3   * Common Development and Distribution License ("CDDL"), version 1.0.
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13   13   * Copyright 2015 Joyent, Inc.
  14   14   */
  15   15  
  16   16  /*
  17   17   * Lookup functions for various file paths used by ipmgmtd.  This mechanism
  18   18   * primarily exists to account for a native root prefix when run within a
  19   19   * branded zone (e.g. "/native").
  20   20   */
  21   21  
  22   22  #include <stdio.h>
  23   23  #include <zone.h>
  24   24  #include "ipmgmt_impl.h"
  25   25  
  26   26  #define IPADM_PERM_DIR          "/etc/ipadm"
  27   27  #define IPADM_TMPFS_DIR         "/etc/svc/volatile/ipadm"
  28   28  
  29   29  typedef struct ipadm_path_ent {
  30   30          ipadm_path_t ipe_id;
  31   31          const char *ipe_path;
  32   32  } ipadm_path_ent_t;
  33   33  
  34   34  static ipadm_path_ent_t ipadm_paths[] = {
  35   35          /*
  36   36           * A temporary directory created in the SMF volatile filesystem.
  37   37           */
  38   38          { IPADM_PATH_TMPFS_DIR,         IPADM_TMPFS_DIR },
  39   39  
  40   40          /*
  41   41           * This file captures the in-memory copy of list `aobjmap' on disk.
  42   42           * This allows the system to recover in the event that the daemon
  43   43           * crashes or is restarted.
  44   44           */
  45   45          { IPADM_PATH_ADDROBJ_MAP_DB,    IPADM_TMPFS_DIR "/aobjmap.conf" },
  46   46  
  47   47          /*
  48   48           * The permanent data store for ipadm.
  49   49           */
  50   50          { IPADM_PATH_DB,                IPADM_PERM_DIR "/ipadm.conf" },
  51   51  
  52   52          /*
  53   53           * A temporary copy of the ipadm configuration created, if needed, to
  54   54           * service write requests early in boot.  This file is merged with the
  55   55           * permanent data store once it is available for writes.
  56   56           */
  57   57          { IPADM_PATH_VOL_DB,            IPADM_TMPFS_DIR "/ipadm.conf" },
  58   58  
  59   59          { 0,                            NULL }
  60   60  };
  61   61  
  62   62  /*
  63   63   * Load one of the paths used by ipadm into the provided string buffer.
  64   64   * Prepends the native system prefix (e.g. "/native") if one is in effect,
  65   65   * such as when running within a branded zone.
  66   66   */
  67   67  void
  68   68  ipmgmt_path(ipadm_path_t ip, char *buf, size_t bufsz)
  69   69  {
  70   70          int i;
  71   71  
  72   72          for (i = 0; ipadm_paths[i].ipe_path != NULL; i++) {
  73   73                  if (ipadm_paths[i].ipe_id == ip) {
  74   74                          const char *zroot = zone_get_nroot();
  75   75  
  76   76                          (void) snprintf(buf, bufsz, "%s%s", zroot != NULL ?
  77   77                              zroot : "", ipadm_paths[i].ipe_path);
  78   78  
  79   79                          return;
  80   80                  }
  81   81          }
  82   82  
  83   83          abort();
  84   84  }
  
    | 
      ↓ open down ↓ | 
    84 lines elided | 
    
      ↑ open up ↑ | 
  
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX