From: Sergey Vlasov Date: Tue, 23 Jan 2007 18:55:38 +0000 (+0100) Subject: unlink old database file before creating a new one X-Git-Tag: 174~2077 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=e0c0807ab32fde7f55776e0a300016bad922e636 unlink old database file before creating a new one udev_db_add_device() can be called when the corressponding database entry already exists - it should overwrite the old entry in this case. However, if the old entry was a symlink, fopen(filename, "w") will not overwrite it properly - it will keep the symlink and create a file named after the symlink target. Calling unlink(filename) before trying to create the database file fixes the problem. Signed-off-by: Sergey Vlasov --- diff --git a/udev_db.c b/udev_db.c index f3c9509dc..b1217d80e 100644 --- a/udev_db.c +++ b/udev_db.c @@ -93,6 +93,7 @@ int udev_db_add_device(struct udevice *udev) struct name_entry *name_loop; FILE *f; + unlink(filename); f = fopen(filename, "w"); if (f == NULL) { err("unable to create db file '%s': %s", filename, strerror(errno));