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
fa82a1da
Commit
fa82a1da
authored
May 17, 2002
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Plain Diff
Merge
bk://bkbits.ras.ucalgary.ca/rgooch-2.5
into home.transmeta.com:/home/torvalds/v2.5/linux
parents
7dbe32be
a68d9759
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
108 additions
and
59 deletions
+108
-59
Documentation/filesystems/devfs/ChangeLog
Documentation/filesystems/devfs/ChangeLog
+19
-0
drivers/char/misc.c
drivers/char/misc.c
+6
-5
fs/devfs/base.c
fs/devfs/base.c
+74
-45
fs/devfs/util.c
fs/devfs/util.c
+9
-9
No files found.
Documentation/filesystems/devfs/ChangeLog
View file @
fa82a1da
...
...
@@ -1912,3 +1912,22 @@ Changes for patch v210
Thanks to Anton Blanchard <anton@samba.org>
- Updated README from master HTML file
===============================================================================
Changes for patch v211
- Do not put miscellaneous character devices in /dev/misc if they
specify their own directory (i.e. contain a '/' character)
- Copied macro for error messages from fs/devfs/base.c to
fs/devfs/util.c and made use of this macro
- Removed 2.4.x compatibility code from fs/devfs/base.c
===============================================================================
Changes for patch v212
- Added BKL to <devfs_open> because drivers still need it
===============================================================================
Changes for patch v213
- Protected <scan_dir_for_removable> and <get_removable_partition>
from changing directory contents
drivers/char/misc.c
View file @
fa82a1da
...
...
@@ -170,7 +170,7 @@ static struct file_operations misc_fops = {
int
misc_register
(
struct
miscdevice
*
misc
)
{
static
devfs_handle_t
devfs_handle
;
static
devfs_handle_t
devfs_handle
,
dir
;
struct
miscdevice
*
c
;
if
(
misc
->
next
||
misc
->
prev
)
...
...
@@ -201,11 +201,12 @@ int misc_register(struct miscdevice * misc)
misc_minors
[
misc
->
minor
>>
3
]
|=
1
<<
(
misc
->
minor
&
7
);
if
(
!
devfs_handle
)
devfs_handle
=
devfs_mk_dir
(
NULL
,
"misc"
,
NULL
);
dir
=
strchr
(
misc
->
name
,
'/'
)
?
NULL
:
devfs_handle
;
misc
->
devfs_handle
=
devfs_register
(
devfs_handle
,
misc
->
name
,
DEVFS_FL_NONE
,
MISC_MAJOR
,
misc
->
minor
,
S_IFCHR
|
S_IRUSR
|
S_IWUSR
|
S_IRGRP
,
misc
->
fops
,
NULL
);
devfs_register
(
dir
,
misc
->
name
,
DEVFS_FL_NONE
,
MISC_MAJOR
,
misc
->
minor
,
S_IFCHR
|
S_IRUSR
|
S_IWUSR
|
S_IRGRP
,
misc
->
fops
,
NULL
);
/*
* Add it to the front, so that later devices can "override"
...
...
fs/devfs/base.c
View file @
fa82a1da
...
...
@@ -620,6 +620,19 @@
unlock_kernel() due to recent VFS locking changes. BKL isn't
required in devfs.
v1.13
20020428 Richard Gooch <rgooch@atnf.csiro.au>
Removed 2.4.x compatibility code.
v1.14
20020510 Richard Gooch <rgooch@atnf.csiro.au>
Added BKL to <devfs_open> because drivers still need it.
v1.15
20020512 Richard Gooch <rgooch@atnf.csiro.au>
Protected <scan_dir_for_removable> and <get_removable_partition>
from changing directory contents.
v1.16
20020514 Richard Gooch <rgooch@atnf.csiro.au>
Minor cleanup of <scan_dir_for_removable>.
v1.17
*/
#include <linux/types.h>
#include <linux/errno.h>
...
...
@@ -652,7 +665,7 @@
#include <asm/bitops.h>
#include <asm/atomic.h>
#define DEVFS_VERSION "1.1
3 (20020406
)"
#define DEVFS_VERSION "1.1
7 (20020514
)"
#define DEVFS_NAME "devfs"
...
...
@@ -1400,16 +1413,8 @@ static void free_dentry (struct devfs_entry *de)
static
int
is_devfsd_or_child
(
struct
fs_info
*
fs_info
)
{
struct
task_struct
*
p
;
if
(
current
==
fs_info
->
devfsd_task
)
return
(
TRUE
);
if
(
current
->
pgrp
==
fs_info
->
devfsd_pgrp
)
return
(
TRUE
);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,1)
for
(
p
=
current
->
p_opptr
;
p
!=
&
init_task
;
p
=
p
->
p_opptr
)
{
if
(
p
==
fs_info
->
devfsd_task
)
return
(
TRUE
);
}
#endif
return
(
FALSE
);
}
/* End Function is_devfsd_or_child */
...
...
@@ -1829,16 +1834,6 @@ devfs_handle_t devfs_mk_dir (devfs_handle_t dir, const char *name, void *info)
de
->
info
=
info
;
if
(
(
err
=
_devfs_append_entry
(
dir
,
de
,
FALSE
,
&
old
)
)
!=
0
)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,1)
if
(
old
&&
S_ISDIR
(
old
->
mode
)
)
{
PRINTK
(
"(%s): using old entry in dir: %p
\"
%s
\"\n
"
,
name
,
dir
,
dir
->
name
);
old
->
vfs_deletable
=
FALSE
;
devfs_put
(
dir
);
return
old
;
}
#endif
PRINTK
(
"(%s): could not append to dir: %p
\"
%s
\"
, err: %d
\n
"
,
name
,
dir
,
dir
->
name
,
err
);
devfs_put
(
old
);
...
...
@@ -2427,6 +2422,9 @@ static int try_modload (struct devfs_entry *parent, struct fs_info *fs_info,
* @de: The device.
*
* Returns 1 if the media was changed, else 0.
*
* This function may block, and may indirectly cause the parent directory
* contents to be changed due to partition re-reading.
*/
static
int
check_disc_changed
(
struct
devfs_entry
*
de
)
...
...
@@ -2461,19 +2459,29 @@ static int check_disc_changed (struct devfs_entry *de)
/**
* scan_dir_for_removable - Scan a directory for removable media devices and check media.
* @dir: The directory.
*
* This function may block, and may indirectly cause the directory
* contents to be changed due to partition re-reading. The directory will
* be locked for reading.
*/
static
void
scan_dir_for_removable
(
struct
devfs_entry
*
dir
)
{
struct
devfs_entry
*
de
;
if
(
dir
->
u
.
dir
.
num_removable
<
1
)
return
;
for
(
de
=
dir
->
u
.
dir
.
first
;
de
!=
NULL
;
de
=
de
->
next
)
read_lock
(
&
dir
->
u
.
dir
.
lock
);
if
(
dir
->
u
.
dir
.
num_removable
<
1
)
de
=
NULL
;
else
{
if
(
!
S_ISBLK
(
de
->
mode
)
)
continue
;
if
(
!
de
->
u
.
fcb
.
removable
)
continue
;
check_disc_changed
(
de
);
for
(
de
=
dir
->
u
.
dir
.
first
;
de
!=
NULL
;
de
=
de
->
next
)
{
if
(
S_ISBLK
(
de
->
mode
)
&&
de
->
u
.
fcb
.
removable
)
break
;
}
devfs_get
(
de
);
}
read_unlock
(
&
dir
->
u
.
dir
.
lock
);
if
(
de
)
check_disc_changed
(
de
);
devfs_put
(
de
);
}
/* End Function scan_dir_for_removable */
/**
...
...
@@ -2483,25 +2491,37 @@ static void scan_dir_for_removable (struct devfs_entry *dir)
* @namelen: The number of characters in <<name>>.
*
* Returns 1 if the media was changed, else 0.
*
* This function may block, and may indirectly cause the directory
* contents to be changed due to partition re-reading. The directory must
* be locked for reading upon entry, and will be unlocked upon exit.
*/
static
int
get_removable_partition
(
struct
devfs_entry
*
dir
,
const
char
*
name
,
unsigned
int
namelen
)
{
int
retval
;
struct
devfs_entry
*
de
;
if
(
dir
->
u
.
dir
.
num_removable
<
1
)
{
read_unlock
(
&
dir
->
u
.
dir
.
lock
);
return
0
;
}
for
(
de
=
dir
->
u
.
dir
.
first
;
de
!=
NULL
;
de
=
de
->
next
)
{
if
(
!
S_ISBLK
(
de
->
mode
)
)
continue
;
if
(
!
de
->
u
.
fcb
.
removable
)
continue
;
if
(
strcmp
(
de
->
name
,
"disc"
)
==
0
)
return
check_disc_changed
(
de
);
if
(
!
S_ISBLK
(
de
->
mode
)
||
!
de
->
u
.
fcb
.
removable
)
continue
;
if
(
strcmp
(
de
->
name
,
"disc"
)
==
0
)
break
;
/* Support for names where the partition is appended to the disc name
*/
if
(
de
->
namelen
>=
namelen
)
continue
;
if
(
strncmp
(
de
->
name
,
name
,
de
->
namelen
)
!=
0
)
continue
;
return
check_disc_changed
(
de
);
if
(
strncmp
(
de
->
name
,
name
,
de
->
namelen
)
==
0
)
break
;
}
return
0
;
devfs_get
(
de
);
read_unlock
(
&
dir
->
u
.
dir
.
lock
);
retval
=
de
?
check_disc_changed
(
de
)
:
0
;
devfs_put
(
de
);
return
retval
;
}
/* End Function get_removable_partition */
...
...
@@ -2739,15 +2759,22 @@ static int devfs_open (struct inode *inode, struct file *file)
{
file
->
f_op
=
&
def_blk_fops
;
if
(
df
->
ops
)
inode
->
i_bdev
->
bd_op
=
df
->
ops
;
err
=
def_blk_fops
.
open
(
inode
,
file
);
}
else
file
->
f_op
=
fops_get
(
(
struct
file_operations
*
)
df
->
ops
);
if
(
file
->
f_op
)
err
=
file
->
f_op
->
open
?
(
*
file
->
f_op
->
open
)
(
inode
,
file
)
:
0
;
else
{
/* Fallback to legacy scheme */
if
(
S_ISCHR
(
inode
->
i_mode
)
)
err
=
chrdev_open
(
inode
,
file
);
else
err
=
-
ENODEV
;
file
->
f_op
=
fops_get
(
(
struct
file_operations
*
)
df
->
ops
);
if
(
file
->
f_op
)
{
lock_kernel
();
err
=
file
->
f_op
->
open
?
(
*
file
->
f_op
->
open
)
(
inode
,
file
)
:
0
;
unlock_kernel
();
}
else
{
/* Fallback to legacy scheme */
if
(
S_ISCHR
(
inode
->
i_mode
)
)
err
=
chrdev_open
(
inode
,
file
);
else
err
=
-
ENODEV
;
}
}
if
(
err
<
0
)
return
err
;
/* Open was successful */
...
...
@@ -2947,15 +2974,17 @@ static struct dentry *devfs_lookup (struct inode *dir, struct dentry *dentry)
if
(
parent
==
NULL
)
return
ERR_PTR
(
-
ENOENT
);
read_lock
(
&
parent
->
u
.
dir
.
lock
);
de
=
_devfs_search_dir
(
parent
,
dentry
->
d_name
.
name
,
dentry
->
d_name
.
len
);
read_unlock
(
&
parent
->
u
.
dir
.
lock
);
if
(
(
de
==
NULL
)
&&
(
parent
->
u
.
dir
.
num_removable
>
0
)
&&
get_removable_partition
(
parent
,
dentry
->
d_name
.
name
,
dentry
->
d_name
.
len
)
)
{
read_lock
(
&
parent
->
u
.
dir
.
lock
);
de
=
_devfs_search_dir
(
parent
,
dentry
->
d_name
.
name
,
dentry
->
d_name
.
len
);
read_unlock
(
&
parent
->
u
.
dir
.
lock
);
if
(
de
)
read_unlock
(
&
parent
->
u
.
dir
.
lock
);
else
{
/* Try re-reading the partition (media may have changed) */
if
(
get_removable_partition
(
parent
,
dentry
->
d_name
.
name
,
dentry
->
d_name
.
len
)
)
/* Unlocks */
{
/* Media did change */
read_lock
(
&
parent
->
u
.
dir
.
lock
);
de
=
_devfs_search_dir
(
parent
,
dentry
->
d_name
.
name
,
dentry
->
d_name
.
len
);
read_unlock
(
&
parent
->
u
.
dir
.
lock
);
}
}
lookup_info
.
de
=
de
;
init_waitqueue_head
(
&
lookup_info
.
wait_queue
);
...
...
fs/devfs/util.c
View file @
fa82a1da
...
...
@@ -56,6 +56,8 @@
Made major bitfield type and initialiser 64 bit safe.
20020413 Richard Gooch <rgooch@atnf.csiro.au>
Fixed shift warning on 64 bit machines.
20020428 Richard Gooch <rgooch@atnf.csiro.au>
Copied and used macro for error messages from fs/devfs/base.c
*/
#include <linux/module.h>
#include <linux/init.h>
...
...
@@ -65,6 +67,9 @@
#include <asm/bitops.h>
#define PRINTK(format, args...) \
{printk (KERN_ERR "%s" format, __FUNCTION__ , ## args);}
/* Private functions follow */
...
...
@@ -209,9 +214,7 @@ void devfs_dealloc_major (char type, int major)
spin_lock
(
&
list
->
lock
);
was_set
=
__test_and_clear_bit
(
major
,
list
->
bits
);
spin_unlock
(
&
list
->
lock
);
if
(
!
was_set
)
printk
(
KERN_ERR
__FUNCTION__
"(): major %d was already free
\n
"
,
major
);
if
(
!
was_set
)
PRINTK
(
"(): major %d was already free
\n
"
,
major
);
}
/* End Function devfs_dealloc_major */
EXPORT_SYMBOL
(
devfs_dealloc_major
);
...
...
@@ -339,12 +342,11 @@ void devfs_dealloc_devnum (char type, kdev_t devnum)
if
(
was_set
)
list
->
none_free
=
0
;
up
(
semaphore
);
if
(
!
was_set
)
printk
(
KERN_ERR
__FUNCTION__
"(): device %s was already free
\n
"
,
kdevname
(
devnum
)
);
PRINTK
(
"(): device %s was already free
\n
"
,
kdevname
(
devnum
)
);
return
;
}
up
(
semaphore
);
printk
(
KERN_ERR
__FUNCTION__
"(): major for %s not previously allocated
\n
"
,
PRINTK
(
"(): major for %s not previously allocated
\n
"
,
kdevname
(
devnum
)
);
}
/* End Function devfs_dealloc_devnum */
EXPORT_SYMBOL
(
devfs_dealloc_devnum
);
...
...
@@ -419,8 +421,6 @@ void devfs_dealloc_unique_number (struct unique_numspace *space, int number)
was_set
=
__test_and_clear_bit
(
number
,
space
->
bits
);
if
(
was_set
)
++
space
->
num_free
;
up
(
&
space
->
semaphore
);
if
(
!
was_set
)
printk
(
KERN_ERR
__FUNCTION__
"(): number %d was already free
\n
"
,
number
);
if
(
!
was_set
)
PRINTK
(
"(): number %d was already free
\n
"
,
number
);
}
/* End Function devfs_dealloc_unique_number */
EXPORT_SYMBOL
(
devfs_dealloc_unique_number
);
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