Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FPGA Configuration Space
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FPGA Configuration Space
Commits
122a437a
Commit
122a437a
authored
Nov 22, 2012
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sdbfs/userspace: fix gensdbfs when called from other dir
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
c0dc555b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
11 deletions
+19
-11
gensdbfs.c
sdbfs/userspace/gensdbfs.c
+18
-11
gensdbfs.h
sdbfs/userspace/gensdbfs.h
+1
-0
No files found.
sdbfs/userspace/gensdbfs.c
View file @
122a437a
...
...
@@ -42,13 +42,17 @@ static inline unsigned long SDB_ALIGN(unsigned long x)
}
/* Helpers for scan_input(), which is below */
static
void
__fill_dot
(
struct
sdbf
*
dot
)
static
void
__fill_dot
(
struct
sdbf
*
dot
,
char
*
dir
)
{
struct
sdb_interconnect
*
i
=
&
dot
->
s_i
;
struct
sdb_component
*
c
=
&
i
->
sdb_component
;
struct
sdb_product
*
p
=
&
c
->
product
;
char
fn
[
PATH_MAX
];
dot
->
fullname
=
strdup
(
"."
);
strcpy
(
fn
,
dir
);
strcat
(
fn
,
"/."
);
dot
->
fullname
=
strdup
(
fn
);
dot
->
basename
=
strdup
(
"."
);
i
->
sdb_magic
=
htonl
(
SDB_MAGIC
);
i
->
sdb_version
=
1
;
i
->
sdb_bus_type
=
sdb_data
;
...
...
@@ -74,6 +78,7 @@ static int __fill_file(struct sdbf *f, char *dir, char *fname)
strcat
(
fn
,
"/"
);
strcat
(
fn
,
fname
);
f
->
fullname
=
strdup
(
fn
);
f
->
basename
=
strdup
(
fname
);
if
(
stat
(
fn
,
&
f
->
stbuf
)
<
0
)
{
fprintf
(
stderr
,
"%s: stat(%s): %s
\n
"
,
prgname
,
fn
,
strerror
(
errno
));
...
...
@@ -123,11 +128,7 @@ static struct sdbf *find_filename(struct sdbf *tree, char *s)
for
(
i
=
0
;
i
<
n
;
i
++
)
{
f
=
tree
+
i
;
if
(
!
strcmp
(
s
,
f
->
fullname
))
return
f
;
/* "fullname" includes the leading "./", but ease the user */
if
(
!
strncmp
(
f
->
fullname
,
"./"
,
2
)
&&
!
strcmp
(
s
,
f
->
fullname
+
2
))
if
(
!
strcmp
(
s
,
f
->
basename
))
return
f
;
}
return
NULL
;
...
...
@@ -214,13 +215,18 @@ static struct sdbf *scan_input(char *name, struct sdbf *parent, FILE **cfgf)
tree
[
n
].
de
=
*
de
;
if
(
!
strcmp
(
de
->
d_name
,
"."
))
{
tree
[
0
].
de
=
*
de
;
__fill_dot
(
tree
);
__fill_dot
(
tree
,
name
);
continue
;
}
if
(
!
strcmp
(
de
->
d_name
,
".."
))
continue
;
/* no dot-dot */
if
(
!
strcmp
(
de
->
d_name
,
CFG_NAME
))
{
*
cfgf
=
fopen
(
de
->
d_name
,
"r"
);
char
s
[
PATH_MAX
];
strcpy
(
s
,
name
);
strcat
(
s
,
"/"
);
strcat
(
s
,
de
->
d_name
);
*
cfgf
=
fopen
(
s
,
"r"
);
if
(
!*
cfgf
)
fprintf
(
stderr
,
"%s: open(%s): %s
\n
"
,
prgname
,
CFG_NAME
,
strerror
(
errno
));
...
...
@@ -290,7 +296,8 @@ static struct sdbf *scan_config(struct sdbf *tree, FILE *f)
/* line starts in column 0: new file name */
current
=
find_filename
(
tree
,
s
);
if
(
!
current
)
{
fprintf
(
stderr
,
"%s: %s:%i:
\"
%s
\"
not found
\n
"
,
fprintf
(
stderr
,
"%s: Warning: %s:%i: "
"
\"
%s
\"
not found
\n
"
,
prgname
,
CFG_NAME
,
lineno
,
s
);
}
continue
;
...
...
@@ -410,7 +417,7 @@ int main(int argc, char **argv)
{
int
c
;
struct
stat
stbuf
;
FILE
*
fcfg
,
*
fout
;
FILE
*
fcfg
=
NULL
,
*
fout
;
char
*
rest
;
struct
sdbf
*
tree
;
...
...
sdbfs/userspace/gensdbfs.h
View file @
122a437a
...
...
@@ -14,6 +14,7 @@ struct sdbf {
struct
sdb_bridge
s_b
;
};
char
*
fullname
;
char
*
basename
;
unsigned
long
astart
,
rstart
;
/* absolute, relative */
unsigned
long
size
;
int
nfiles
,
totsize
;
/* for dirs */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment