All of lore.kernel.org
 help / color / mirror / Atom feed
From: Helmut Schaa <helmut.schaa@googlemail.com>
To: Luis R Rodriguez <mcgrof@gmail.com>
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH] crda: allow loading of regulatory.bin from /lib/crda in addition to /usr/lib/crda
Date: Tue, 24 Feb 2009 15:31:50 +0100	[thread overview]
Message-ID: <200902241531.50649.helmut.schaa@gmail.com> (raw)

As crda is typically installed in /sbin it might be worth to install
regulatory.bin into /lib/crda instead of /usr/lib/crda. Hence, extend
crda to try both paths for loading the database.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
---

diff --git a/crda.c b/crda.c
index f2c471f..55632a6 100644
--- a/crda.c
+++ b/crda.c
@@ -143,7 +143,7 @@ nla_put_failure:
 
 int main(int argc, char **argv)
 {
-	int fd;
+	int fd = -1;
 	struct stat stat;
 	__u8 *db;
 	struct regdb_file_header *header;
@@ -162,7 +162,12 @@ int main(int argc, char **argv)
 	struct nlattr *nl_reg_rules;
 	int num_rules;
 
-	const char regdb[] = "/usr/lib/crda/regulatory.bin";
+	const char *regdb_paths[] = {
+		"/usr/lib/crda/regulatory.bin",
+		"/lib/crda/regulatory.bin",
+		NULL
+	};
+	const char **regdb = regdb_paths;
 
 	if (argc != 1) {
 		fprintf(stderr, "Usage: %s\n", argv[0]);
@@ -183,7 +188,12 @@ int main(int argc, char **argv)
 
 	memcpy(alpha2, env_country, 2);
 
-	fd = open(regdb, O_RDONLY);
+	while (*regdb != NULL) {
+		fd = open(*regdb, O_RDONLY);
+		if (fd >= 0)
+			break;
+		regdb++;
+	}
 	if (fd < 0) {
 		perror("failed to open db file");
 		return -ENOENT;

             reply	other threads:[~2009-02-24 14:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-24 14:31 Helmut Schaa [this message]
2009-02-24 14:55 ` [PATCH] crda: allow loading of regulatory.bin from /lib/crda in addition to /usr/lib/crda John W. Linville
2009-02-24 19:46   ` Luis R. Rodriguez

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=200902241531.50649.helmut.schaa@gmail.com \
    --to=helmut.schaa@googlemail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mcgrof@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.