/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Device allocation related work.
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <fcntl.h>
#include <bsm/devalloc.h>
static char *_update_dev(deventry_t *, int, const char *, char *, char *);
static int _make_db();
extern int event_driven;
/*
* _da_check_for_usb
* returns 1 if device pointed by 'link' is a removable hotplugged disk,
* else returns 0.
*/
int
{
int removable = 0;
int hotpluggable = 0;
char *p = NULL;
return (0);
} else {
len = 0;
}
p = path;
} else {
p = rpath;
} else {
p = path;
}
}
return (0);
if (removable && hotpluggable)
return (1);
return (0);
}
/*
* _reset_devalloc
* If device allocation is being turned on, creates device_allocate
* device_maps if they do not exist.
*/
void
{
(void) _make_db();
return;
(void) da_update_device(&dargs);
}
/*
* _make_db
* execs /usr/sbin/mkdevalloc to create device_allocate and
* device_maps.
*/
static int
_make_db()
{
int status;
switch (pid) {
case -1:
return (1);
case 0:
default:
for (;;) {
continue;
else
return (1);
} else {
break;
}
}
break;
}
}
/*
* _update_devalloc_db
* Forms allocatable device entries to be written to device_allocate and
* device_maps.
*
* Or finds the correct entry to remove, and removes it.
*
* Note: devname is a /devices link in the REMOVE case.
*/
/* ARGSUSED */
void
char *root_dir)
{
int i;
char *typestring;
for (i = 0; i < DA_COUNT; i++) {
switch (i) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
default:
return;
}
if (dentry)
NULL);
}
} else
return;
if (event_driven) {
devname);
}
return;
}
/*
* Not reached as of now, could be reached if devfsadm is
* enhanced to clean up devalloc database more thoroughly.
* Will not reliably match for event-driven removes
*/
break;
}
}
}
/*
*
* If adding a device:
* dentry: A linked list of allocatable devices
* action: DA_ADD or DA_REMOVE
* devtype: type of device linked list to update on removal
* devname: short name (i.e. rmdisk5, cdrom0) of device if known
* rm_link: name of real /device from hot_cleanup
*
* If the action is ADD or if the action is triggered by an event
* from syseventd, read the files FIRST and treat their data as
* more-accurate than the dentry list, adjusting dentry contents if needed.
*
* For DA_ADD, try to add each device in the list to the files.
*
* If the action is DA_REMOVE and not a hotplug remove, adjust the files
* as indicated by the linked list.
*
* RETURNS:
* If we successfully remove a device from the files, returns
* a char * to strdup'd devname of the device removed.
*
* The caller is responsible for freeing the return value.
*
* NULL for all other cases, both success and failure.
*
*/
static char *
char *rm_link)
{
int status;
if (event_driven)
else
/*
* Add Events do not have enough information to overrride the
* existing file contents.
*/
(void) da_update_device(&dargs);
}
if (dentry) {
else
} else {
}
/*
* da_update_device will fill in entry devname if
* event_driven is true and device is in the file
*/
if (event_driven)
if (status == 0)
}
return (NULL);
}