linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Vlasov <vsu@altlinux.ru>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] unlink old database file before creating a new one
Date: Tue, 23 Jan 2007 15:37:33 +0000	[thread overview]
Message-ID: <11695666531692-git-send-email-vsu@altlinux.ru> (raw)

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 <vsu@altlinux.ru>
---
 udev_db.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/udev_db.c b/udev_db.c
index f3c9509..b1217d8 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));
-- 
1.5.0.rc2.gd894fb


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

             reply	other threads:[~2007-01-23 15:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-23 15:37 Sergey Vlasov [this message]
2007-01-24  9:48 ` [PATCH] unlink old database file before creating a new one Kay Sievers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11695666531692-git-send-email-vsu@altlinux.ru \
    --to=vsu@altlinux.ru \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).