Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
Verlässliche Systemsoftware
projects
osv
Commits
d102880f
Commit
d102880f
authored
11 years ago
by
Avi Kivity
Browse files
Options
Downloads
Patches
Plain Diff
console: make it a derived class of file
Signed-off-by:
Avi Kivity
<
avi@cloudius-systems.com
>
parent
4eee5123
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
drivers/console.cc
+48
-18
48 additions, 18 deletions
drivers/console.cc
with
48 additions
and
18 deletions
drivers/console.cc
+
48
−
18
View file @
d102880f
...
...
@@ -285,6 +285,19 @@ void console_init(void)
device_create
(
&
console_driver
,
"console"
,
D_CHR
);
}
class
console_file
:
public
file
{
public:
console_file
()
:
file
(
FREAD
|
FWRITE
,
DTYPE_UNSPEC
)
{}
virtual
int
read
(
struct
uio
*
uio
,
int
flags
)
override
;
virtual
int
write
(
struct
uio
*
uio
,
int
flags
)
override
;
virtual
int
truncate
(
off_t
len
)
override
;
virtual
int
ioctl
(
u_long
com
,
void
*
data
)
override
;
virtual
int
poll
(
int
events
)
override
;
virtual
int
stat
(
struct
stat
*
buf
)
override
;
virtual
int
close
()
override
;
virtual
int
chmod
(
mode_t
mode
)
override
;
};
// The above allows opening /dev/console to use the console. We currently
// have a bug with the VFS/device layer - vfs_read() and vfs_write() hold a
// lock throughout the call, preventing a write() to the console while read()
...
...
@@ -292,13 +305,8 @@ void console_init(void)
// character special devices.
// To bypass this buggy layer, here's an console::open() function, a
// replacement for open("/dev/console", O_RDWR, 0).
static
int
fops_console_init_close
(
file
*
f
)
{
return
0
;
}
static
int
fops_console_stat
(
file
*
f
,
struct
stat
*
s
)
int
console_file
::
stat
(
struct
stat
*
s
)
{
// We are not expected to fill much in s. Java expects (see os::available
// in os_linux.cpp) S_ISCHR to be true.
...
...
@@ -308,22 +316,44 @@ fops_console_stat(file *f, struct stat *s)
return
0
;
}
int
console_file
::
read
(
struct
uio
*
uio
,
int
flags
)
{
return
op_read
<
file
>
(
this
,
uio
,
flags
);
}
int
console_file
::
write
(
struct
uio
*
uio
,
int
flags
)
{
return
op_write
<
file
>
(
this
,
uio
,
flags
);
}
static
fileops
console_ops
=
{
fops_console_init_close
,
op_read
<
file
>
,
op_write
<
file
>
,
unsupported_truncate
,
op_ioctl
<
file
>
,
unsupported_poll
,
// FIXME: implement this, and don't forget poll_wake()
fops_console_stat
,
fops_console_init_close
,
unsupported_chmod
,
};
int
console_file
::
truncate
(
off_t
len
)
{
return
unsupported_truncate
(
this
,
len
);
}
int
console_file
::
ioctl
(
u_long
com
,
void
*
data
)
{
return
op_ioctl
<
file
>
(
this
,
com
,
data
);
}
int
console_file
::
poll
(
int
events
)
{
return
unsupported_poll
(
this
,
events
);
}
int
console_file
::
close
()
{
return
0
;
}
int
console_file
::
chmod
(
mode_t
mode
)
{
return
unsupported_chmod
(
this
,
mode
);
}
int
open
()
{
try
{
fileref
f
=
make_file
(
FREAD
|
FWRITE
,
DTYPE_UNSPEC
,
NULL
,
&
console_
ops
);
fileref
f
=
make_file
<
console_
file
>
(
);
fdesc
fd
(
f
);
return
fd
.
release
();
}
catch
(
int
error
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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