aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2005-06-21 00:15:16 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-06-26 15:25:05 -0400
commita29641883f57f36424e3219ae9ff48dd6cd34de0 (patch)
treede70437649f87064f378b513003d3e4691d178e4
parent5c3927dc3468f47b803c9e1bb82cbed2bbd411ab (diff)
[PATCH] devfs: Remove devfs from the partition code
This patch removes the devfs code from the fs/partitions/ directory. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--fs/partitions/Makefile1
-rw-r--r--fs/partitions/check.c26
-rw-r--r--fs/partitions/devfs.c130
-rw-r--r--fs/partitions/devfs.h10
4 files changed, 5 insertions, 162 deletions
diff --git a/fs/partitions/Makefile b/fs/partitions/Makefile
index 42c7d3878ed0..d713ce6b3e12 100644
--- a/fs/partitions/Makefile
+++ b/fs/partitions/Makefile
@@ -4,7 +4,6 @@
4 4
5obj-y := check.o 5obj-y := check.o
6 6
7obj-$(CONFIG_DEVFS_FS) += devfs.o
8obj-$(CONFIG_ACORN_PARTITION) += acorn.o 7obj-$(CONFIG_ACORN_PARTITION) += acorn.o
9obj-$(CONFIG_AMIGA_PARTITION) += amiga.o 8obj-$(CONFIG_AMIGA_PARTITION) += amiga.o
10obj-$(CONFIG_ATARI_PARTITION) += atari.o 9obj-$(CONFIG_ATARI_PARTITION) += atari.o
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 2ef313a96b66..2ab7701eb2fb 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -21,7 +21,6 @@
21#include <linux/devfs_fs_kernel.h> 21#include <linux/devfs_fs_kernel.h>
22 22
23#include "check.h" 23#include "check.h"
24#include "devfs.h"
25 24
26#include "acorn.h" 25#include "acorn.h"
27#include "amiga.h" 26#include "amiga.h"
@@ -161,18 +160,11 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
161 if (!state) 160 if (!state)
162 return NULL; 161 return NULL;
163 162
164#ifdef CONFIG_DEVFS_FS 163 disk_name(hd, 0, state->name);
165 if (hd->devfs_name[0] != '\0') { 164 printk(KERN_INFO " %s:", state->name);
166 printk(KERN_INFO " /dev/%s:", hd->devfs_name); 165 if (isdigit(state->name[strlen(state->name)-1]))
167 sprintf(state->name, "p"); 166 sprintf(state->name, "p");
168 } 167
169#endif
170 else {
171 disk_name(hd, 0, state->name);
172 printk(KERN_INFO " %s:", state->name);
173 if (isdigit(state->name[strlen(state->name)-1]))
174 sprintf(state->name, "p");
175 }
176 state->limit = hd->minors; 168 state->limit = hd->minors;
177 i = res = 0; 169 i = res = 0;
178 while (!res && check_part[i]) { 170 while (!res && check_part[i]) {
@@ -423,14 +415,8 @@ void register_disk(struct gendisk *disk)
423 disk_sysfs_add_subdirs(disk); 415 disk_sysfs_add_subdirs(disk);
424 416
425 /* No minors to use for partitions */ 417 /* No minors to use for partitions */
426 if (disk->minors == 1) { 418 if (disk->minors == 1)
427 if (disk->devfs_name[0] != '\0')
428 devfs_add_disk(disk);
429 goto exit; 419 goto exit;
430 }
431
432 /* always add handle for the whole disk */
433 devfs_add_partitioned(disk);
434 420
435 /* No such device (e.g., media were just removed) */ 421 /* No such device (e.g., media were just removed) */
436 if (!get_capacity(disk)) 422 if (!get_capacity(disk))
@@ -538,8 +524,6 @@ void del_gendisk(struct gendisk *disk)
538 disk_stat_set_all(disk, 0); 524 disk_stat_set_all(disk, 0);
539 disk->stamp = 0; 525 disk->stamp = 0;
540 526
541 devfs_remove_disk(disk);
542
543 kobject_uevent(&disk->kobj, KOBJ_REMOVE); 527 kobject_uevent(&disk->kobj, KOBJ_REMOVE);
544 if (disk->holder_dir) 528 if (disk->holder_dir)
545 kobject_unregister(disk->holder_dir); 529 kobject_unregister(disk->holder_dir);
diff --git a/fs/partitions/devfs.c b/fs/partitions/devfs.c
deleted file mode 100644
index 3f0a780c9cec..000000000000
--- a/fs/partitions/devfs.c
+++ /dev/null
@@ -1,130 +0,0 @@
1/*
2 * This tries to keep block devices away from devfs as much as possible.
3 */
4#include <linux/fs.h>
5#include <linux/devfs_fs_kernel.h>
6#include <linux/vmalloc.h>
7#include <linux/genhd.h>
8#include <linux/bitops.h>
9#include <linux/mutex.h>
10
11
12struct unique_numspace {
13 u32 num_free; /* Num free in bits */
14 u32 length; /* Array length in bytes */
15 unsigned long *bits;
16 struct semaphore mutex;
17};
18
19static DEFINE_MUTEX(numspace_mutex);
20
21static int expand_numspace(struct unique_numspace *s)
22{
23 u32 length;
24 void *bits;
25
26 if (s->length < 16)
27 length = 16;
28 else
29 length = s->length << 1;
30
31 bits = vmalloc(length);
32 if (!bits)
33 return -ENOMEM;
34 if (s->bits) {
35 memcpy(bits, s->bits, s->length);
36 vfree(s->bits);
37 }
38
39 s->num_free = (length - s->length) << 3;
40 s->bits = bits;
41 memset(bits + s->length, 0, length - s->length);
42 s->length = length;
43
44 return 0;
45}
46
47static int alloc_unique_number(struct unique_numspace *s)
48{
49 int rval = 0;
50
51 mutex_lock(&numspace_mutex);
52 if (s->num_free < 1)
53 rval = expand_numspace(s);
54 if (!rval) {
55 rval = find_first_zero_bit(s->bits, s->length << 3);
56 --s->num_free;
57 __set_bit(rval, s->bits);
58 }
59 mutex_unlock(&numspace_mutex);
60
61 return rval;
62}
63
64static void dealloc_unique_number(struct unique_numspace *s, int number)
65{
66 int old_val;
67
68 if (number >= 0) {
69 mutex_lock(&numspace_mutex);
70 old_val = __test_and_clear_bit(number, s->bits);
71 if (old_val)
72 ++s->num_free;
73 mutex_unlock(&numspace_mutex);
74 }
75}
76
77static struct unique_numspace disc_numspace;
78static struct unique_numspace cdrom_numspace;
79
80void devfs_add_partitioned(struct gendisk *disk)
81{
82 char dirname[64], symlink[16];
83
84 devfs_mk_dir(disk->devfs_name);
85 devfs_mk_bdev(MKDEV(disk->major, disk->first_minor),
86 S_IFBLK|S_IRUSR|S_IWUSR,
87 "%s/disc", disk->devfs_name);
88
89 disk->number = alloc_unique_number(&disc_numspace);
90
91 sprintf(symlink, "discs/disc%d", disk->number);
92 sprintf(dirname, "../%s", disk->devfs_name);
93 devfs_mk_symlink(symlink, dirname);
94
95}
96
97void devfs_add_disk(struct gendisk *disk)
98{
99 devfs_mk_bdev(MKDEV(disk->major, disk->first_minor),
100 (disk->flags & GENHD_FL_CD) ?
101 S_IFBLK|S_IRUGO|S_IWUGO :
102 S_IFBLK|S_IRUSR|S_IWUSR,
103 "%s", disk->devfs_name);
104
105 if (disk->flags & GENHD_FL_CD) {
106 char dirname[64], symlink[16];
107
108 disk->number = alloc_unique_number(&cdrom_numspace);
109
110 sprintf(symlink, "cdroms/cdrom%d", disk->number);
111 sprintf(dirname, "../%s", disk->devfs_name);
112 devfs_mk_symlink(symlink, dirname);
113 }
114}
115
116void devfs_remove_disk(struct gendisk *disk)
117{
118 if (disk->minors != 1) {
119 devfs_remove("discs/disc%d", disk->number);
120 dealloc_unique_number(&disc_numspace, disk->number);
121 devfs_remove("%s/disc", disk->devfs_name);
122 }
123 if (disk->flags & GENHD_FL_CD) {
124 devfs_remove("cdroms/cdrom%d", disk->number);
125 dealloc_unique_number(&cdrom_numspace, disk->number);
126 }
127 devfs_remove(disk->devfs_name);
128}
129
130
diff --git a/fs/partitions/devfs.h b/fs/partitions/devfs.h
deleted file mode 100644
index 176118b4e492..000000000000
--- a/fs/partitions/devfs.h
+++ /dev/null
@@ -1,10 +0,0 @@
1
2#ifdef CONFIG_DEVFS_FS
3void devfs_add_disk(struct gendisk *dev);
4void devfs_add_partitioned(struct gendisk *dev);
5void devfs_remove_disk(struct gendisk *dev);
6#else
7# define devfs_add_disk(disk) do { } while (0)
8# define devfs_add_partitioned(disk) do { } while (0)
9# define devfs_remove_disk(disk) do { } while (0)
10#endif