uml: style fixes in arch/um/os-Linux

Style changes under arch/um/os-Linux:
	include trimming
	CodingStyle fixes
	some printks needed severity indicators

make_tempfile turns out not to be used outside of mem.c, so it is now static.
Its declaration in tempfile.h is no longer needed, and tempfile.h itself is no
longer needed.

create_tmp_file was also made static.

checkpatch moans about an EXPORT_SYMBOL in user_syms.c which is part of a
macro definition - this is copying a bit of kernel infrastructure into the
libc side of UML because the kernel headers can't be included there.

Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Jeff Dike 2008-02-08 04:22:08 -08:00 committed by Linus Torvalds
parent 536788fe2d
commit 5134d8fea0
14 changed files with 99 additions and 130 deletions

View file

@ -1,11 +0,0 @@
/*
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL
*/
#ifndef __TEMPFILE_H__
#define __TEMPFILE_H__
extern int make_tempfile(const char *template, char **tempname, int do_unlink);
#endif

View file

@ -6,7 +6,7 @@
* Licensed under the GPL.
*/
#include "linux/init.h"
#include <linux/init.h>
#include <linux/netdevice.h>
#include "etap.h"
#include "net_kern.h"
@ -30,10 +30,10 @@ static void etap_init(struct net_device *dev, void *data)
epri->control_fd = -1;
epri->dev = dev;
printk("ethertap backend - %s", epri->dev_name);
printk(KERN_INFO "ethertap backend - %s", epri->dev_name);
if (epri->gate_addr != NULL)
printk(", IP = %s", epri->gate_addr);
printk("\n");
printk(KERN_CONT ", IP = %s", epri->gate_addr);
printk(KERN_CONT "\n");
}
static int etap_read(int fd, struct sk_buff *skb, struct uml_net_private *lp)

View file

@ -29,10 +29,10 @@ static void tuntap_init(struct net_device *dev, void *data)
tpri->fd = -1;
tpri->dev = dev;
printk("TUN/TAP backend - ");
printk(KERN_INFO "TUN/TAP backend - ");
if (tpri->gate_addr != NULL)
printk("IP = %s", tpri->gate_addr);
printk("\n");
printk(KERN_CONT "IP = %s", tpri->gate_addr);
printk(KERN_CONT "\n");
}
static int tuntap_read(int fd, struct sk_buff *skb, struct uml_net_private *lp)

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
* Licensed under the GPL
*/
@ -9,14 +9,3 @@
#define DEV_NULL "/dev/null"
#endif
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/

View file

@ -1,22 +1,21 @@
/*
* Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
* Licensed under the GPL
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/statfs.h>
#include "user.h"
#include "mem_user.h"
#include "init.h"
#include "os.h"
#include "tempfile.h"
#include "kern_constants.h"
#include <sys/param.h>
#include "init.h"
#include "kern_constants.h"
#include "os.h"
#include "user.h"
/* Modified by which_tmpdir, which is called during early boot */
static char *default_tmpdir = "/tmp";
@ -33,7 +32,8 @@ static void __init find_tempdir(void)
int i;
char *dir = NULL;
if(tempdir != NULL) /* We've already been called */
if (tempdir != NULL)
/* We've already been called */
return;
for (i = 0; dirs[i]; i++) {
dir = getenv(dirs[i]);
@ -53,7 +53,8 @@ static void __init find_tempdir(void)
strcat(tempdir, "/");
}
/* This will return 1, with the first character in buf being the
/*
* This will return 1, with the first character in buf being the
* character following the next instance of c in the file. This will
* read the file as needed. If there's an error, -errno is returned;
* if the end of the file is reached, 0 is returned.
@ -78,7 +79,8 @@ static int next(int fd, char *buf, size_t size, char c)
len = strlen(ptr);
memmove(buf, ptr, len + 1);
/* Refill the buffer so that if there's a partial string that we care
/*
* Refill the buffer so that if there's a partial string that we care
* about, it will be completed, and we can recognize it.
*/
n = read(fd, &buf[len], size - len - 1);
@ -92,7 +94,8 @@ static int next(int fd, char *buf, size_t size, char c)
/* which_tmpdir is called only during early boot */
static int checked_tmpdir = 0;
/* Look for a tmpfs mounted at /dev/shm. I couldn't find a cleaner
/*
* Look for a tmpfs mounted at /dev/shm. I couldn't find a cleaner
* way to do this than to parse /proc/mounts. statfs will return the
* same filesystem magic number and fs id for both /dev and /dev/shm
* when they are both tmpfs, so you can't tell if they are different
@ -164,7 +167,7 @@ found:
* (file: kernel/tt/ptproxy/proxy.c, proc: start_debugger).
* So it isn't 'static' yet.
*/
int __init make_tempfile(const char *template, char **out_tempname,
static int __init make_tempfile(const char *template, char **out_tempname,
int do_unlink)
{
char *tempname;
@ -204,19 +207,14 @@ out:
#define TEMPNAME_TEMPLATE "vm_file-XXXXXX"
/*
* This proc is used in start_up.c
* So it isn't 'static'.
*/
int __init create_tmp_file(unsigned long long len)
static int __init create_tmp_file(unsigned long long len)
{
int fd, err;
char zero;
fd = make_tempfile(TEMPNAME_TEMPLATE, NULL, 1);
if(fd < 0) {
if (fd < 0)
exit(1);
}
err = fchmod(fd, 0777);
if (err < 0) {
@ -224,7 +222,8 @@ int __init create_tmp_file(unsigned long long len)
exit(1);
}
/* Seek to len - 1 because writing a character there will
/*
* Seek to len - 1 because writing a character there will
* increase the file size by one byte, to the desired length.
*/
if (lseek64(fd, len - 1, SEEK_SET) < 0) {

View file

@ -224,7 +224,7 @@ int __init can_drop_memory(void)
goto out_unmap;
}
printk("OK\n");
printk(UM_KERN_CONT "OK\n");
ok = 1;
out_unmap:

View file

@ -341,7 +341,7 @@ void userspace(struct uml_pt_regs *regs)
int local_using_sysemu;
if (getitimer(ITIMER_VIRTUAL, &timer))
printk("Failed to get itimer, errno = %d\n", errno);
printk(UM_KERN_ERR "Failed to get itimer, errno = %d\n", errno);
nsecs = timer.it_value.tv_sec * UM_NSEC_PER_SEC +
timer.it_value.tv_usec * UM_NSEC_PER_USEC;
nsecs += os_nsecs();

View file

@ -7,6 +7,7 @@
#include <sys/ptrace.h>
#define __FRAME_OFFSETS
#include <asm/ptrace.h>
#include "kern_constants.h"
#include "longjmp.h"
#include "user.h"
@ -27,11 +28,15 @@ int restore_fp_registers(int pid, unsigned long *fp_regs)
unsigned long get_thread_reg(int reg, jmp_buf *buf)
{
switch (reg) {
case RIP: return buf[0]->__rip;
case RSP: return buf[0]->__rsp;
case RBP: return buf[0]->__rbp;
case RIP:
return buf[0]->__rip;
case RSP:
return buf[0]->__rsp;
case RBP:
return buf[0]->__rbp;
default:
printk("get_thread_regs - unknown register %d\n", reg);
printk(UM_KERN_ERR "get_thread_regs - unknown register %d\n",
reg);
return 0;
}
}

View file

@ -1,6 +1,6 @@
/*
* Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk)
* Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
* Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
* Licensed under the GPL
*/

View file

@ -1,35 +1,20 @@
/*
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
* Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
* Licensed under the GPL
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <sys/param.h>
#include <sys/time.h>
#include "asm/types.h"
#include <ctype.h>
#include <signal.h>
#include <wait.h>
#include <errno.h>
#include <stdarg.h>
#include <sched.h>
#include <termios.h>
#include <signal.h>
#include <string.h>
#include "kern_util.h"
#include "user.h"
#include "mem_user.h"
#include "init.h"
#include "ptrace_user.h"
#include "uml-config.h"
#include "os.h"
#include "longjmp.h"
#include <termios.h>
#include <wait.h>
#include <sys/mman.h>
#include <sys/utsname.h>
#include "kern_constants.h"
#include "os.h"
#include "user.h"
void stack_protections(unsigned long address)
{
@ -53,8 +38,10 @@ int raw(int fd)
if (err < 0)
return -errno;
/* XXX tcsetattr could have applied only some changes
* (and cfmakeraw() is a set of changes) */
/*
* XXX tcsetattr could have applied only some changes
* (and cfmakeraw() is a set of changes)
*/
return 0;
}