summaryrefslogtreecommitdiffstats
path: root/scripts/dtc/fstree.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/dtc/fstree.c')
-rw-r--r--scripts/dtc/fstree.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/scripts/dtc/fstree.c b/scripts/dtc/fstree.c
index e464727c8808..6d1beec9581d 100644
--- a/scripts/dtc/fstree.c
+++ b/scripts/dtc/fstree.c
@@ -37,26 +37,26 @@ static struct node *read_fstree(const char *dirname)
37 tree = build_node(NULL, NULL); 37 tree = build_node(NULL, NULL);
38 38
39 while ((de = readdir(d)) != NULL) { 39 while ((de = readdir(d)) != NULL) {
40 char *tmpnam; 40 char *tmpname;
41 41
42 if (streq(de->d_name, ".") 42 if (streq(de->d_name, ".")
43 || streq(de->d_name, "..")) 43 || streq(de->d_name, ".."))
44 continue; 44 continue;
45 45
46 tmpnam = join_path(dirname, de->d_name); 46 tmpname = join_path(dirname, de->d_name);
47 47
48 if (lstat(tmpnam, &st) < 0) 48 if (lstat(tmpname, &st) < 0)
49 die("stat(%s): %s\n", tmpnam, strerror(errno)); 49 die("stat(%s): %s\n", tmpname, strerror(errno));
50 50
51 if (S_ISREG(st.st_mode)) { 51 if (S_ISREG(st.st_mode)) {
52 struct property *prop; 52 struct property *prop;
53 FILE *pfile; 53 FILE *pfile;
54 54
55 pfile = fopen(tmpnam, "r"); 55 pfile = fopen(tmpname, "rb");
56 if (! pfile) { 56 if (! pfile) {
57 fprintf(stderr, 57 fprintf(stderr,
58 "WARNING: Cannot open %s: %s\n", 58 "WARNING: Cannot open %s: %s\n",
59 tmpnam, strerror(errno)); 59 tmpname, strerror(errno));
60 } else { 60 } else {
61 prop = build_property(xstrdup(de->d_name), 61 prop = build_property(xstrdup(de->d_name),
62 data_copy_file(pfile, 62 data_copy_file(pfile,
@@ -67,12 +67,12 @@ static struct node *read_fstree(const char *dirname)
67 } else if (S_ISDIR(st.st_mode)) { 67 } else if (S_ISDIR(st.st_mode)) {
68 struct node *newchild; 68 struct node *newchild;
69 69
70 newchild = read_fstree(tmpnam); 70 newchild = read_fstree(tmpname);
71 newchild = name_node(newchild, xstrdup(de->d_name)); 71 newchild = name_node(newchild, xstrdup(de->d_name));
72 add_child(tree, newchild); 72 add_child(tree, newchild);
73 } 73 }
74 74
75 free(tmpnam); 75 free(tmpname);
76 } 76 }
77 77
78 closedir(d); 78 closedir(d);
@@ -88,3 +88,4 @@ struct boot_info *dt_from_fs(const char *dirname)
88 88
89 return build_boot_info(NULL, tree, guess_boot_cpuid(tree)); 89 return build_boot_info(NULL, tree, guess_boot_cpuid(tree));
90} 90}
91