Commit 7dd6f4b2 authored by Anthony Liguori's avatar Anthony Liguori

Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging

* riku/linux-user-for-upstream:
  linux-user: Clarify "Unable to reserve guest address space" error
  linux-user: fix emulation of getdents
  linux-user: arg_table need not have global scope
parents 18fec301 097b8cb8
...@@ -3222,7 +3222,7 @@ struct qemu_argument { ...@@ -3222,7 +3222,7 @@ struct qemu_argument {
const char *help; const char *help;
}; };
struct qemu_argument arg_table[] = { static const struct qemu_argument arg_table[] = {
{"h", "", false, handle_arg_help, {"h", "", false, handle_arg_help,
"", "print this help"}, "", "print this help"},
{"g", "QEMU_GDB", true, handle_arg_gdb, {"g", "QEMU_GDB", true, handle_arg_gdb,
...@@ -3264,7 +3264,7 @@ struct qemu_argument arg_table[] = { ...@@ -3264,7 +3264,7 @@ struct qemu_argument arg_table[] = {
static void usage(void) static void usage(void)
{ {
struct qemu_argument *arginfo; const struct qemu_argument *arginfo;
int maxarglen; int maxarglen;
int maxenvlen; int maxenvlen;
...@@ -3330,7 +3330,7 @@ static int parse_args(int argc, char **argv) ...@@ -3330,7 +3330,7 @@ static int parse_args(int argc, char **argv)
{ {
const char *r; const char *r;
int optind; int optind;
struct qemu_argument *arginfo; const struct qemu_argument *arginfo;
for (arginfo = arg_table; arginfo->handle_opt != NULL; arginfo++) { for (arginfo = arg_table; arginfo->handle_opt != NULL; arginfo++) {
if (arginfo->env == NULL) { if (arginfo->env == NULL) {
...@@ -3519,7 +3519,10 @@ int main(int argc, char **argv, char **envp) ...@@ -3519,7 +3519,10 @@ int main(int argc, char **argv, char **envp)
guest_base = init_guest_space(guest_base, reserved_va, 0, guest_base = init_guest_space(guest_base, reserved_va, 0,
have_guest_base); have_guest_base);
if (guest_base == (unsigned long)-1) { if (guest_base == (unsigned long)-1) {
fprintf(stderr, "Unable to reserve guest address space\n"); fprintf(stderr, "Unable to reserve 0x%lx bytes of virtual address "
"space for use as guest address space (check your virtual "
"memory ulimit setting or reserve less using -R option)\n",
reserved_va);
exit(1); exit(1);
} }
......
...@@ -7025,15 +7025,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ...@@ -7025,15 +7025,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
tde = target_dirp; tde = target_dirp;
while (len > 0) { while (len > 0) {
reclen = de->d_reclen; reclen = de->d_reclen;
treclen = reclen - (2 * (sizeof(long) - sizeof(abi_long))); tnamelen = reclen - offsetof(struct linux_dirent, d_name);
assert(tnamelen >= 0);
treclen = tnamelen + offsetof(struct target_dirent, d_name);
assert(count1 + treclen <= count);
tde->d_reclen = tswap16(treclen); tde->d_reclen = tswap16(treclen);
tde->d_ino = tswapal(de->d_ino); tde->d_ino = tswapal(de->d_ino);
tde->d_off = tswapal(de->d_off); tde->d_off = tswapal(de->d_off);
tnamelen = treclen - (2 * sizeof(abi_long) + 2); memcpy(tde->d_name, de->d_name, tnamelen);
if (tnamelen > 256)
tnamelen = 256;
/* XXX: may not be correct */
pstrcpy(tde->d_name, tnamelen, de->d_name);
de = (struct linux_dirent *)((char *)de + reclen); de = (struct linux_dirent *)((char *)de + reclen);
len -= reclen; len -= reclen;
tde = (struct target_dirent *)((char *)tde + treclen); tde = (struct target_dirent *)((char *)tde + treclen);
......
...@@ -255,10 +255,10 @@ struct kernel_statfs { ...@@ -255,10 +255,10 @@ struct kernel_statfs {
}; };
struct target_dirent { struct target_dirent {
abi_long d_ino; abi_long d_ino;
abi_long d_off; abi_long d_off;
unsigned short d_reclen; unsigned short d_reclen;
char d_name[256]; /* We must not include limits.h! */ char d_name[];
}; };
struct target_dirent64 { struct target_dirent64 {
......
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