Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
drivers
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Liam Naddell
drivers
Commits
c1a1de1a
Commit
c1a1de1a
authored
Sep 29, 2016
by
Jeremy Soller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix dup deadlock, add stat
parent
e4005d05
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
ahcid/src/scheme.rs
ahcid/src/scheme.rs
+15
-3
No files found.
ahcid/src/scheme.rs
View file @
c1a1de1a
...
...
@@ -3,7 +3,7 @@ use std::{cmp, str};
use
std
::
sync
::
Arc
;
use
std
::
sync
::
atomic
::{
AtomicUsize
,
Ordering
};
use
spin
::
Mutex
;
use
syscall
::{
Error
,
EBADF
,
EINVAL
,
ENOENT
,
Result
,
Scheme
,
SEEK_CUR
,
SEEK_END
,
SEEK_SET
};
use
syscall
::{
Error
,
EBADF
,
EINVAL
,
ENOENT
,
Result
,
Scheme
,
S
tat
,
MODE_FILE
,
S
EEK_CUR
,
SEEK_END
,
SEEK_SET
};
use
ahci
::
disk
::
Disk
;
...
...
@@ -45,13 +45,25 @@ impl Scheme for DiskScheme {
fn
dup
(
&
self
,
id
:
usize
)
->
Result
<
usize
>
{
let
mut
handles
=
self
.handles
.lock
();
let
mut
handle
=
handles
.get_mut
(
&
id
)
.ok_or
(
Error
::
new
(
EBADF
))
?
;
let
new_handle
=
{
let
handle
=
handles
.get
(
&
id
)
.ok_or
(
Error
::
new
(
EBADF
))
?
;
handle
.clone
()
};
let
new_id
=
self
.next_id
.fetch_add
(
1
,
Ordering
::
SeqCst
);
self
.handles
.lock
()
.insert
(
new_id
,
handle
.clone
()
);
handles
.insert
(
new_id
,
new_handle
);
Ok
(
new_id
)
}
fn
fstat
(
&
self
,
id
:
usize
,
stat
:
&
mut
Stat
)
->
Result
<
usize
>
{
let
handles
=
self
.handles
.lock
();
let
handle
=
handles
.get
(
&
id
)
.ok_or
(
Error
::
new
(
EBADF
))
?
;
stat
.st_mode
=
MODE_FILE
;
stat
.st_size
=
handle
.0
.lock
()
.size
();
Ok
(
0
)
}
fn
read
(
&
self
,
id
:
usize
,
buf
:
&
mut
[
u8
])
->
Result
<
usize
>
{
let
mut
handles
=
self
.handles
.lock
();
let
mut
handle
=
handles
.get_mut
(
&
id
)
.ok_or
(
Error
::
new
(
EBADF
))
?
;
...
...
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