Messages in this thread Patch in this message | | | Date | Sun, 9 Aug 1998 02:00:08 +0200 (MET DST) | From | Andries.Brouwer@cwi ... | Subject | [PATCH] proc fixed, ... |
| |
The patch below does the following.
(i) It fixes the problem that "rm -r /proc" crashes the kernel. The problem was that free_proc_entry() would free entries that had never been dynamically allocated (such as PROC_SCSI_SCSI, which is hand-crafted in drivers/scsi/scsi.c). No doubt a better solution is never to hand-craft structures and always get them in the generic way. However, I just added a test in free_proc_entry().
This cancels one item from Alan's showstopper list.
(ii) It adds /proc/partitions. (Used by mount to allow mounting a filesystem specified by volumelabel or UUID.)
(iii) Adds (#ifdef'd out, the maintainer may add it for real) a hash function for tlan.c that is seven times as fast as the old one.
(iv) Adds a warning in 3c509.c when compiled with CONFIG_MCA, and gives an URL where to look for a patch.
(v) Other minor fixes.
Andries
-------------------------------------------------------------------- diff -r -u ../linux-2.1.115/linux/drivers/block/genhd.c linux/drivers/block/genhd.c --- ../linux-2.1.115/linux/drivers/block/genhd.c Fri Aug 7 12:07:52 1998 +++ linux/drivers/block/genhd.c Sun Aug 9 01:11:08 1998 @@ -1101,7 +1101,6 @@ extern int soc_probe(void); #endif struct gendisk *p; - int nr=0; #ifdef CONFIG_PARPORT parport_init(); @@ -1123,10 +1122,9 @@ console_map_init(); #endif - for (p = gendisk_head ; p ; p=p->next) { + for (p = gendisk_head ; p ; p=p->next) setup_dev(p); - nr += p->nr_real; - } + #ifdef CONFIG_BLK_DEV_RAM #ifdef CONFIG_BLK_DEV_INITRD if (initrd_start && mount_initrd) initrd_load(); @@ -1138,3 +1136,25 @@ md_setup_drive(); #endif } + +#ifdef CONFIG_PROC_FS +int get_partition_list(char * page) +{ + struct gendisk *p; + char buf[8]; + int n, len; + + len = sprintf(page, "major minor #blocks name\n\n"); + for (p = gendisk_head; p; p = p->next) { + for (n=0; n < (p->nr_real << p->minor_shift); n++) { + if (p->part[n].nr_sects && len < PAGE_SIZE - 80) { + len += sprintf(page+len, + "%4d %4d %10d %s\n", + p->major, n, p->sizes[n], + disk_name(p, n, buf)); + } + } + } + return len; +} +#endif diff -r -u ../linux-2.1.115/linux/drivers/char/apm_bios.c linux/drivers/char/apm_bios.c --- ../linux-2.1.115/linux/drivers/char/apm_bios.c Tue Aug 4 20:50:18 1998 +++ linux/drivers/char/apm_bios.c Sun Aug 9 01:11:08 1998 @@ -515,6 +515,8 @@ return APM_SUCCESS; } +#if 0 +/* not used anywhere */ static int apm_get_battery_status(u_short which, u_short *bat, u_short *life, u_short *nbat) { @@ -532,6 +534,7 @@ return (error >> 8); return APM_SUCCESS; } +#endif static inline int apm_engage_power_management(u_short device) { diff -r -u ../linux-2.1.115/linux/drivers/char/cyclades.c linux/drivers/char/cyclades.c --- ../linux-2.1.115/linux/drivers/char/cyclades.c Fri Aug 7 12:07:52 1998 +++ linux/drivers/char/cyclades.c Sun Aug 9 01:11:08 1998 @@ -4949,7 +4949,7 @@ info->idle_stats.recv_bytes, JIFFIES_DIFF(info->idle_stats.recv_idle, cur_jifs) / HZ, info->idle_stats.overruns, - info->tty->ldisc.num); + (long) info->tty->ldisc.num); else size = sprintf(buf+len, "%3d %8lu %10lu %8lu %10lu %8lu %9lu %6ld\n", diff -r -u ../linux-2.1.115/linux/drivers/net/3c509.c linux/drivers/net/3c509.c --- ../linux-2.1.115/linux/drivers/net/3c509.c Tue Aug 4 20:54:06 1998 +++ linux/drivers/net/3c509.c Sun Aug 9 01:11:08 1998 @@ -178,6 +178,9 @@ } #ifdef CONFIG_MCA +#warning "The MCA code in drivers/net/3c509.c does not compile" +#warning "See http://glycerine.itsmm.uni.edu/mca/ for patches." +#if 0 if (MCA_bus) { mca_adaptor_select_mode(1); for (i = 0; i < 8; i++) @@ -195,6 +198,7 @@ } #endif +#endif /* Reset the ISA PnP mechanism on 3c509b. */ outb(0x02, 0x279); /* Select PnP config control register. */ @@ -208,7 +212,7 @@ if (inb(id_port) & 0x01) break; } - if (id_port >= 0x200) { /* GCC optimizes this test out. */ + if (id_port >= 0x200) { /* Rare -- do we really need a warning? */ printk(" WARNING: No I/O port available for 3c509 activation.\n"); return -ENODEV; diff -r -u ../linux-2.1.115/linux/drivers/net/tlan.c linux/drivers/net/tlan.c --- ../linux-2.1.115/linux/drivers/net/tlan.c Tue Aug 4 20:52:09 1998 +++ linux/drivers/net/tlan.c Sun Aug 9 01:11:08 1998 @@ -48,15 +48,16 @@ static struct device *TLanDevices = NULL; static int TLanDevicesInstalled = 0; +static int aui = 0; +static int sa_int = 0; +static int duplex = 0; +static int speed = 0; + #endif static int debug = 0; -static int aui = 0; -static int sa_int = 0; static int bbuf = 0; -static int duplex = 0; -static int speed = 0; static u8 *TLanPadBuffer; static char TLanSignature[] = "TLAN"; static int TLanVersionMajor = 1; diff -r -u ../linux-2.1.115/linux/drivers/net/tlan.h linux/drivers/net/tlan.h --- ../linux-2.1.115/linux/drivers/net/tlan.h Tue Aug 4 20:51:55 1998 +++ linux/drivers/net/tlan.h Sun Aug 9 01:11:08 1998 @@ -496,6 +496,24 @@ #define TLan_GetBit( bit, port ) ((int) (inb_p(port) & bit)) #define TLan_SetBit( bit, port ) outb_p(inb_p(port) | bit, port) +#ifdef I_LIKE_A_FAST_HASH_FUNCTION +/* given 6 bytes, view them as 8 6-bit numbers and return the XOR of those */ +/* the code below is about seven times as fast as the original code */ +inline u32 TLan_HashFunc( u8 *a ) +{ + u8 hash; + + hash = (a[0]^a[3]); /* & 077 */ + hash ^= ((a[0]^a[3])>>6); /* & 003 */ + hash ^= ((a[1]^a[4])<<2); /* & 074 */ + hash ^= ((a[1]^a[4])>>4); /* & 017 */ + hash ^= ((a[2]^a[5])<<4); /* & 060 */ + hash ^= ((a[2]^a[5])>>2); /* & 077 */ + + return (hash & 077); +} + +#else /* original code */ inline u32 xor( u32 a, u32 b ) { @@ -519,7 +537,5 @@ } - - - +#endif /* I_LIKE_A_FAST_HASH_FUNCTION */ #endif diff -r -u ../linux-2.1.115/linux/fs/proc/array.c linux/fs/proc/array.c --- ../linux-2.1.115/linux/fs/proc/array.c Tue Aug 4 20:54:45 1998 +++ linux/fs/proc/array.c Sun Aug 9 01:14:35 1998 @@ -35,6 +35,8 @@ * - Incorporation and non-SMP safe operation * of forissier patch in 2.1.78 by * Hans Marcus <crowbar@concepts.nl> + * + * aeb@cwi.nl : /proc/partitions */ #include <linux/types.h> @@ -1191,6 +1193,7 @@ extern int get_ksyms_list(char *, char **, off_t, int); #endif extern int get_device_list(char *); +extern int get_partition_list(char *); extern int get_filesystem_list(char *); extern int get_filesystem_info( char * ); extern int get_irq_list(char *); @@ -1249,6 +1252,9 @@ case PROC_DEVICES: return get_device_list(page); + + case PROC_PARTITIONS: + return get_partition_list(page); case PROC_INTERRUPTS: return get_irq_list(page); diff -r -u ../linux-2.1.115/linux/fs/proc/generic.c linux/fs/proc/generic.c --- ../linux-2.1.115/linux/fs/proc/generic.c Tue Aug 4 20:52:11 1998 +++ linux/fs/proc/generic.c Sun Aug 9 01:11:09 1998 @@ -283,7 +283,11 @@ extern void free_proc_entry(struct proc_dir_entry *); void free_proc_entry(struct proc_dir_entry *de) { - kfree(de); + int ino = de->low_ino; + + if (ino >= PROC_DYNAMIC_FIRST && + ino < PROC_DYNAMIC_FIRST+PROC_NDYNAMIC) + kfree(de); } /* diff -r -u ../linux-2.1.115/linux/fs/proc/root.c linux/fs/proc/root.c --- ../linux-2.1.115/linux/fs/proc/root.c Tue Aug 4 20:54:45 1998 +++ linux/fs/proc/root.c Sun Aug 9 01:11:09 1998 @@ -560,6 +560,11 @@ S_IFREG | S_IRUGO, 1, 0, 0, 0, &proc_array_inode_operations }; +static struct proc_dir_entry proc_root_partitions = { + PROC_PARTITIONS, 10, "partitions", + S_IFREG | S_IRUGO, 1, 0, 0, + 0, &proc_array_inode_operations +}; static struct proc_dir_entry proc_root_interrupts = { PROC_INTERRUPTS, 10,"interrupts", S_IFREG | S_IRUGO, 1, 0, 0, @@ -667,6 +672,7 @@ #endif proc_register(&proc_root, &proc_root_stat); proc_register(&proc_root, &proc_root_devices); + proc_register(&proc_root, &proc_root_partitions); proc_register(&proc_root, &proc_root_interrupts); proc_register(&proc_root, &proc_root_filesystems); proc_register(&proc_root, &proc_root_fs); diff -r -u ../linux-2.1.115/linux/include/linux/genhd.h linux/include/linux/genhd.h --- ../linux-2.1.115/linux/include/linux/genhd.h Sat Feb 28 22:21:55 1998 +++ linux/include/linux/genhd.h Sun Aug 9 01:15:06 1998 @@ -26,6 +26,7 @@ #define DOS_EXTENDED_PARTITION 5 #define LINUX_EXTENDED_PARTITION 0x85 #define WIN98_EXTENDED_PARTITION 0x0f + #define LINUX_SWAP_PARTITION 0x82 #ifdef CONFIG_SOLARIS_X86_PARTITION diff -r -u ../linux-2.1.115/linux/include/linux/proc_fs.h linux/include/linux/proc_fs.h --- ../linux-2.1.115/linux/include/linux/proc_fs.h Tue Aug 4 20:54:45 1998 +++ linux/include/linux/proc_fs.h Sun Aug 9 01:15:06 1998 @@ -31,6 +31,7 @@ PROC_MODULES, PROC_STAT, PROC_DEVICES, + PROC_PARTITIONS, PROC_INTERRUPTS, PROC_FILESYSTEMS, PROC_KSYMS, - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html
| |