compat.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * 32 bit compatibility code for System V IPC
  3. *
  4. * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  5. * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
  6. * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com>
  7. * Copyright (C) 2000 VA Linux Co
  8. * Copyright (C) 2000 Don Dugger <n0ano@valinux.com>
  9. * Copyright (C) 2000 Hewlett-Packard Co.
  10. * Copyright (C) 2000 David Mosberger-Tang <davidm@hpl.hp.com>
  11. * Copyright (C) 2000 Gerhard Tonn (ton@de.ibm.com)
  12. * Copyright (C) 2000-2002 Andi Kleen, SuSE Labs (x86-64 port)
  13. * Copyright (C) 2000 Silicon Graphics, Inc.
  14. * Copyright (C) 2001 IBM
  15. * Copyright (C) 2004 IBM Deutschland Entwicklung GmbH, IBM Corporation
  16. * Copyright (C) 2004 Arnd Bergmann (arnd@arndb.de)
  17. *
  18. * This code is collected from the versions for sparc64, mips64, s390x, ia64,
  19. * ppc64 and x86_64, all of which are based on the original sparc64 version
  20. * by Jakub Jelinek.
  21. *
  22. */
  23. #include <linux/compat.h>
  24. #include <linux/errno.h>
  25. #include <linux/highuid.h>
  26. #include <linux/init.h>
  27. #include <linux/msg.h>
  28. #include <linux/shm.h>
  29. #include <linux/syscalls.h>
  30. #include <linux/ptrace.h>
  31. #include <linux/mutex.h>
  32. #include <linux/uaccess.h>
  33. #include "util.h"
  34. int get_compat_ipc64_perm(struct ipc64_perm *to,
  35. struct compat_ipc64_perm __user *from)
  36. {
  37. struct compat_ipc64_perm v;
  38. if (copy_from_user(&v, from, sizeof(v)))
  39. return -EFAULT;
  40. to->uid = v.uid;
  41. to->gid = v.gid;
  42. to->mode = v.mode;
  43. return 0;
  44. }
  45. int get_compat_ipc_perm(struct ipc64_perm *to,
  46. struct compat_ipc_perm __user *from)
  47. {
  48. struct compat_ipc_perm v;
  49. if (copy_from_user(&v, from, sizeof(v)))
  50. return -EFAULT;
  51. to->uid = v.uid;
  52. to->gid = v.gid;
  53. to->mode = v.mode;
  54. return 0;
  55. }
  56. void to_compat_ipc64_perm(struct compat_ipc64_perm *to, struct ipc64_perm *from)
  57. {
  58. to->key = from->key;
  59. to->uid = from->uid;
  60. to->gid = from->gid;
  61. to->cuid = from->cuid;
  62. to->cgid = from->cgid;
  63. to->mode = from->mode;
  64. to->seq = from->seq;
  65. }
  66. void to_compat_ipc_perm(struct compat_ipc_perm *to, struct ipc64_perm *from)
  67. {
  68. to->key = from->key;
  69. SET_UID(to->uid, from->uid);
  70. SET_GID(to->gid, from->gid);
  71. SET_UID(to->cuid, from->cuid);
  72. SET_GID(to->cgid, from->cgid);
  73. to->mode = from->mode;
  74. to->seq = from->seq;
  75. }