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
174d4a37
Commit
174d4a37
authored
Sep 28, 2012
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sdbfs/kernel: fix two somehow minor shortcomings
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
dad95997
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
sdbfs-core.c
sdbfs/kernel/sdbfs-core.c
+21
-14
No files found.
sdbfs/kernel/sdbfs-core.c
View file @
174d4a37
...
...
@@ -32,13 +32,11 @@ static int sdbfs_readdir(struct file * filp,
int
i
,
j
,
n
;
printk
(
"%s
\n
"
,
__func__
);
if
(
file_off
!=
0
)
return
0
;
inode
=
container_of
(
ino
,
struct
sdbfs_inode
,
ino
);
n
=
be16_to_cpu
(
inode
->
s_i
.
sdb_records
)
-
1
;
/* FIXME: use file_off */
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
i
=
file_off
;
i
<
n
;
i
++
)
{
char
s
[
20
];
offset
+=
SDB_SIZE
;
...
...
@@ -71,30 +69,39 @@ static ssize_t sdbfs_read(struct file *f, char __user *buf, size_t count,
struct
sdbfs_inode
*
inode
;
char
kbuf
[
16
];
unsigned
long
start
,
size
;
ssize_t
ret
;
ssize_t
i
,
done
;
inode
=
container_of
(
ino
,
struct
sdbfs_inode
,
ino
);
start
=
be64_to_cpu
(
inode
->
s_d
.
sdb_component
.
addr_first
);
size
=
be64_to_cpu
(
inode
->
s_d
.
sdb_component
.
addr_last
)
+
1
-
start
;
/* Horribly inefficient, who cares... */
if
(
*
offp
>
size
)
return
0
;
if
(
*
offp
+
count
>
size
)
count
=
size
-
*
offp
;
ret
=
count
;
while
(
count
)
{
done
=
0
;
while
(
done
<
count
)
{
/* Horribly inefficient, just copy a few bytes at a time */
int
n
=
sizeof
(
kbuf
)
>
count
?
count
:
sizeof
(
kbuf
);
/* FIXME: error checking */
sd
->
ops
->
read
(
sd
,
start
+
*
offp
,
kbuf
,
n
);
if
(
copy_to_user
(
buf
,
kbuf
,
n
))
i
=
sd
->
ops
->
read
(
sd
,
start
+
*
offp
,
kbuf
,
n
);
if
(
i
<
0
)
{
if
(
done
)
return
done
;
return
i
;
}
if
(
copy_to_user
(
buf
,
kbuf
,
i
))
return
-
EFAULT
;
count
-=
n
;
buf
+=
n
;
*
offp
+=
n
;
buf
+=
i
;
done
+=
i
;
if
(
i
!=
n
)
{
/* Partial read: done for this time */
break
;
}
}
return
ret
;
*
offp
+=
done
;
return
done
;
}
static
const
struct
file_operations
sdbfs_fops
=
{
...
...
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