From 99dd5f8c7549a7e7f4183bd8040c3e0e8884594f Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 4 Jun 2006 15:27:17 +0000 Subject: Load firmware files from /lib/firmware --- tools/hciattach_st.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tools/hciattach_st.c b/tools/hciattach_st.c index 0279d398..46efbc2c 100644 --- a/tools/hciattach_st.c +++ b/tools/hciattach_st.c @@ -115,7 +115,7 @@ static int load_file(int dd, uint16_t version, const char *suffix) { DIR *dir; struct dirent *d; - char filename[NAME_MAX], prefix[20]; + char pathname[PATH_MAX], filename[NAME_MAX], prefix[20]; unsigned char cmd[256]; unsigned char buf[256]; uint8_t seqnum = 0; @@ -126,9 +126,14 @@ static int load_file(int dd, uint16_t version, const char *suffix) snprintf(prefix, sizeof(prefix), "STLC2500_R%d_%02d_", version >> 8, version & 0xff); - dir = opendir("."); - if (!dir) - return -errno; + strcpy(pathname, "/lib/firmware"); + dir = opendir(pathname); + if (!dir) { + strcpy(pathname, "."); + dir = opendir(pathname); + if (!dir) + return -errno; + } while (1) { d = readdir(dir); @@ -142,7 +147,8 @@ static int load_file(int dd, uint16_t version, const char *suffix) if (strncmp(d->d_name, prefix, strlen(prefix))) continue; - snprintf(filename, sizeof(filename), "%s", d->d_name); + snprintf(filename, sizeof(filename), "%s/%s", + pathname, d->d_name); } closedir(dir); -- cgit