Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SDB - Self-describing Bus
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
SDB - Self-describing Bus
Commits
aa05e0dd
Commit
aa05e0dd
authored
11 years ago
by
Alessandro Rubini
Browse files
Options
Downloads
Patches
Plain Diff
sdbfs/lib: add write method; misc cleanups
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
1387c482
Branches
Branches containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
sdbfs/lib/access.c
+24
-7
24 additions, 7 deletions
sdbfs/lib/access.c
sdbfs/lib/glue.c
+2
-0
2 additions, 0 deletions
sdbfs/lib/glue.c
sdbfs/lib/libsdbfs.h
+2
-2
2 additions, 2 deletions
sdbfs/lib/libsdbfs.h
with
28 additions
and
9 deletions
sdbfs/lib/access.c
+
24
−
7
View file @
aa05e0dd
/*
* 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
;
}
This diff is collapsed.
Click to expand it.
sdbfs/lib/glue.c
+
2
−
0
View file @
aa05e0dd
...
...
@@ -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
;
}
...
...
This diff is collapsed.
Click to expand it.
sdbfs/lib/libsdbfs.h
+
2
−
2
View file @
aa05e0dd
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment