udev_node.c revision 17fcfb5972977b6a3aedca6ad2aa8d1fbfbc761d
/*
* Copyright (C) 2004-2008 Kay Sievers <kay.sievers@vrfy.org>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stddef.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <grp.h>
#include <dirent.h>
#include "udev.h"
#include "udev_rules.h"
#define TMP_FILE_EXT ".udev-tmp"
int udev_node_mknod(struct udevice *udevice, const char *file, dev_t devt, mode_t mode, uid_t uid, gid_t gid)
{
int preserve = 0;
int err = 0;
else
preserve = 1;
} else {
if (err != 0) {
goto exit;
}
if (err != 0) {
}
}
} else {
if (err != 0) {
goto exit;
}
}
if (err != 0) {
goto exit;
}
}
if (err != 0) {
goto exit;
}
}
exit:
return err;
}
{
int i = 0;
int tail = 0;
int len;
int retval = 0;
/* use relative link */
if (node[i] == '/')
tail = i+1;
i++;
}
while (slink[i] != '\0') {
if (slink[i] == '/')
i++;
}
/* preserve link with correct target, do not replace node of other device */
} else {
err(udevice->udev, "device node '%s' already exists, link to '%s' will not overwrite it\n", slink, node);
goto exit;
}
}
char buf[UTIL_PATH_SIZE];
if (len > 0) {
goto exit;
}
}
}
} else {
if (retval == 0)
goto exit;
}
if (retval != 0) {
goto exit;
}
if (retval != 0) {
goto exit;
}
exit:
return retval;
}
{
char slink[UTIL_PATH_SIZE];
char node[UTIL_PATH_SIZE];
struct udevice *udevice_db;
struct name_entry *device;
int count;
int priority = 0;
int rc = 0;
/* if we don't have a reference, delete it */
if (count <= 0) {
}
goto out;
}
/* find the device with the highest priority */
/* did we find ourself? we win, if we have the same priority */
info(udevice->udev, "'%s' is our device node, database inconsistent, skip link update\n", udevice->name);
}
continue;
}
/* another device, read priority from database */
if (udevice_db == NULL)
continue;
info(udevice->udev, "'%s' is a device node of '%s', skip link update\n", udevice_db->name, device->name);
} else {
}
}
}
}
if (target[0] == '\0') {
rc = 1;
goto out;
}
/* create symlink to the target with the highest priority */
info(udevice->udev, "'%s' with target '%s' has the highest priority %i, create it\n", name, target, priority);
}
out:
return rc;
}
{
struct name_entry *name_loop;
}
/* export symlinks to environment */
if (symlinks[0] != '\0')
/* update possible left-over symlinks (device metadata changed) */
if (udevice_old != NULL) {
struct name_entry *link_loop;
struct name_entry *link_old_loop;
int found;
/* remove current symlinks from old list */
found = 0;
found = 1;
break;
}
}
if (!found) {
/* link does no longer belong to this device */
}
}
/*
* if the node name has changed, delete the node,
* or possibly restore a symlink of another device
*/
}
}
{
char filename[UTIL_PATH_SIZE];
int i;
int retval = 0;
uid = 0;
else {
char *endptr;
unsigned long id;
if (endptr[0] == '\0')
else
}
gid = 0;
else {
char *endptr;
unsigned long id;
if (endptr[0] == '\0')
else
}
retval = -1;
goto exit;
}
/* create all_partitions if requested */
if (udevice->partitions) {
char partitionname[UTIL_PATH_SIZE];
char *attr;
int range;
/* take the maximum registered minor range */
if (range > 1)
}
}
}
}
exit:
return retval;
}
{
char filename[UTIL_PATH_SIZE];
char partitionname[UTIL_PATH_SIZE];
int retval = 0;
int num;
return 0;
}
return -1;
}
if (retval)
return retval;
if (num > 0) {
int i;
if (num > 255)
return -1;
for (i = 1; i <= num; i++) {
}
}
return retval;
}