aboutsummaryrefslogtreecommitdiffstats
path: root/fs/compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/compat.c')
-rw-r--r--fs/compat.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/fs/compat.c b/fs/compat.c
index 72e5e6923828..a32e2ae737fb 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -15,6 +15,7 @@
15 * published by the Free Software Foundation. 15 * published by the Free Software Foundation.
16 */ 16 */
17 17
18#include <linux/kernel.h>
18#include <linux/linkage.h> 19#include <linux/linkage.h>
19#include <linux/compat.h> 20#include <linux/compat.h>
20#include <linux/errno.h> 21#include <linux/errno.h>
@@ -902,8 +903,6 @@ asmlinkage long compat_sys_mount(char __user * dev_name, char __user * dir_name,
902} 903}
903 904
904#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de))) 905#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
905#define COMPAT_ROUND_UP(x) (((x)+sizeof(compat_long_t)-1) & \
906 ~(sizeof(compat_long_t)-1))
907 906
908struct compat_old_linux_dirent { 907struct compat_old_linux_dirent {
909 compat_ulong_t d_ino; 908 compat_ulong_t d_ino;
@@ -991,7 +990,7 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
991 struct compat_linux_dirent __user * dirent; 990 struct compat_linux_dirent __user * dirent;
992 struct compat_getdents_callback *buf = __buf; 991 struct compat_getdents_callback *buf = __buf;
993 compat_ulong_t d_ino; 992 compat_ulong_t d_ino;
994 int reclen = COMPAT_ROUND_UP(NAME_OFFSET(dirent) + namlen + 2); 993 int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 2, sizeof(compat_long_t));
995 994
996 buf->error = -EINVAL; /* only used if we fail.. */ 995 buf->error = -EINVAL; /* only used if we fail.. */
997 if (reclen > buf->count) 996 if (reclen > buf->count)
@@ -1066,7 +1065,6 @@ out:
1066} 1065}
1067 1066
1068#ifndef __ARCH_OMIT_COMPAT_SYS_GETDENTS64 1067#ifndef __ARCH_OMIT_COMPAT_SYS_GETDENTS64
1069#define COMPAT_ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
1070 1068
1071struct compat_getdents_callback64 { 1069struct compat_getdents_callback64 {
1072 struct linux_dirent64 __user *current_dir; 1070 struct linux_dirent64 __user *current_dir;
@@ -1081,7 +1079,7 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
1081 struct linux_dirent64 __user *dirent; 1079 struct linux_dirent64 __user *dirent;
1082 struct compat_getdents_callback64 *buf = __buf; 1080 struct compat_getdents_callback64 *buf = __buf;
1083 int jj = NAME_OFFSET(dirent); 1081 int jj = NAME_OFFSET(dirent);
1084 int reclen = COMPAT_ROUND_UP64(jj + namlen + 1); 1082 int reclen = ALIGN(jj + namlen + 1, sizeof(u64));
1085 u64 off; 1083 u64 off;
1086 1084
1087 buf->error = -EINVAL; /* only used if we fail.. */ 1085 buf->error = -EINVAL; /* only used if we fail.. */
@@ -1594,8 +1592,6 @@ out_ret:
1594 1592
1595#define __COMPAT_NFDBITS (8 * sizeof(compat_ulong_t)) 1593#define __COMPAT_NFDBITS (8 * sizeof(compat_ulong_t))
1596 1594
1597#define ROUND_UP(x,y) (((x)+(y)-1)/(y))
1598
1599/* 1595/*
1600 * Ooo, nasty. We need here to frob 32-bit unsigned longs to 1596 * Ooo, nasty. We need here to frob 32-bit unsigned longs to
1601 * 64-bit unsigned longs. 1597 * 64-bit unsigned longs.
@@ -1604,7 +1600,7 @@ static
1604int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset, 1600int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1605 unsigned long *fdset) 1601 unsigned long *fdset)
1606{ 1602{
1607 nr = ROUND_UP(nr, __COMPAT_NFDBITS); 1603 nr = DIV_ROUND_UP(nr, __COMPAT_NFDBITS);
1608 if (ufdset) { 1604 if (ufdset) {
1609 unsigned long odd; 1605 unsigned long odd;
1610 1606
@@ -1638,7 +1634,7 @@ int compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1638 unsigned long *fdset) 1634 unsigned long *fdset)
1639{ 1635{
1640 unsigned long odd; 1636 unsigned long odd;
1641 nr = ROUND_UP(nr, __COMPAT_NFDBITS); 1637 nr = DIV_ROUND_UP(nr, __COMPAT_NFDBITS);
1642 1638
1643 if (!ufdset) 1639 if (!ufdset)
1644 return 0; 1640 return 0;
@@ -1760,7 +1756,7 @@ asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
1760 if ((u64)tv.tv_sec >= (u64)MAX_INT64_SECONDS) 1756 if ((u64)tv.tv_sec >= (u64)MAX_INT64_SECONDS)
1761 timeout = -1; /* infinite */ 1757 timeout = -1; /* infinite */
1762 else { 1758 else {
1763 timeout = ROUND_UP(tv.tv_usec, 1000000/HZ); 1759 timeout = DIV_ROUND_UP(tv.tv_usec, 1000000/HZ);
1764 timeout += tv.tv_sec * HZ; 1760 timeout += tv.tv_sec * HZ;
1765 } 1761 }
1766 } 1762 }
@@ -1828,7 +1824,7 @@ asmlinkage long compat_sys_pselect7(int n, compat_ulong_t __user *inp,
1828 do { 1824 do {
1829 if (tsp) { 1825 if (tsp) {
1830 if ((unsigned long)ts.tv_sec < MAX_SELECT_SECONDS) { 1826 if ((unsigned long)ts.tv_sec < MAX_SELECT_SECONDS) {
1831 timeout = ROUND_UP(ts.tv_nsec, 1000000000/HZ); 1827 timeout = DIV_ROUND_UP(ts.tv_nsec, 1000000000/HZ);
1832 timeout += ts.tv_sec * (unsigned long)HZ; 1828 timeout += ts.tv_sec * (unsigned long)HZ;
1833 ts.tv_sec = 0; 1829 ts.tv_sec = 0;
1834 ts.tv_nsec = 0; 1830 ts.tv_nsec = 0;
@@ -1924,7 +1920,7 @@ asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
1924 /* We assume that ts.tv_sec is always lower than 1920 /* We assume that ts.tv_sec is always lower than
1925 the number of seconds that can be expressed in 1921 the number of seconds that can be expressed in
1926 an s64. Otherwise the compiler bitches at us */ 1922 an s64. Otherwise the compiler bitches at us */
1927 timeout = ROUND_UP(ts.tv_nsec, 1000000000/HZ); 1923 timeout = DIV_ROUND_UP(ts.tv_nsec, 1000000000/HZ);
1928 timeout += ts.tv_sec * HZ; 1924 timeout += ts.tv_sec * HZ;
1929 } 1925 }
1930 1926