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


   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   "@(#)devfsadm.c 1.97    08/04/19 SMI"
  28 
  29 /*
  30  * Devfsadm replaces drvconfig, audlinks, disks, tapes, ports, devlinks
  31  * as a general purpose device administrative utility.  It creates
  32  * devices special files in /devices and logical links in /dev, and
  33  * coordinates updates to /etc/path_to_instance with the kernel.  It
  34  * operates in both command line mode to handle user or script invoked
  35  * reconfiguration updates, and operates in daemon mode to handle dynamic
  36  * reconfiguration for hotplugging support.
  37  */
  38 
  39 #include <string.h>
  40 #include <deflt.h>
  41 #include <tsol/label.h>
  42 #include <bsm/devices.h>
  43 #include <bsm/devalloc.h>
  44 #include <utime.h>
  45 #include <sys/param.h>
  46 #include <bsm/libbsm.h>
  47 #include "devfsadm_impl.h"


8436                         if ((x = add_property(nvl, prop)) == 0)
8437                                 count++;
8438                         else if (x == -1) {
8439                                 if ((prop_name = di_prop_name(prop)) == NULL)
8440                                         prop_name = "";
8441                                 err_print(PROP_ADD_FAILED, prop_name);
8442                                 goto out;
8443                         }
8444                 }
8445         }
8446 
8447         return (nvl);
8448 
8449 out:
8450         if (nvl)
8451                 nvlist_free(nvl);
8452 
8453         if (dev_name)
8454                 free(dev_name);
8455 
8456         if (dev_name_lookup_err)





8457                 err_print(DEV_NAME_LOOKUP_FAILED, node_path);
8458         else
8459                 err_print(BUILD_EVENT_ATTR_FAILED, (err) ? strerror(err) : "");

8460         return (NULL);
8461 }
8462 
8463 static void
8464 log_event(char *class, char *subclass, nvlist_t *nvl)
8465 {
8466         sysevent_id_t eid;
8467 
8468         if (sysevent_post_event(class, subclass, "SUNW", DEVFSADMD,
8469             nvl, &eid) != 0) {
8470                 err_print(LOG_EVENT_FAILED, strerror(errno));
8471         }
8472 }
8473 
8474 /*
8475  * When devfsadmd needs to generate sysevents, they are queued for later
8476  * delivery this allows them to be delivered after the devlinks db cache has
8477  * been flushed guaranteeing that applications consuming these events have
8478  * access to an accurate devlinks db.  The queue is a FIFO, sysevents to be
8479  * inserted in the front of the queue and consumed off the back.




   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   "@(#)devfsadm.c 1.98    08/05/07 SMI"
  28 
  29 /*
  30  * Devfsadm replaces drvconfig, audlinks, disks, tapes, ports, devlinks
  31  * as a general purpose device administrative utility.  It creates
  32  * devices special files in /devices and logical links in /dev, and
  33  * coordinates updates to /etc/path_to_instance with the kernel.  It
  34  * operates in both command line mode to handle user or script invoked
  35  * reconfiguration updates, and operates in daemon mode to handle dynamic
  36  * reconfiguration for hotplugging support.
  37  */
  38 
  39 #include <string.h>
  40 #include <deflt.h>
  41 #include <tsol/label.h>
  42 #include <bsm/devices.h>
  43 #include <bsm/devalloc.h>
  44 #include <utime.h>
  45 #include <sys/param.h>
  46 #include <bsm/libbsm.h>
  47 #include "devfsadm_impl.h"


8436                         if ((x = add_property(nvl, prop)) == 0)
8437                                 count++;
8438                         else if (x == -1) {
8439                                 if ((prop_name = di_prop_name(prop)) == NULL)
8440                                         prop_name = "";
8441                                 err_print(PROP_ADD_FAILED, prop_name);
8442                                 goto out;
8443                         }
8444                 }
8445         }
8446 
8447         return (nvl);
8448 
8449 out:
8450         if (nvl)
8451                 nvlist_free(nvl);
8452 
8453         if (dev_name)
8454                 free(dev_name);
8455 
8456         if (dev_name_lookup_err) {
8457                 /*
8458                  * If a lofi mount fails, the /devices node may well have
8459                  * disappeared by the time we run, so let's not complain.
8460                  */
8461                 if (strcmp(subclass, ESC_LOFI) != 0)
8462                         err_print(DEV_NAME_LOOKUP_FAILED, node_path);
8463         } else {
8464                 err_print(BUILD_EVENT_ATTR_FAILED, (err) ? strerror(err) : "");
8465         }
8466         return (NULL);
8467 }
8468 
8469 static void
8470 log_event(char *class, char *subclass, nvlist_t *nvl)
8471 {
8472         sysevent_id_t eid;
8473 
8474         if (sysevent_post_event(class, subclass, "SUNW", DEVFSADMD,
8475             nvl, &eid) != 0) {
8476                 err_print(LOG_EVENT_FAILED, strerror(errno));
8477         }
8478 }
8479 
8480 /*
8481  * When devfsadmd needs to generate sysevents, they are queued for later
8482  * delivery this allows them to be delivered after the devlinks db cache has
8483  * been flushed guaranteeing that applications consuming these events have
8484  * access to an accurate devlinks db.  The queue is a FIFO, sysevents to be
8485  * inserted in the front of the queue and consumed off the back.