Commit 67a05ecd authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://kernel.bkbits.net/davem/net-2.5

into home.osdl.org:/home/torvalds/v2.5/linux
parents 6ebf476f 198b38b3
......@@ -337,6 +337,16 @@ static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable, \
}
}
}
static inline void mps_oem_check(struct mp_config_table *mpc, char *oem,
char *productid)
{
if (strncmp(oem, "IBM NUMA", 8))
printk("Warning! May not be a NUMA-Q system!\n");
if (mpc->mpc_oemptr)
smp_read_mpc_oem((struct mp_config_oemtable *) mpc->mpc_oemptr,
mpc->mpc_oemsize);
}
#endif /* CONFIG_X86_NUMAQ */
/*
......
......@@ -28,7 +28,6 @@ obj-$(CONFIG_ATARI_ACSI) += acsi.o
obj-$(CONFIG_ATARI_SLM) += acsi_slm.o
obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o
obj-$(CONFIG_BLK_DEV_RAM) += rd.o
obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
obj-$(CONFIG_BLK_DEV_LOOP) += loop.o
obj-$(CONFIG_BLK_DEV_PS2) += ps2esdi.o
obj-$(CONFIG_BLK_DEV_XD) += xd.o
......
#include <linux/blkdev.h>
#include <linux/genhd.h>
#include <linux/initrd.h>
#include <linux/init.h>
#include <linux/major.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <asm/uaccess.h>
unsigned long initrd_start, initrd_end;
int initrd_below_start_ok;
static int initrd_users;
static spinlock_t initrd_users_lock = SPIN_LOCK_UNLOCKED;
static struct gendisk *initrd_disk;
static ssize_t initrd_read(struct file *file, char *buf,
size_t count, loff_t *ppos)
{
int left = initrd_end - initrd_start - *ppos;
if (count > left)
count = left;
if (count == 0)
return 0;
if (copy_to_user(buf, (char *)initrd_start + *ppos, count))
return -EFAULT;
*ppos += count;
return count;
}
static int initrd_release(struct inode *inode,struct file *file)
{
blkdev_put(inode->i_bdev, BDEV_FILE);
spin_lock(&initrd_users_lock);
if (!--initrd_users) {
spin_unlock(&initrd_users_lock);
del_gendisk(initrd_disk);
free_initrd_mem(initrd_start, initrd_end);
initrd_start = 0;
} else
spin_unlock(&initrd_users_lock);
return 0;
}
static struct file_operations initrd_fops = {
.read = initrd_read,
.release = initrd_release,
};
static int initrd_open(struct inode *inode, struct file *filp)
{
if (!initrd_start)
return -ENODEV;
spin_lock(&initrd_users_lock);
initrd_users++;
spin_unlock(&initrd_users_lock);
filp->f_op = &initrd_fops;
return 0;
}
static struct block_device_operations initrd_bdops = {
.owner = THIS_MODULE,
.open = initrd_open,
};
static int __init initrd_init(void)
{
initrd_disk = alloc_disk(1);
if (!initrd_disk)
return -ENOMEM;
initrd_disk->major = RAMDISK_MAJOR;
initrd_disk->first_minor = INITRD_MINOR;
initrd_disk->fops = &initrd_bdops;
sprintf(initrd_disk->disk_name, "initrd");
sprintf(initrd_disk->devfs_name, "rd/initrd");
set_capacity(initrd_disk, (initrd_end-initrd_start+511) >> 9);
add_disk(initrd_disk);
return 0;
}
static void __exit initrd_exit(void)
{
put_disk(initrd_disk);
}
module_init(initrd_init);
module_exit(initrd_exit);
......@@ -842,8 +842,9 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp,
CDROM_AUDIO_NO_STATUS;
}
copy_from_user(&sjcd_msf, (void *) arg,
sizeof(sjcd_msf));
if (copy_from_user(&sjcd_msf, (void *) arg,
sizeof(sjcd_msf)))
return (-EFAULT);
sjcd_playing.start.min =
bin2bcd(sjcd_msf.cdmsf_min0);
......@@ -893,9 +894,9 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp,
sizeof(toc_entry))) == 0) {
struct sjcd_hw_disk_info *tp;
copy_from_user(&toc_entry, (void *) arg,
sizeof(toc_entry));
if (copy_from_user(&toc_entry, (void *) arg,
sizeof(toc_entry)))
return (-EFAULT);
if (toc_entry.cdte_track == CDROM_LEADOUT)
tp = &sjcd_table_of_contents[0];
else if (toc_entry.cdte_track <
......@@ -948,8 +949,10 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp,
sizeof(subchnl))) == 0) {
struct sjcd_hw_qinfo q_info;
copy_from_user(&subchnl, (void *) arg,
sizeof(subchnl));
if (copy_from_user(&subchnl, (void *) arg,
sizeof(subchnl)))
return (-EFAULT);
if (sjcd_get_q_info(&q_info) < 0)
return (-EIO);
......@@ -1005,8 +1008,9 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp,
sizeof(vol_ctrl))) == 0) {
unsigned char dummy[4];
copy_from_user(&vol_ctrl, (void *) arg,
sizeof(vol_ctrl));
if (copy_from_user(&vol_ctrl, (void *) arg,
sizeof(vol_ctrl)))
return (-EFAULT);
sjcd_send_4_cmd(SCMD_SET_VOLUME,
vol_ctrl.channel0, 0xFF,
vol_ctrl.channel1, 0xFF);
......
......@@ -214,6 +214,7 @@ int __init applicom_init(void)
if (!RamIO) {
printk(KERN_INFO "ac.o: Failed to ioremap PCI memory space at 0x%lx\n", dev->resource[0].start);
pci_disable_device(dev);
return -EIO;
}
......@@ -225,12 +226,14 @@ int __init applicom_init(void)
(unsigned long)RamIO,0))) {
printk(KERN_INFO "ac.o: PCI Applicom device doesn't have correct signature.\n");
iounmap(RamIO);
pci_disable_device(dev);
continue;
}
if (request_irq(dev->irq, &ac_interrupt, SA_SHIRQ, "Applicom PCI", &dummy)) {
printk(KERN_INFO "Could not allocate IRQ %d for PCI Applicom device.\n", dev->irq);
iounmap(RamIO);
pci_disable_device(dev);
apbs[boardno - 1].RamIO = 0;
continue;
}
......@@ -257,12 +260,6 @@ int __init applicom_init(void)
/* Now try the specified ISA cards */
#warning "LEAK"
RamIO = ioremap(mem, LEN_RAM_IO * MAX_ISA_BOARD);
if (!RamIO)
printk(KERN_INFO "ac.o: Failed to ioremap ISA memory space at 0x%lx\n", mem);
for (i = 0; i < MAX_ISA_BOARD; i++) {
RamIO = ioremap(mem + (LEN_RAM_IO * i), LEN_RAM_IO);
......@@ -285,7 +282,8 @@ int __init applicom_init(void)
iounmap((void *) RamIO);
apbs[boardno - 1].RamIO = 0;
}
apbs[boardno - 1].irq = irq;
else
apbs[boardno - 1].irq = irq;
}
else
apbs[boardno - 1].irq = 0;
......
......@@ -1796,7 +1796,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy)
* we'll leave the limitation below for the 2.2.x tree.
*/
if (strcmp(drive->id->model, "IOMEGA ZIP 100 ATAPI") == 0) {
if (strstr(drive->id->model, "IOMEGA ZIP") != NULL) {
set_bit(IDEFLOPPY_ZIP_DRIVE, &floppy->flags);
/* This value will be visible in the /proc/ide/hdx/settings */
floppy->ticks = IDEFLOPPY_TICKS_DELAY;
......
/* $Id: divasmain.c,v 1.43 2003/09/22 08:57:31 schindler Exp $
/* $Id: divasmain.c,v 1.46 2003/10/10 12:28:14 armin Exp $
*
* Low level driver for Eicon DIVA Server ISDN cards.
*
......@@ -41,7 +41,7 @@
#include "diva_dma.h"
#include "diva_pci.h"
static char *main_revision = "$Revision: 1.43 $";
static char *main_revision = "$Revision: 1.46 $";
static int major;
......@@ -69,7 +69,7 @@ extern int divasfunc_init(int dbgmask);
extern void divasfunc_exit(void);
typedef struct _diva_os_thread_dpc {
struct tasklet_struct divas_task;
struct work_struct divas_task;
struct work_struct trap_script_task;
diva_os_soft_isr_t *psoft_isr;
int card_failed;
......@@ -552,7 +552,7 @@ void diva_os_remove_irq(void *context, byte irq)
/* --------------------------------------------------------------------------
DPC framework implementation
-------------------------------------------------------------------------- */
static void diva_os_dpc_proc(unsigned long context)
static void diva_os_dpc_proc(void *context)
{
diva_os_thread_dpc_t *psoft_isr = (diva_os_thread_dpc_t *) context;
diva_os_soft_isr_t *pisr = psoft_isr->psoft_isr;
......@@ -575,8 +575,7 @@ int diva_os_initialize_soft_isr(diva_os_soft_isr_t * psoft_isr,
psoft_isr->callback_context = callback_context;
pdpc->psoft_isr = psoft_isr;
INIT_WORK(&pdpc->trap_script_task, diva_adapter_trapped, pdpc);
tasklet_init(&pdpc->divas_task, diva_os_dpc_proc,
(unsigned long) pdpc);
INIT_WORK(&pdpc->divas_task, diva_os_dpc_proc, pdpc);
return (0);
}
......@@ -587,7 +586,7 @@ int diva_os_schedule_soft_isr(diva_os_soft_isr_t * psoft_isr)
diva_os_thread_dpc_t *pdpc =
(diva_os_thread_dpc_t *) psoft_isr->object;
tasklet_schedule(&pdpc->divas_task);
schedule_work(&pdpc->divas_task);
}
return (1);
......@@ -595,26 +594,18 @@ int diva_os_schedule_soft_isr(diva_os_soft_isr_t * psoft_isr)
int diva_os_cancel_soft_isr(diva_os_soft_isr_t * psoft_isr)
{
if (psoft_isr && psoft_isr->object) {
diva_os_thread_dpc_t *pdpc =
(diva_os_thread_dpc_t *) psoft_isr->object;
tasklet_kill(&pdpc->divas_task);
}
flush_scheduled_work();
return (0);
}
void diva_os_remove_soft_isr(diva_os_soft_isr_t * psoft_isr)
{
if (psoft_isr && psoft_isr->object) {
diva_os_thread_dpc_t *pdpc =
(diva_os_thread_dpc_t *) psoft_isr->object;
void *mem;
tasklet_kill(&pdpc->divas_task);
flush_scheduled_work();
mem = psoft_isr->object;
psoft_isr->object = 0;
flush_scheduled_work();
diva_os_free(0, mem);
}
}
......
......@@ -95,7 +95,7 @@ struct list_head saa7134_devlist;
unsigned int saa7134_devcount;
#define dprintk(fmt, arg...) if (core_debug) \
printk(KERN_DEBUG "%s/core: " fmt, dev->name, ## arg)
printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg)
/* ------------------------------------------------------------------ */
/* debug help functions */
......
......@@ -204,7 +204,7 @@ config REISERFS_FS
In general, ReiserFS is as fast as ext2, but is very efficient with
large directories and small files. Additional patches are needed
for NFS and quotas, please see <http://www.reiserfs.org/> for links.
for NFS and quotas, please see <http://www.namesys.com/> for links.
It is more easily extended to have features currently found in
database and keyword search systems than block allocation based file
......@@ -212,7 +212,7 @@ config REISERFS_FS
plugins consistent with our motto ``It takes more than a license to
make source code open.''
Read <http://www.reiserfs.org/> to learn more about reiserfs.
Read <http://www.namesys.com/> to learn more about reiserfs.
Sponsored by Threshold Networks, Emusic.com, and Bigstorage.com.
......
......@@ -19,7 +19,7 @@ static struct posix_acl *
ext2_acl_from_disk(const void *value, size_t size)
{
const char *end = (char *)value + size;
size_t n, count;
int n, count;
struct posix_acl *acl;
if (!value)
......
......@@ -20,7 +20,7 @@ static struct posix_acl *
ext3_acl_from_disk(const void *value, size_t size)
{
const char *end = (char *)value + size;
size_t n, count;
int n, count;
struct posix_acl *acl;
if (!value)
......
......@@ -769,7 +769,6 @@ ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
int boundary = 0;
int depth = ext3_block_to_path(inode, iblock, offsets, &boundary);
struct ext3_inode_info *ei = EXT3_I(inode);
loff_t new_size;
J_ASSERT(handle != NULL || create == 0);
......@@ -834,23 +833,17 @@ ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
if (!err)
err = ext3_splice_branch(handle, inode, iblock, chain,
partial, left);
/* i_disksize growing is protected by truncate_sem
* don't forget to protect it if you're about to implement
* concurrent ext3_get_block() -bzzz */
if (!err && extend_disksize && inode->i_size > ei->i_disksize)
ei->i_disksize = inode->i_size;
up(&ei->truncate_sem);
if (err == -EAGAIN)
goto changed;
if (err)
goto cleanup;
if (extend_disksize) {
/*
* This is not racy against ext3_truncate's modification of
* i_disksize because VM/VFS ensures that the file cannot be
* extended while truncate is in progress. It is racy between
* multiple parallel instances of get_block, but we have BKL.
*/
new_size = inode->i_size;
if (new_size > ei->i_disksize)
ei->i_disksize = new_size;
}
set_buffer_new(bh_result);
goto got_it;
......
......@@ -453,7 +453,7 @@ static void prune_icache(int nr_to_scan)
dispose_list(&freeable);
up(&iprune_sem);
if (current_is_kswapd)
if (current_is_kswapd())
mod_page_state(kswapd_inodesteal, reap);
else
mod_page_state(pginodesteal, reap);
......
......@@ -478,14 +478,15 @@ static void *r_start(struct seq_file *m, loff_t *pos)
static void *r_next(struct seq_file *m, void *v, loff_t *pos)
{
++*pos;
if (v)
deactivate_super(v);
return NULL;
}
static void r_stop(struct seq_file *m, void *v)
{
struct proc_dir_entry *de = m->private;
struct super_block *s = de->data;
deactivate_super(s);
if (v)
deactivate_super(v);
}
static int r_show(struct seq_file *m, void *v)
......
#ifndef __ASM_MACH_MPPARSE_H
#define __ASM_MACH_MPPARSE_H
static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable,
unsigned short oemsize);
static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name,
struct mpc_config_translation *translation)
{
......@@ -24,16 +21,6 @@ static inline void mpc_oem_pci_bus(struct mpc_config_bus *m,
quad_local_to_mp_bus_id[quad][local] = m->mpc_busid;
}
static inline void mps_oem_check(struct mp_config_table *mpc, char *oem,
char *productid)
{
if (strncmp(oem, "IBM NUMA", 8))
printk("Warning! May not be a NUMA-Q system!\n");
if (mpc->mpc_oemptr)
smp_read_mpc_oem((struct mp_config_oemtable *) mpc->mpc_oemptr,
mpc->mpc_oemsize);
}
/* Hook from generic ACPI tables.c */
static inline void acpi_madt_oem_check(char *oem_id, char *oem_table_id)
{
......
......@@ -9,6 +9,8 @@
#include "do_mounts.h"
unsigned long initrd_start, initrd_end;
int initrd_below_start_ok;
unsigned int real_root_dev; /* do_proc_dointvec cannot handle kdev_t */
static int __initdata old_fd, root_fd;
static int __initdata mount_initrd = 1;
......@@ -99,18 +101,20 @@ static void __init handle_initrd(void)
int __init initrd_load(void)
{
if (!mount_initrd)
return 0;
create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, 0), NULL);
create_dev("/dev/initrd", MKDEV(RAMDISK_MAJOR, INITRD_MINOR), NULL);
/* Load the initrd data into /dev/ram0. Execute it as initrd unless
* /dev/ram0 is supposed to be our actual root device, in
* that case the ram disk is just set up here, and gets
* mounted in the normal path. */
if (rd_load_image("/dev/initrd") && ROOT_DEV != Root_RAM0) {
handle_initrd();
return 1;
if (mount_initrd) {
create_dev("/dev/ram", Root_RAM0, NULL);
/*
* Load the initrd data into /dev/ram0. Execute it as initrd
* unless /dev/ram0 is supposed to be our actual root device,
* in that case the ram disk is just set up here, and gets
* mounted in the normal path.
*/
if (rd_load_image("/dev/initrd") && ROOT_DEV != Root_RAM0) {
sys_unlink("/dev/initrd");
handle_initrd();
return 1;
}
}
sys_unlink("/dev/initrd");
return 0;
}
......@@ -8,9 +8,11 @@
#include <linux/delay.h>
#include <linux/string.h>
static __initdata char *message;
static void __init error(char *x)
{
panic("populate_root: %s\n", x);
if (!message)
message = x;
}
static void __init *malloc(int size)
......@@ -63,7 +65,7 @@ static char __init *find_link(int major, int minor, int ino, char *name)
}
q = (struct hash *)malloc(sizeof(struct hash));
if (!q)
error("can't allocate link hash entry");
panic("can't allocate link hash entry");
q->ino = ino;
q->minor = minor;
q->major = major;
......@@ -119,7 +121,7 @@ static void __init parse_header(char *s)
/* FSM */
enum state {
static __initdata enum state {
Start,
Collect,
GotHeader,
......@@ -130,9 +132,11 @@ enum state {
Reset
} state, next_state;
char *victim;
unsigned count;
loff_t this_header, next_header;
static __initdata char *victim;
static __initdata unsigned count;
static __initdata loff_t this_header, next_header;
static __initdata int dry_run;
static inline void eat(unsigned n)
{
......@@ -185,23 +189,30 @@ static int __init do_collect(void)
static int __init do_header(void)
{
if (memcmp(collected, "070701", 6)) {
error("no cpio magic");
return 1;
}
parse_header(collected);
next_header = this_header + N_ALIGN(name_len) + body_len;
next_header = (next_header + 3) & ~3;
if (dry_run) {
read_into(name_buf, N_ALIGN(name_len), GotName);
return 0;
}
state = SkipIt;
if (name_len <= 0 || name_len > PATH_MAX)
state = SkipIt;
else if (S_ISLNK(mode)) {
return 0;
if (S_ISLNK(mode)) {
if (body_len > PATH_MAX)
state = SkipIt;
else {
collect = collected = symlink_buf;
remains = N_ALIGN(name_len) + body_len;
next_state = GotSymlink;
state = Collect;
}
} else if (body_len && !S_ISREG(mode))
state = SkipIt;
else
return 0;
collect = collected = symlink_buf;
remains = N_ALIGN(name_len) + body_len;
next_state = GotSymlink;
state = Collect;
return 0;
}
if (S_ISREG(mode) || !body_len)
read_into(name_buf, N_ALIGN(name_len), GotName);
return 0;
}
......@@ -248,6 +259,8 @@ static int __init do_name(void)
next_state = Reset;
return 0;
}
if (dry_run)
return 0;
if (S_ISREG(mode)) {
if (maybe_link() >= 0) {
wfd = sys_open(collected, O_WRONLY|O_CREAT, mode);
......@@ -268,8 +281,7 @@ static int __init do_name(void)
sys_chown(collected, uid, gid);
sys_chmod(collected, mode);
}
} else
panic("populate_root: bogus mode: %o\n", mode);
}
return 0;
}
......@@ -323,13 +335,14 @@ static int __init write_buffer(char *buf, unsigned len)
static void __init flush_buffer(char *buf, unsigned len)
{
int written;
while ((written = write_buffer(buf, len)) < len) {
if (message)
return;
while ((written = write_buffer(buf, len)) < len && !message) {
char c = buf[written];
if (c == '0') {
buf += written;
len -= written;
state = Start;
continue;
} else
error("junk in compressed archive");
}
......@@ -408,18 +421,20 @@ static void __init flush_window(void)
outcnt = 0;
}
static void __init unpack_to_rootfs(char *buf, unsigned len)
char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
{
int written;
dry_run = check_only;
header_buf = malloc(110);
symlink_buf = malloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1);
name_buf = malloc(N_ALIGN(PATH_MAX));
window = malloc(WSIZE);
if (!window || !header_buf || !symlink_buf || !name_buf)
error("can't allocate buffers");
panic("can't allocate buffers");
state = Start;
this_header = 0;
while (len) {
message = NULL;
while (!message && len) {
loff_t saved_offset = this_header;
if (*buf == '0' && !(this_header & 3)) {
state = Start;
......@@ -427,7 +442,8 @@ static void __init unpack_to_rootfs(char *buf, unsigned len)
buf += written;
len -= written;
continue;
} else if (!*buf) {
}
if (!*buf) {
buf++;
len--;
this_header++;
......@@ -442,7 +458,7 @@ static void __init unpack_to_rootfs(char *buf, unsigned len)
crc = (ulg)0xffffffffL; /* shift register contents */
makecrc();
if (gunzip())
error("ungzip failed");
message = "ungzip failed";
if (state != Reset)
error("junk in gzipped archive");
this_header = saved_offset + inptr;
......@@ -453,12 +469,41 @@ static void __init unpack_to_rootfs(char *buf, unsigned len)
free(name_buf);
free(symlink_buf);
free(header_buf);
return message;
}
extern char __initramfs_start, __initramfs_end;
#ifdef CONFIG_BLK_DEV_INITRD
#include <linux/initrd.h>
#endif
void __init populate_rootfs(void)
{
unpack_to_rootfs(&__initramfs_start,
&__initramfs_end - &__initramfs_start);
char *err = unpack_to_rootfs(&__initramfs_start,
&__initramfs_end - &__initramfs_start, 0);
if (err)
panic(err);
#ifdef CONFIG_BLK_DEV_INITRD
if (initrd_start) {
int fd;
printk(KERN_INFO "checking if image is initramfs...");
err = unpack_to_rootfs((char *)initrd_start,
initrd_end - initrd_start, 1);
if (!err) {
printk(" it is\n");
unpack_to_rootfs((char *)initrd_start,
initrd_end - initrd_start, 0);
free_initrd_mem(initrd_start, initrd_end);
return;
}
printk("it isn't (%s); looks like an initrd\n", err);
fd = sys_open("/dev/initrd", O_WRONLY|O_CREAT, 700);
if (fd >= 0) {
sys_write(fd, (char *)initrd_start,
initrd_end - initrd_start);
sys_close(fd);
free_initrd_mem(initrd_start, initrd_end);
}
}
#endif
}
......@@ -2849,7 +2849,7 @@ void __might_sleep(char *file, int line)
static unsigned long prev_jiffy; /* ratelimiting */
if (in_atomic() || irqs_disabled()) {
if (time_before(jiffies, prev_jiffy + HZ))
if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
return;
prev_jiffy = jiffies;
printk(KERN_ERR "Debug: sleeping function called from invalid"
......
......@@ -1318,6 +1318,10 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
/*
* Read the swap header.
*/
if (!mapping->a_ops->readpage) {
error = -EINVAL;
goto bad_swap;
}
page = read_cache_page(mapping, 0,
(filler_t *)mapping->a_ops->readpage, swap_file);
if (IS_ERR(page)) {
......
......@@ -12,7 +12,7 @@ use strict;
## $3 -- the filename which contained the sgmldoc output
## (I need this so I know which manpages to convert)
my($LISTING, $GENERATED, $INPUT, $OUTPUT, $front, $mode, $filename);
my($LISTING, $GENERATED, $INPUT, $OUTPUT, $front, $mode, $filename, $tmpdir);
if($ARGV[0] eq ""){
die "Usage: makeman [convert | install] <dir> <file>\n";
......@@ -22,6 +22,13 @@ if( ! -d "$ARGV[1]" ){
die "Output directory \"$ARGV[1]\" does not exist\n";
}
if($ENV{"TMPDIR"} ne ""){
$tmpdir = $ENV{"TMPDIR"};
}
else{
$tmpdir = "/tmp";
}
if($ARGV[0] eq "convert"){
open LISTING, "grep \"<refentrytitle>\" $ARGV[2] |";
while(<LISTING>){
......@@ -40,29 +47,38 @@ if($ARGV[0] eq "convert"){
open INPUT, "< $ARGV[1]/$filename.sgml";
$front = "";
$mode = 0;
while(<INPUT>){
if(/.*ENDFRONTTAG.*/){
$mode = 0;
}
# The modes used here are:
# mode = 0
# <!-- BEGINFRONTTAG -->
# <!-- <bookinfo> mode = 1
# <!-- <legalnotice> mode = 2
# <!-- ...GPL or whatever...
# <!-- </legalnotice> mode = 4
# <!-- </bookinfo> mode = 3
# <!-- ENDFRONTTAG -->
#
# ...doco...
# I know that some of the if statements in this while loop are in a funny
# order, but that is deliberate...
while(<INPUT>){
if($mode > 0){
s/<!-- //;
s/ -->//;
s/<bookinfo>//;
s/<\/bookinfo>//;
s/<docinfo>//;
s<\/docinfo>//;
s/^[ \t]*//;
s/<docinfo>//i;
s<\/docinfo>//i;
s/^[ \t]*//i;
}
if($mode == 2){
if(/<para>/){
if(/<para>/i){
}
elsif(/<\/para>/){
elsif(/<\/para>/i){
$front = "$front.\\\" \n";
}
elsif(/<\/legalnotice>/){
$mode = 1;
elsif(/<\/legalnotice>/i){
$mode = 4;
}
elsif(/^[ \t]*$/){
}
......@@ -72,69 +88,79 @@ if($ARGV[0] eq "convert"){
}
if($mode == 1){
if(/<title>(.*)<\/title>/){
if(/<title>(.*)<\/title>/i){
$front = "$front.\\\" This documentation was generated from the book titled \"$1\", which is part of the Linux kernel source.\n.\\\" \n";
}
elsif(/<legalnotice>/){
elsif(/<legalnotice>/i){
$front = "$front.\\\" This documentation comes with the following legal notice:\n.\\\" \n";
$mode = 2;
}
elsif(/<author>/){
elsif(/<author>/i){
$front = "$front.\\\" Documentation by: ";
}
elsif(/<firstname>(.*)<\/firstname>/){
elsif(/<firstname>(.*)<\/firstname>/i){
$front = "$front$1 ";
}
elsif(/<surname>(.*)<\/surname>/){
elsif(/<surname>(.*)<\/surname>/i){
$front = "$front$1 ";
}
elsif(/<email>(.*)<\/email>/){
elsif(/<email>(.*)<\/email>/i){
$front = "$front($1)";
}
elsif(/\/author>/){
elsif(/\/author>/i){
$front = "$front\n";
}
elsif(/<copyright>/){
elsif(/<copyright>/i){
$front = "$front.\\\" Documentation copyright: ";
}
elsif(/<holder>(.*)<\/holder>/){
elsif(/<holder>(.*)<\/holder>/i){
$front = "$front$1 ";
}
elsif(/<year>(.*)<\/year>/){
elsif(/<year>(.*)<\/year>/i){
$front = "$front$1 ";
}
elsif(/\/copyright>/){
elsif(/\/copyright>/i){
$front = "$front\n";
}
elsif(/^[ \t]*$/
|| /<affiliation>/
|| /<\/affiliation>/
|| /<address>/
|| /<\/address>/
|| /<authorgroup>/
|| /<\/authorgroup>/
|| /<\/legalnotice>/
|| /<date>/
|| /<\/date>/
|| /<edition>/
|| /<\/edition>/){
|| /<affiliation>/i
|| /<\/affiliation>/i
|| /<address>/i
|| /<\/address>/i
|| /<authorgroup>/i
|| /<\/authorgroup>/i
|| /<\/legalnotice>/i
|| /<date>/i
|| /<\/date>/i
|| /<edition>/i
|| /<\/edition>/i
|| /<pubdate>/i
|| /<\/pubdate>/i){
}
else{
print "Unknown tag in manpage conversion: $_";
}
}
if(/.*BEGINFRONTTAG.*/){
$mode = 1;
if($mode == 0){
if(/<bookinfo>/i){
$mode = 1;
}
}
if($mode == 4){
if(/<\/bookinfo>/i){
$mode = 3;
}
}
}
close INPUT;
system("cd $ARGV[1]; docbook2man $filename.sgml; mv $filename.9 /tmp/$$.9\n");
open GENERATED, "< /tmp/$$.9";
system("cd $ARGV[1]; docbook2man $filename.sgml; mv $filename.9 $tmpdir/$$.9\n");
open GENERATED, "< $tmpdir/$$.9";
open OUTPUT, "> $ARGV[1]/$filename.9";
print OUTPUT "$front";
......@@ -146,7 +172,7 @@ if($ARGV[0] eq "convert"){
close GENERATED;
system("gzip -f $ARGV[1]/$filename.9\n");
unlink("/tmp/$filename.9");
unlink("$tmpdir/$$.9");
}
}
elsif($ARGV[0] eq "install"){
......
......@@ -52,7 +52,7 @@ while(<SGML>){
open REF, "> $ARGV[1]/$filename.sgml" or
die "Couldn't open output file \"$ARGV[1]/$filename.sgml\": $!\n";
print REF <<EOF;
<!DOCTYPE refentry PUBLIC "-//Davenport//DTD DocBook V3.0//EN">
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
<!-- BEGINFRONTTAG: The following is front matter for the parent book -->
$front
......
......@@ -13,6 +13,7 @@
#define SECCLASS_NULL 0x0000 /* no class */
#define SELINUX_MAGIC 0xf97cff8c
#define POLICYDB_VERSION 15
#ifdef CONFIG_SECURITY_SELINUX_BOOTPARAM
extern int selinux_enabled;
......
......@@ -37,7 +37,8 @@ enum sel_inos {
SEL_ACCESS, /* compute access decision */
SEL_CREATE, /* compute create labeling decision */
SEL_RELABEL, /* compute relabeling decision */
SEL_USER /* compute reachable user contexts */
SEL_USER, /* compute reachable user contexts */
SEL_POLICYVERS /* return policy version for this kernel */
};
static ssize_t sel_read_enforce(struct file *filp, char *buf,
......@@ -125,6 +126,46 @@ static struct file_operations sel_enforce_ops = {
.write = sel_write_enforce,
};
static ssize_t sel_read_policyvers(struct file *filp, char *buf,
size_t count, loff_t *ppos)
{
char *page;
ssize_t length;
ssize_t end;
if (count < 0 || count > PAGE_SIZE)
return -EINVAL;
if (!(page = (char*)__get_free_page(GFP_KERNEL)))
return -ENOMEM;
memset(page, 0, PAGE_SIZE);
length = snprintf(page, PAGE_SIZE, "%u", POLICYDB_VERSION);
if (length < 0) {
free_page((unsigned long)page);
return length;
}
if (*ppos >= length) {
free_page((unsigned long)page);
return 0;
}
if (count + *ppos > length)
count = length - *ppos;
end = count + *ppos;
if (copy_to_user(buf, (char *) page + *ppos, count)) {
count = -EFAULT;
goto out;
}
*ppos = end;
out:
free_page((unsigned long)page);
return count;
}
static struct file_operations sel_policyvers_ops = {
.read = sel_read_policyvers,
};
static ssize_t sel_write_load(struct file * file, const char * buf,
size_t count, loff_t *ppos)
......@@ -568,6 +609,7 @@ static int sel_fill_super(struct super_block * sb, void * data, int silent)
[SEL_CREATE] = {"create", &transaction_ops, S_IRUGO|S_IWUGO},
[SEL_RELABEL] = {"relabel", &transaction_ops, S_IRUGO|S_IWUGO},
[SEL_USER] = {"user", &transaction_ops, S_IRUGO|S_IWUGO},
[SEL_POLICYVERS] = {"policyvers", &sel_policyvers_ops, S_IRUGO},
/* last one */ {""}
};
return simple_fill_super(sb, SELINUX_MAGIC, selinux_files);
......
......@@ -225,7 +225,6 @@ extern int policydb_read(struct policydb *p, void *fp);
#define PERM_SYMTAB_SIZE 32
#define POLICYDB_VERSION 15
#define POLICYDB_CONFIG_MLS 1
#define OBJECT_R "object_r"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment