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
a92586eb
Commit
a92586eb
authored
May 22, 2013
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sdbfs/userspace/gensdbfs: add a fill_product helper
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
9feb4315
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
22 deletions
+23
-22
gensdbfs.c
sdbfs/userspace/gensdbfs.c
+22
-22
gensdbfs.h
sdbfs/userspace/gensdbfs.h
+1
-0
No files found.
sdbfs/userspace/gensdbfs.c
View file @
a92586eb
...
...
@@ -41,6 +41,25 @@ static inline unsigned long SDB_ALIGN(unsigned long x)
return
(
x
+
(
blocksize
-
1
))
&
~
(
blocksize
-
1
);
}
static
void
__fill_product
(
struct
sdb_product
*
p
,
char
*
name
,
time_t
t
,
int
record_type
)
{
int
len
=
strlen
(
name
);
if
(
len
>
sizeof
(
p
->
name
))
{
fprintf
(
stderr
,
"%s: truncating filename
\"
%s
\"\n
"
,
prgname
,
name
);
len
=
sizeof
(
p
->
name
);
}
memset
(
p
->
name
,
' '
,
sizeof
(
p
->
name
));
memcpy
(
p
->
name
,
name
,
len
);
memcpy
(
&
p
->
device_id
,
p
->
name
,
sizeof
(
p
->
device_id
));
p
->
vendor_id
=
DEFAULT_VENDOR
;
/* changed by config, possibly */
p
->
version
=
htonl
(
1
);
/* FIXME: version of gensdbfs */
/* FIXME: date */
p
->
record_type
=
record_type
;
}
/* Helpers for scan_input(), which is below */
static
void
__fill_dot
(
struct
sdbf
*
dot
,
char
*
dir
)
{
...
...
@@ -57,13 +76,7 @@ static void __fill_dot(struct sdbf *dot, char *dir)
i
->
sdb_version
=
1
;
i
->
sdb_bus_type
=
sdb_data
;
/* c->addr_first/last to be filled later */
p
->
vendor_id
=
htonll
(
0x46696c6544617461LL
);
/* "FileData" */
p
->
version
=
htonl
(
1
);
/* FIXME: version of gensdbfs */
/* FIXME: date */
memset
(
p
->
name
,
' '
,
sizeof
(
p
->
name
));
p
->
name
[
0
]
=
'.'
;
memcpy
(
&
p
->
device_id
,
p
->
name
,
4
);
p
->
record_type
=
sdb_type_interconnect
;
__fill_product
(
p
,
"."
,
0
/* date */
,
sdb_type_interconnect
);
}
static
int
__fill_file
(
struct
sdbf
*
f
,
char
*
dir
,
char
*
fname
)
...
...
@@ -72,7 +85,7 @@ static int __fill_file(struct sdbf *f, char *dir, char *fname)
struct
sdb_device
*
d
=
&
f
->
s_d
;
struct
sdb_component
*
c
=
&
d
->
sdb_component
;
struct
sdb_product
*
p
=
&
c
->
product
;
int
flags
,
len
;
int
flags
;
strcpy
(
fn
,
dir
);
strcat
(
fn
,
"/"
);
...
...
@@ -108,20 +121,7 @@ static int __fill_file(struct sdbf *f, char *dir, char *fname)
if
(
f
->
stbuf
.
st_mode
&
S_IXOTH
)
flags
|=
SDB_DATA_EXEC
;
d
->
bus_specific
=
htonl
(
flags
);
/* c->addr_first/last to be filled later */
p
->
vendor_id
=
htonll
(
0x46696c6544617461LL
);
/* "FileData" */
p
->
version
=
htonl
(
1
);
/* FIXME: version of gensdbfs */
/* FIXME: date */
memset
(
p
->
name
,
' '
,
sizeof
(
p
->
name
));
len
=
strlen
(
fname
);
if
(
len
>
sizeof
(
p
->
name
))
{
fprintf
(
stderr
,
"%s: truncating filename
\"
%s
\"\n
"
,
prgname
,
fname
);
len
=
sizeof
(
p
->
name
);
}
memcpy
(
p
->
name
,
fname
,
len
);
memcpy
(
&
p
->
device_id
,
p
->
name
,
4
);
p
->
record_type
=
sdb_type_device
;
__fill_product
(
p
,
f
->
basename
,
f
->
stbuf
.
st_mtime
,
sdb_type_device
);
return
1
;
}
...
...
sdbfs/userspace/gensdbfs.h
View file @
a92586eb
...
...
@@ -3,6 +3,7 @@
#include <stdint.h>
#define CFG_NAME "--SDB-CONFIG--"
#define DEFAULT_VENDOR htonll(0x46696c6544617461LL)
/* "FileData" */
/* We need to keep track of each file as both unix and sdb entity*/
struct
sdbf
{
...
...
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