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
d37e8885
Commit
d37e8885
authored
May 20, 2013
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sdbfs/lib: add write method; misc cleanups
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
54db5f20
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
9 deletions
+28
-9
access.c
sdbfs/lib/access.c
+24
-7
glue.c
sdbfs/lib/glue.c
+2
-0
libsdbfs.h
sdbfs/lib/libsdbfs.h
+2
-2
No files found.
sdbfs/lib/access.c
View file @
d37e8885
/*
* Copyright (C) 2012 CERN (www.cern.ch)
* Copyright (C) 2012
,2013
CERN (www.cern.ch)
* Author: Alessandro Rubini <rubini@gnudd.com>
*
* Released according to the GNU GPL, version 2 or any later version.
...
...
@@ -19,8 +19,10 @@ int sdbfs_fstat(struct sdbfs *fs, struct sdb_device *record_return)
return
0
;
}
int
sdbfs_fread
(
struct
sdbfs
*
fs
,
int
offset
,
char
*
buf
,
int
count
)
int
sdbfs_fread
(
struct
sdbfs
*
fs
,
int
offset
,
void
*
buf
,
int
count
)
{
int
ret
=
count
;
if
(
!
fs
->
currentp
)
return
-
ENOENT
;
if
(
offset
<
0
)
...
...
@@ -30,12 +32,27 @@ int sdbfs_fread(struct sdbfs *fs, int offset, char *buf, int count)
if
(
fs
->
data
)
memcpy
(
buf
,
fs
->
data
+
fs
->
f_offset
+
offset
,
count
);
else
fs
->
read
(
fs
,
fs
->
f_offset
+
offset
,
buf
,
count
);
fs
->
read_offset
=
offset
+
count
;
return
count
;
ret
=
fs
->
read
(
fs
,
fs
->
f_offset
+
offset
,
buf
,
count
);
if
(
ret
>
0
)
fs
->
read_offset
=
offset
+
ret
;
return
ret
;
}
int
sdbfs_fwrite
(
struct
sdbfs
*
fs
,
int
offset
,
char
*
buf
,
int
count
)
int
sdbfs_fwrite
(
struct
sdbfs
*
fs
,
int
offset
,
void
*
buf
,
int
count
)
{
return
-
ENOSYS
;
int
ret
=
count
;
if
(
!
fs
->
currentp
)
return
-
ENOENT
;
if
(
offset
<
0
)
offset
=
fs
->
read_offset
;
if
(
offset
+
count
>
fs
->
f_len
)
count
=
fs
->
f_len
-
offset
;
if
(
fs
->
data
)
memcpy
(
buf
,
fs
->
data
+
fs
->
f_offset
+
offset
,
count
);
else
ret
=
fs
->
write
(
fs
,
fs
->
f_offset
+
offset
,
buf
,
count
);
if
(
ret
>
0
)
fs
->
read_offset
=
offset
+
ret
;
return
ret
;
}
sdbfs/lib/glue.c
View file @
d37e8885
...
...
@@ -74,6 +74,8 @@ static struct sdb_device *sdbfs_readentry(struct sdbfs *fs,
*/
if
(
fs
->
data
)
return
(
struct
sdb_device
*
)(
fs
->
data
+
offset
);
if
(
!
fs
->
read
)
return
NULL
;
fs
->
read
(
fs
,
offset
,
&
fs
->
current_record
,
sizeof
(
fs
->
current_record
));
return
&
fs
->
current_record
;
}
...
...
sdbfs/lib/libsdbfs.h
View file @
d37e8885
...
...
@@ -59,8 +59,8 @@ struct sdb_device *sdbfs_scan(struct sdbfs *fs, int newscan);
/* Defined in access.c */
int
sdbfs_fstat
(
struct
sdbfs
*
fs
,
struct
sdb_device
*
record_return
);
int
sdbfs_fread
(
struct
sdbfs
*
fs
,
int
offset
,
char
*
buf
,
int
count
);
int
sdbfs_fwrite
(
struct
sdbfs
*
fs
,
int
offset
,
char
*
buf
,
int
count
);
int
sdbfs_fread
(
struct
sdbfs
*
fs
,
int
offset
,
void
*
buf
,
int
count
);
int
sdbfs_fwrite
(
struct
sdbfs
*
fs
,
int
offset
,
void
*
buf
,
int
count
);
/* This is needed to convert endianness. Hoping it is not defined elsewhere */
static
inline
uint64_t
htonll
(
uint64_t
ll
)
...
...
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