diff options
author | Andrew Morton <akpm@osdl.org> | 2004-03-13 03:25:58 -0800 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2004-03-13 03:25:58 -0800 |
commit | d1dbcdee71f00e0e4c4422d678ea4d4ced30212a (patch) | |
tree | a76a2f8cab41669ac6a741235b13acd9c1f80cfe /init | |
parent | 214b914e1efb03b22cc5009a6f5d78f8df91686c (diff) | |
download | history-d1dbcdee71f00e0e4c4422d678ea4d4ced30212a.tar.gz |
[PATCH] further __KERNEL_SYSCALLS__ removal
From: Arnd Bergmann <arnd@arndb.de>
Dave Jones already removed some of the useless __KERNEL_SYSCALLS__ defines
in various files, this gets rid of almost all the others. Replacing
execve() is nontrivial, so I left those in for now.
For all the other system calls that are currently used from inside the
kernel, calling the sys_* function directly should always have an identical
effect.
Diffstat (limited to 'init')
-rw-r--r-- | init/do_mounts.c | 24 | ||||
-rw-r--r-- | init/do_mounts.h | 1 | ||||
-rw-r--r-- | init/do_mounts_devfs.c | 8 | ||||
-rw-r--r-- | init/do_mounts_initrd.c | 29 | ||||
-rw-r--r-- | init/do_mounts_md.c | 10 | ||||
-rw-r--r-- | init/do_mounts_rd.c | 30 | ||||
-rw-r--r-- | init/initramfs.c | 2 | ||||
-rw-r--r-- | init/main.c | 8 |
8 files changed, 55 insertions, 57 deletions
diff --git a/init/do_mounts.c b/init/do_mounts.c index 81327e407b91d7..fef791e4dcb62f 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c @@ -66,11 +66,11 @@ static dev_t __init try_name(char *name, int part) /* read device number from .../dev */ sprintf(path, "/sys/block/%s/dev", name); - fd = open(path, 0, 0); + fd = sys_open(path, 0, 0); if (fd < 0) goto fail; - len = read(fd, buf, 32); - close(fd); + len = sys_read(fd, buf, 32); + sys_close(fd); if (len <= 0 || len == 32 || buf[len - 1] != '\n') goto fail; buf[len - 1] = '\0'; @@ -96,11 +96,11 @@ static dev_t __init try_name(char *name, int part) /* otherwise read range from .../range */ sprintf(path, "/sys/block/%s/range", name); - fd = open(path, 0, 0); + fd = sys_open(path, 0, 0); if (fd < 0) goto fail; - len = read(fd, buf, 32); - close(fd); + len = sys_read(fd, buf, 32); + sys_close(fd); if (len <= 0 || len == 32 || buf[len - 1] != '\n') goto fail; buf[len - 1] = '\0'; @@ -288,7 +288,7 @@ retry: continue; } /* - * Allow the user to distinguish between failed open + * Allow the user to distinguish between failed sys_open * and bad superblock on root device. */ __bdevname(ROOT_DEV, b); @@ -327,21 +327,21 @@ void __init change_floppy(char *fmt, ...) va_start(args, fmt); vsprintf(buf, fmt, args); va_end(args); - fd = open("/dev/root", O_RDWR | O_NDELAY, 0); + fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0); if (fd >= 0) { sys_ioctl(fd, FDEJECT, 0); - close(fd); + sys_close(fd); } printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf); - fd = open("/dev/console", O_RDWR, 0); + fd = sys_open("/dev/console", O_RDWR, 0); if (fd >= 0) { sys_ioctl(fd, TCGETS, (long)&termios); termios.c_lflag &= ~ICANON; sys_ioctl(fd, TCSETSF, (long)&termios); - read(fd, &c, 1); + sys_read(fd, &c, 1); termios.c_lflag |= ICANON; sys_ioctl(fd, TCSETSF, (long)&termios); - close(fd); + sys_close(fd); } } #endif diff --git a/init/do_mounts.h b/init/do_mounts.h index 88e4c7463ee1d5..de92bee4f35e7b 100644 --- a/init/do_mounts.h +++ b/init/do_mounts.h @@ -1,4 +1,3 @@ -#define __KERNEL_SYSCALLS__ #include <linux/config.h> #include <linux/kernel.h> #include <linux/devfs_fs_kernel.h> diff --git a/init/do_mounts_devfs.c b/init/do_mounts_devfs.c index 005cf8b32f55c0..e1be9c28f9ef6b 100644 --- a/init/do_mounts_devfs.c +++ b/init/do_mounts_devfs.c @@ -24,7 +24,7 @@ static int __init do_read_dir(int fd, void *buf, int len) { long bytes, n; char *p = buf; - lseek(fd, 0, 0); + sys_lseek(fd, 0, 0); for (bytes = 0; bytes < len; bytes += n) { n = sys_getdents64(fd, (struct linux_dirent64 *)(p + bytes), @@ -45,7 +45,7 @@ static int __init do_read_dir(int fd, void *buf, int len) static void * __init read_dir(char *path, int *len) { int size; - int fd = open(path, 0, 0); + int fd = sys_open(path, 0, 0); *len = 0; if (fd < 0) @@ -58,7 +58,7 @@ static void * __init read_dir(char *path, int *len) break; n = do_read_dir(fd, p, size); if (n > 0) { - close(fd); + sys_close(fd); *len = n; return p; } @@ -68,7 +68,7 @@ static void * __init read_dir(char *path, int *len) if (n < 0) break; } - close(fd); + sys_close(fd); return NULL; } diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index 452b522cbcfa64..e65c2e25dd28d0 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c @@ -1,4 +1,5 @@ - +#define __KERNEL_SYSCALLS__ +#include <linux/unistd.h> #include <linux/kernel.h> #include <linux/fs.h> #include <linux/minix_fs.h> @@ -28,12 +29,12 @@ static int __init do_linuxrc(void * shell) static char *argv[] = { "linuxrc", NULL, }; extern char * envp_init[]; - close(old_fd);close(root_fd); - close(0);close(1);close(2); - setsid(); - (void) open("/dev/console",O_RDWR,0); - (void) dup(0); - (void) dup(0); + sys_close(old_fd);sys_close(root_fd); + sys_close(0);sys_close(1);sys_close(2); + sys_setsid(); + (void) sys_open("/dev/console",O_RDWR,0); + (void) sys_dup(0); + (void) sys_dup(0); return execve(shell, argv, envp_init); } @@ -47,8 +48,8 @@ static void __init handle_initrd(void) /* mount initrd on rootfs' /root */ mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY); sys_mkdir("/old", 0700); - root_fd = open("/", 0, 0); - old_fd = open("/old", 0, 0); + root_fd = sys_open("/", 0, 0); + old_fd = sys_open("/old", 0, 0); /* move initrd over / and chdir/chroot in initrd root */ sys_chdir("/root"); sys_mount(".", "/", NULL, MS_MOVE, NULL); @@ -57,7 +58,7 @@ static void __init handle_initrd(void) pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD); if (pid > 0) { - while (pid != waitpid(-1, &i, 0)) + while (pid != sys_wait4(-1, &i, 0, 0)) yield(); } @@ -67,8 +68,8 @@ static void __init handle_initrd(void) /* switch root and cwd back to / of rootfs */ sys_fchdir(root_fd); sys_chroot("."); - close(old_fd); - close(root_fd); + sys_close(old_fd); + sys_close(root_fd); umount_devfs("/old/dev"); if (new_decode_dev(real_root_dev) == Root_RAM0) { @@ -84,7 +85,7 @@ static void __init handle_initrd(void) if (!error) printk("okay\n"); else { - int fd = open("/dev/root.old", O_RDWR, 0); + int fd = sys_open("/dev/root.old", O_RDWR, 0); printk("failed\n"); printk(KERN_NOTICE "Unmounting old root\n"); sys_umount("/old", MNT_DETACH); @@ -93,7 +94,7 @@ static void __init handle_initrd(void) error = fd; } else { error = sys_ioctl(fd, BLKFLSBUF, 0); - close(fd); + sys_close(fd); } printk(!error ? "okay\n" : "failed\n"); } diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c index 7287d055c75887..a2b7fe08a418cb 100644 --- a/init/do_mounts_md.c +++ b/init/do_mounts_md.c @@ -154,7 +154,7 @@ static void __init md_setup_drive(void) printk(KERN_INFO "md: Loading md%d: %s\n", minor, md_setup_args.device_names[minor]); - fd = open(name, 0, 0); + fd = sys_open(name, 0, 0); if (fd < 0) { printk(KERN_ERR "md: open failed - cannot start array %d\n", minor); continue; @@ -163,7 +163,7 @@ static void __init md_setup_drive(void) printk(KERN_WARNING "md: Ignoring md=%d, already autodetected. (Use raid=noautodetect)\n", minor); - close(fd); + sys_close(fd); continue; } @@ -209,7 +209,7 @@ static void __init md_setup_drive(void) err = sys_ioctl(fd, RUN_ARRAY, 0); if (err) printk(KERN_WARNING "md: starting md%d failed\n", minor); - close(fd); + sys_close(fd); } } @@ -243,10 +243,10 @@ void __init md_run_setup(void) if (raid_noautodetect) printk(KERN_INFO "md: Skipping autodetection of RAID arrays. (raid=noautodetect)\n"); else { - int fd = open("/dev/md0", 0, 0); + int fd = sys_open("/dev/md0", 0, 0); if (fd >= 0) { sys_ioctl(fd, RAID_AUTORUN, 0); - close(fd); + sys_close(fd); } } md_setup_drive(); diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c index e8b6e2ffc11a8c..f7e3d8f1ae7081 100644 --- a/init/do_mounts_rd.c +++ b/init/do_mounts_rd.c @@ -69,8 +69,8 @@ identify_ramdisk_image(int fd, int start_block) /* * Read block 0 to test for gzipped kernel */ - lseek(fd, start_block * BLOCK_SIZE, 0); - read(fd, buf, size); + sys_lseek(fd, start_block * BLOCK_SIZE, 0); + sys_read(fd, buf, size); /* * If it matches the gzip magic numbers, return -1 @@ -104,8 +104,8 @@ identify_ramdisk_image(int fd, int start_block) /* * Read block 1 to test for minix and ext2 superblock */ - lseek(fd, (start_block+1) * BLOCK_SIZE, 0); - read(fd, buf, size); + sys_lseek(fd, (start_block+1) * BLOCK_SIZE, 0); + sys_read(fd, buf, size); /* Try minix */ if (minixsb->s_magic == MINIX_SUPER_MAGIC || @@ -131,7 +131,7 @@ identify_ramdisk_image(int fd, int start_block) start_block); done: - lseek(fd, start_block * BLOCK_SIZE, 0); + sys_lseek(fd, start_block * BLOCK_SIZE, 0); kfree(buf); return nblocks; } @@ -148,11 +148,11 @@ int __init rd_load_image(char *from) char rotator[4] = { '|' , '/' , '-' , '\\' }; #endif - out_fd = open("/dev/ram", O_RDWR, 0); + out_fd = sys_open("/dev/ram", O_RDWR, 0); if (out_fd < 0) goto out; - in_fd = open(from, O_RDONLY, 0); + in_fd = sys_open(from, O_RDONLY, 0); if (in_fd < 0) goto noclose_input; @@ -217,20 +217,20 @@ int __init rd_load_image(char *from) if (i && (i % devblocks == 0)) { printk("done disk #%d.\n", disk++); rotate = 0; - if (close(in_fd)) { + if (sys_close(in_fd)) { printk("Error closing the disk.\n"); goto noclose_input; } change_floppy("disk #%d", disk); - in_fd = open(from, O_RDONLY, 0); + in_fd = sys_open(from, O_RDONLY, 0); if (in_fd < 0) { printk("Error opening disk.\n"); goto noclose_input; } printk("Loading disk #%d... ", disk); } - read(in_fd, buf, BLOCK_SIZE); - write(out_fd, buf, BLOCK_SIZE); + sys_read(in_fd, buf, BLOCK_SIZE); + sys_write(out_fd, buf, BLOCK_SIZE); #if !defined(CONFIG_ARCH_S390) && !defined(CONFIG_PPC_ISERIES) if (!(i % 16)) { printk("%c\b", rotator[rotate & 0x3]); @@ -243,9 +243,9 @@ int __init rd_load_image(char *from) successful_load: res = 1; done: - close(in_fd); + sys_close(in_fd); noclose_input: - close(out_fd); + sys_close(out_fd); out: kfree(buf); sys_unlink("/dev/ram"); @@ -342,7 +342,7 @@ static int __init fill_inbuf(void) { if (exit_code) return -1; - insize = read(crd_infd, inbuf, INBUFSIZ); + insize = sys_read(crd_infd, inbuf, INBUFSIZ); if (insize == 0) { error("RAMDISK: ran out of compressed data"); return -1; @@ -363,7 +363,7 @@ static void __init flush_window(void) unsigned n, written; uch *in, ch; - written = write(crd_outfd, window, outcnt); + written = sys_write(crd_outfd, window, outcnt); if (written != outcnt && unzip_error == 0) { printk(KERN_ERR "RAMDISK: incomplete write (%d != %d) %ld\n", written, outcnt, bytes_out); diff --git a/init/initramfs.c b/init/initramfs.c index 7608b019137cee..d0ce3884bc9df6 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -1,10 +1,8 @@ -#define __KERNEL_SYSCALLS__ #include <linux/init.h> #include <linux/fs.h> #include <linux/slab.h> #include <linux/types.h> #include <linux/fcntl.h> -#include <linux/unistd.h> #include <linux/delay.h> #include <linux/string.h> #include <linux/syscalls.h> diff --git a/init/main.c b/init/main.c index 2059782e8a9ddc..7e73a1c3c5e7f5 100644 --- a/init/main.c +++ b/init/main.c @@ -18,7 +18,6 @@ #include <linux/devfs_fs_kernel.h> #include <linux/kernel.h> #include <linux/syscalls.h> -#include <linux/unistd.h> #include <linux/string.h> #include <linux/ctype.h> #include <linux/delay.h> @@ -42,6 +41,7 @@ #include <linux/writeback.h> #include <linux/cpu.h> #include <linux/efi.h> +#include <linux/unistd.h> #include <asm/io.h> #include <asm/bugs.h> @@ -612,11 +612,11 @@ static int init(void * unused) unlock_kernel(); system_running = 1; - if (open("/dev/console", O_RDWR, 0) < 0) + if (sys_open("/dev/console", O_RDWR, 0) < 0) printk("Warning: unable to open an initial console.\n"); - (void) dup(0); - (void) dup(0); + (void) sys_dup(0); + (void) sys_dup(0); /* * We try each of these until one succeeds. |