Add another field to the filename specified for create and add operations
to specify the intended pathname for the blob.
Signed-off-by: Jordan Crouse <[EMAIL PROTECTED]>
Index: LinuxBIOSv3/util/lar/stream.c
===================================================================
--- LinuxBIOSv3.orig/util/lar/stream.c 2007-07-23 09:47:04.000000000 -0600
+++ LinuxBIOSv3/util/lar/stream.c 2007-07-23 09:51:39.000000000 -0600
@@ -543,6 +543,8 @@
int lar_add_file(struct lar *lar, const char *name)
{
char *filename, *ptr, *temp;
+ char *pathname;
+
enum compalgo thisalgo;
struct lar_header *header;
u32 offset;
@@ -567,6 +569,20 @@
if (filename[0] == '.' && filename[1] == '/')
filename += 2;
+ pathname = strchr(filename, ':');
+
+ if (pathname != NULL) {
+ *pathname = '\0';
+ pathname++;
+
+ if (!strlen(pathname)) {
+ err("Invalid pathname specified.\n");
+ return -1;
+ }
+ }
+ else
+ pathname = filename;
+
/* Open the file */
fd = open(filename, O_RDONLY);
@@ -614,7 +630,7 @@
munmap(ptr, s.st_size);
close(fd);
- pathlen = strlen(filename) + 1 > MAX_PATHLEN ? MAX_PATHLEN :
strlen(filename) + 1;
+ pathlen = strlen(pathname) + 1 > MAX_PATHLEN ? MAX_PATHLEN :
strlen(pathname) + 1;
/* Figure out how big our header will be */
hlen = sizeof(struct lar_header) + pathlen;
@@ -641,7 +657,7 @@
/* Copy the path name */
strncpy((char *) (lar->map + offset + sizeof(struct lar_header)),
- filename, pathlen - 1);
+ pathname, pathlen - 1);
/* Copy in the data */
memcpy(lar->map + (offset + hlen), temp, complen);
Index: LinuxBIOSv3/util/lar/lib.c
===================================================================
--- LinuxBIOSv3.orig/util/lar/lib.c 2007-07-23 09:51:11.000000000 -0600
+++ LinuxBIOSv3/util/lar/lib.c 2007-07-23 09:51:39.000000000 -0600
@@ -195,16 +195,29 @@
{
struct stat filestat;
int ret = -1;
- const char *realname;
+ char *realname;
+ char *c;
- realname = name;
if (strstr(name, "nocompress:") == name) {
- realname = name + 11;
+ name += 11;
}
+ realname = strdup(name);
+
+ if (realname == NULL) {
+ fprintf(stderr, "Out of memory.\n");
+ exit(1);
+ }
+
+ c = strchr(realname, ':');
+
+ if (c != NULL)
+ *c = '\0';
+
/* printf("... add_files %s\n", name); */
if (stat(realname, &filestat) == -1) {
fprintf(stderr, "Error getting file attributes of %s\n", name);
+ free(realname);
return -1;
}
@@ -249,6 +262,7 @@
ret = 0;
}
+ free(realname);
return ret;
}
--
Jordan Crouse
Systems Software Development Engineer
Advanced Micro Devices, Inc.
--
linuxbios mailing list
[email protected]
http://www.linuxbios.org/mailman/listinfo/linuxbios