udev-node.c revision cb14f4543a941ff8a22ef2725df86b3b0190a189
/*
* 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"
#define TMP_FILE_EXT ".udev-tmp"
/* reverse mapping from the device file name to the devpath */
{
char device[UTIL_PATH_SIZE];
int fd;
/* directory with device name */
/* entry with the devpath */
if (add) {
if (fd > 0)
} else {
}
return 0;
}
int udev_node_mknod(struct udev_device *dev, const char *file, dev_t devnum, 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;
}
{
char target[UTIL_PATH_SIZE];
int i = 0;
int tail = 0;
int len;
int err = 0;
/* use relative link */
target[0] = '\0';
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 {
"link to '%s' will not overwrite it\n",
goto exit;
}
}
char buf[UTIL_PATH_SIZE];
if (len > 0) {
goto exit;
}
}
}
} else {
if (err == 0)
goto exit;
}
if (err != 0) {
goto exit;
}
if (err != 0) {
goto exit;
}
exit:
return err;
}
static int name_index_get_devices(struct udev *udev, const char *name, struct udev_list_node *dev_list)
{
int count = 0;
count = -1;
goto out;
}
while (1) {
char device[UTIL_PATH_SIZE];
break;
continue;
count++;
}
out:
return count;
}
{
struct udev_list_node dev_list;
struct udev_list_entry *dev_entry;
char target[UTIL_PATH_SIZE];
int count;
int priority = 0;
int rc = 0;
if (count > 1)
/* if we don't have a reference, delete it */
if (count <= 0) {
goto out;
}
/* find the device with the highest priority */
target[0] = '\0';
const char *syspath;
struct udev_device *dev_db;
const char *devnode;
/* did we find ourself? we win, if we have the same priority */
}
continue;
}
/* another device, read priority from database */
continue;
} else {
priority);
}
}
}
}
if (target[0] == '\0') {
rc = 1;
goto out;
}
/* create symlink to the target with the highest priority */
info(udev, "'%s' with target '%s' has the highest priority %i, create it\n", slink, target, priority);
out:
return rc;
}
{
struct udev_list_entry *list_entry;
const char *devnode_old;
/* update possible left-over symlinks */
struct udev_list_entry *list_entry_current;
int found;
/* check if old link name is now our node name */
continue;
/* check if old link name still belongs to this device */
found = 0;
found = 1;
break;
}
}
if (found)
continue;
}
/*
* if the node name has changed, delete the node,
* and possibly restore a symlink of a different device
*/
if (devnode_old != NULL) {
}
}
}
{
int i;
int num;
struct udev_list_entry *list_entry;
int err = 0;
err = -1;
goto exit;
}
/* create all_partitions if requested */
if (num > 0) {
for (i = 1; i <= num; i++) {
char partitionname[UTIL_PATH_SIZE];
udev_device_get_devnode(dev), i);
}
}
/* add node to name index */
}
exit:
return err;
}
{
struct udev_list_entry *list_entry;
const char *devnode;
char partitionname[UTIL_PATH_SIZE];
int err = 0;
int num;
/* remove node from name index */
/* remove,update symlinks, remove symlinks from name index */
}
return 0;
return 0;
}
return -1;
}
if (err)
return err;
if (num > 0) {
int i;
if (num > 255)
return -1;
for (i = 1; i <= num; i++) {
}
}
return err;
}