]>
git.ipfire.org Git - thirdparty/systemd.git/blob - udev-remove.c
cd917af193e6a05a128bebdba51720480ed25a0b
6 * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation version 2 of the License.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 675 Mass Ave, Cambridge, MA 02139, USA.
32 #include "udev_version.h"
34 #include "libsysfs/libsysfs.h"
38 * Here would go a call to the naming deamon, to get the name we want to have
39 * for this device. But for now, let's just default to whatever the kernel is
40 * calling the device as that will keep the "old-style" naming policy
42 static char *get_name(char *dev
, int major
, int minor
)
44 static char name
[100];
47 temp
= strrchr(dev
, '/');
50 strncpy(name
, &temp
[1], sizeof(name
));
52 dbg("name is %s", name
);
58 * We also want to clean up any symlinks that were created in create_node()
60 static int delete_node(char *name
)
64 strncpy(filename
, UDEV_ROOT
, sizeof(filename
));
65 strncat(filename
, name
, sizeof(filename
));
67 dbg("unlinking %s", filename
);
68 return unlink(filename
);
71 int udev_remove_device(char *device
, char *subsystem
)
76 name
= get_name(device
, 0, 0);
78 dbg ("get_name failed");
83 return delete_node(name
);