udev_remove.c revision 1cec1c241600fc11121f9504bc9e95836c03bd9c
/*
*
* Userspace devfs
*
* Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
*
*
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2 of the License.
*
* 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, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include "udev.h"
#include "udev_utils.h"
#include "udev_version.h"
#include "namedev.h"
#include "udev_db.h"
#include "logging.h"
static int delete_path(const char *path)
{
char *pos;
int retval;
while (1) {
*pos = '\0';
/* don't remove the last one */
break;
/* remove if empty */
retval = 0;
if (retval) {
return 0;
dbg("rmdir(%s) failed with error '%s'",
break;
}
}
return 0;
}
{
char partitionname[NAME_SIZE];
int retval;
int i;
char *pos;
int len;
int num;
return -1;
return -1;
}
if (retval)
return retval;
/* remove all_partitions nodes */
if (num > 0) {
if (num > 255) {
info("garbage from udev database, skip all_partitions removal");
return -1;
}
for (i = 1; i <= num; i++) {
strintcat(partitionname, i);
}
}
/* remove subdirectories */
retval = 0;
if (retval) {
dbg("unlink(%s) failed with error '%s'",
return retval;
}
}
}
return retval;
}
/*
* look up the sysfs path in the database to get the node name to remove
* If we can't find it, use kernel name for lack of anything else to know to do
*/
{
const char *temp;
int retval;
return 0;
if (retval) {
/* fall back to kernel name */
return -ENODEV;
}
if (udev->ignore_remove) {
return 0;
}
/* use full path to the environment */
return delete_node(udev);
}