Skip to content

Commit b4ffb6a

Browse files
cfd-36Linus Torvalds
authored andcommitted
uml: host_info tidying
Move the host_info string from util.c to um_arch.c, where it is actually initialized and used. Also document its lack of locking. Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a5ed1ff commit b4ffb6a

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎arch/um/include/os.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ extern void stack_protections(unsigned long address);
273273
extern void task_protections(unsigned long address);
274274
extern int raw(int fd);
275275
extern void setup_machinename(char *machine_out);
276-
extern void setup_hostinfo(void);
276+
extern void setup_hostinfo(char *buf, int len);
277277
extern int setjmp_wrapper(void (*proc)(void *, void *), ...);
278278

279279
/* time.c */

‎arch/um/include/user_util.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ extern unsigned long end_vm;
3636
extern unsigned long start_vm;
3737
extern unsigned long long highmem;
3838

39-
extern char host_info[];
40-
4139
extern unsigned long _stext, _etext, _sdata, _edata, __bss_start, _end;
4240
extern unsigned long _unprotected_end;
4341
extern unsigned long brk_start;

‎arch/um/kernel/um_arch.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "linux/seq_file.h"
1818
#include "linux/delay.h"
1919
#include "linux/module.h"
20+
#include "linux/utsname.h"
2021
#include "asm/page.h"
2122
#include "asm/pgtable.h"
2223
#include "asm/ptrace.h"
@@ -67,6 +68,9 @@ unsigned long thread_saved_pc(struct task_struct *task)
6768
task));
6869
}
6970

71+
/* Changed in setup_arch, which is called in early boot */
72+
static char host_info[(__NEW_UTS_LEN + 1) * 5];
73+
7074
static int show_cpuinfo(struct seq_file *m, void *v)
7175
{
7276
int index = 0;
@@ -482,7 +486,7 @@ void __init setup_arch(char **cmdline_p)
482486
paging_init();
483487
strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
484488
*cmdline_p = command_line;
485-
setup_hostinfo();
489+
setup_hostinfo(host_info, sizeof host_info);
486490
}
487491

488492
void __init check_bugs(void)

‎arch/um/os-Linux/util.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,13 @@ void setup_machinename(char *machine_out)
9696
strcpy(machine_out, host.machine);
9797
}
9898

99-
char host_info[(_UTSNAME_LENGTH + 1) * 4 + _UTSNAME_NODENAME_LENGTH + 1];
100-
101-
void setup_hostinfo(void)
99+
void setup_hostinfo(char *buf, int len)
102100
{
103101
struct utsname host;
104102

105103
uname(&host);
106-
sprintf(host_info, "%s %s %s %s %s", host.sysname, host.nodename,
107-
host.release, host.version, host.machine);
104+
snprintf(buf, len, "%s %s %s %s %s", host.sysname, host.nodename,
105+
host.release, host.version, host.machine);
108106
}
109107

110108
int setjmp_wrapper(void (*proc)(void *, void *), ...)

0 commit comments

Comments
 (0)