Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
e873005d
Commit
e873005d
authored
Sep 21, 2002
by
Alexander Viro
Committed by
Linus Torvalds
Sep 21, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] gendisk for rd
rd switched to use of gendisk
parent
82cc65a9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
31 deletions
+39
-31
drivers/block/rd.c
drivers/block/rd.c
+39
-31
No files found.
drivers/block/rd.c
View file @
e873005d
...
@@ -77,7 +77,8 @@ int initrd_below_start_ok;
...
@@ -77,7 +77,8 @@ int initrd_below_start_ok;
*/
*/
static
unsigned
long
rd_length
[
NUM_RAMDISKS
];
/* Size of RAM disks in bytes */
static
unsigned
long
rd_length
[
NUM_RAMDISKS
];
/* Size of RAM disks in bytes */
static
int
rd_kbsize
[
NUM_RAMDISKS
];
/* Size in blocks of 1024 bytes */
static
struct
gendisk
rd_disks
[
NUM_RAMDISKS
];
static
char
rd_names
[
NUM_RAMDISKS
][
5
];
static
devfs_handle_t
devfs_handle
;
static
devfs_handle_t
devfs_handle
;
static
struct
block_device
*
rd_bdev
[
NUM_RAMDISKS
];
/* Protected device data */
static
struct
block_device
*
rd_bdev
[
NUM_RAMDISKS
];
/* Protected device data */
...
@@ -286,16 +287,11 @@ static int rd_make_request(request_queue_t * q, struct bio *sbh)
...
@@ -286,16 +287,11 @@ static int rd_make_request(request_queue_t * q, struct bio *sbh)
static
int
rd_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
)
static
int
rd_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
{
int
error
=
-
EINVAL
;
int
error
;
unsigned
int
minor
;
if
(
!
inode
||
kdev_none
(
inode
->
i_rdev
))
goto
out
;
minor
=
minor
(
inode
->
i_rdev
);
if
(
cmd
!=
BLKFLSBUF
)
return
-
EINVAL
;
switch
(
cmd
)
{
case
BLKFLSBUF
:
if
(
!
capable
(
CAP_SYS_ADMIN
))
if
(
!
capable
(
CAP_SYS_ADMIN
))
return
-
EACCES
;
return
-
EACCES
;
/* special: we want to release the ramdisk memory,
/* special: we want to release the ramdisk memory,
...
@@ -308,15 +304,21 @@ static int rd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
...
@@ -308,15 +304,21 @@ static int rd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
error
=
0
;
error
=
0
;
}
}
up
(
&
inode
->
i_bdev
->
bd_sem
);
up
(
&
inode
->
i_bdev
->
bd_sem
);
break
;
}
out:
return
error
;
return
error
;
}
}
#ifdef CONFIG_BLK_DEV_INITRD
#ifdef CONFIG_BLK_DEV_INITRD
static
struct
block_device_operations
rd_bd_op
;
static
struct
gendisk
initrd_disk
=
{
.
major
=
MAJOR_NR
,
.
first_minor
=
INITRD_MINOR
,
.
minor_shift
=
0
,
.
fops
=
&
rd_bd_op
,
.
major_name
=
"initrd"
};
static
ssize_t
initrd_read
(
struct
file
*
file
,
char
*
buf
,
static
ssize_t
initrd_read
(
struct
file
*
file
,
char
*
buf
,
size_t
count
,
loff_t
*
ppos
)
size_t
count
,
loff_t
*
ppos
)
{
{
...
@@ -339,6 +341,7 @@ static int initrd_release(struct inode *inode,struct file *file)
...
@@ -339,6 +341,7 @@ static int initrd_release(struct inode *inode,struct file *file)
spin_lock
(
&
initrd_users_lock
);
spin_lock
(
&
initrd_users_lock
);
if
(
!--
initrd_users
)
{
if
(
!--
initrd_users
)
{
spin_unlock
(
&
initrd_users_lock
);
spin_unlock
(
&
initrd_users_lock
);
del_gendisk
(
&
initrd_disk
);
free_initrd_mem
(
initrd_start
,
initrd_end
);
free_initrd_mem
(
initrd_start
,
initrd_end
);
initrd_start
=
0
;
initrd_start
=
0
;
}
else
{
}
else
{
...
@@ -410,6 +413,7 @@ static void __exit rd_cleanup (void)
...
@@ -410,6 +413,7 @@ static void __exit rd_cleanup (void)
invalidate_bdev
(
bdev
,
1
);
invalidate_bdev
(
bdev
,
1
);
blkdev_put
(
bdev
,
BDEV_FILE
);
blkdev_put
(
bdev
,
BDEV_FILE
);
}
}
del_gendisk
(
rd_disks
+
i
);
}
}
devfs_unregister
(
devfs_handle
);
devfs_unregister
(
devfs_handle
);
...
@@ -437,9 +441,16 @@ static int __init rd_init (void)
...
@@ -437,9 +441,16 @@ static int __init rd_init (void)
blk_queue_make_request
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
),
&
rd_make_request
);
blk_queue_make_request
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
),
&
rd_make_request
);
for
(
i
=
0
;
i
<
NUM_RAMDISKS
;
i
++
)
{
for
(
i
=
0
;
i
<
NUM_RAMDISKS
;
i
++
)
{
struct
gendisk
*
disk
=
rd_disks
+
i
;
/* rd_size is given in kB */
/* rd_size is given in kB */
rd_length
[
i
]
=
rd_size
<<
10
;
rd_length
[
i
]
=
rd_size
<<
10
;
rd_kbsize
[
i
]
=
rd_size
;
disk
->
major
=
MAJOR_NR
;
disk
->
first_minor
=
0
;
disk
->
minor_shift
=
0
;
disk
->
fops
=
&
rd_bd_op
;
sprintf
(
rd_names
[
i
],
"rd%d"
,
i
);
disk
->
major_name
=
rd_names
[
i
];
set_capacity
(
disk
,
rd_size
*
2
);
}
}
devfs_handle
=
devfs_mk_dir
(
NULL
,
"rd"
,
NULL
);
devfs_handle
=
devfs_mk_dir
(
NULL
,
"rd"
,
NULL
);
devfs_register_series
(
devfs_handle
,
"%u"
,
NUM_RAMDISKS
,
devfs_register_series
(
devfs_handle
,
"%u"
,
NUM_RAMDISKS
,
...
@@ -448,18 +459,15 @@ static int __init rd_init (void)
...
@@ -448,18 +459,15 @@ static int __init rd_init (void)
&
rd_bd_op
,
NULL
);
&
rd_bd_op
,
NULL
);
for
(
i
=
0
;
i
<
NUM_RAMDISKS
;
i
++
)
for
(
i
=
0
;
i
<
NUM_RAMDISKS
;
i
++
)
register_disk
(
NULL
,
mk_kdev
(
MAJOR_NR
,
i
),
1
,
&
rd_bd_op
,
add_disk
(
rd_disks
+
i
);
rd_size
<<
1
);
#ifdef CONFIG_BLK_DEV_INITRD
#ifdef CONFIG_BLK_DEV_INITRD
/* We ought to separate initrd operations here */
/* We ought to separate initrd operations here */
register_disk
(
NULL
,
mk_kdev
(
MAJOR_NR
,
INITRD_MINOR
),
1
,
&
rd_bd_op
,
rd_size
<<
1
);
add_disk
(
&
initrd_disk
);
devfs_register
(
devfs_handle
,
"initrd"
,
DEVFS_FL_DEFAULT
,
MAJOR_NR
,
devfs_register
(
devfs_handle
,
"initrd"
,
DEVFS_FL_DEFAULT
,
MAJOR_NR
,
INITRD_MINOR
,
S_IFBLK
|
S_IRUSR
,
&
rd_bd_op
,
NULL
);
INITRD_MINOR
,
S_IFBLK
|
S_IRUSR
,
&
rd_bd_op
,
NULL
);
#endif
#endif
blk_size
[
MAJOR_NR
]
=
rd_kbsize
;
/* Size of the RAM disk in kB */
/* rd_size is given in kB */
/* rd_size is given in kB */
printk
(
"RAMDISK driver initialized: "
printk
(
"RAMDISK driver initialized: "
"%d RAM disks of %dK size %d blocksize
\n
"
,
"%d RAM disks of %dK size %d blocksize
\n
"
,
...
...
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