udev-remove.c revision 3d150dfb28efbaf0b25f154fb8955c47d606c3d5
/*
*
* 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 <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include "udev.h"
#include "udev_version.h"
#include "namedev.h"
#include "udevdb.h"
#include "libsysfs/libsysfs.h"
static int delete_path(char *path)
{
char *pos;
int retval;
while (1) {
*pos = '\0';
/* don't remove the last one */
break;
/* remove if empty */
if (retval) {
return 0;
dbg("rmdir(%s) failed with error '%s'",
break;
}
}
return 0;
}
{
char filename[255];
int retval;
if (retval) {
dbg("unlink(%s) failed with error '%s'",
return retval;
}
/* remove subdirectories */
if (retval) {
dbg("unlink(%s) failed with error '%s'",
return retval;
}
}
}
return retval;
}
/*
* Look up the sysfs path in the database to see if we have named this device
* something different from the kernel name. If we have, us it. If not, use
* the default kernel name for lack of anything else to know to do.
*/
{
char name[100];
char *temp;
return -ENODEV;
}
return delete_node(dev);
}