aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/compat.c20
-rw-r--r--fs/readdir.c8
-rw-r--r--fs/select.c8
3 files changed, 15 insertions, 21 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
diff --git a/fs/readdir.c b/fs/readdir.c
index 71bd12b50b4c..efe52e676577 100644
--- a/fs/readdir.c
+++ b/fs/readdir.c
@@ -4,6 +4,7 @@
4 * Copyright (C) 1995 Linus Torvalds 4 * Copyright (C) 1995 Linus Torvalds
5 */ 5 */
6 6
7#include <linux/kernel.h>
7#include <linux/module.h> 8#include <linux/module.h>
8#include <linux/time.h> 9#include <linux/time.h>
9#include <linux/mm.h> 10#include <linux/mm.h>
@@ -51,7 +52,6 @@ EXPORT_SYMBOL(vfs_readdir);
51 * case (the low-level handlers don't need to care about this). 52 * case (the low-level handlers don't need to care about this).
52 */ 53 */
53#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de))) 54#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
54#define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
55 55
56#ifdef __ARCH_WANT_OLD_READDIR 56#ifdef __ARCH_WANT_OLD_READDIR
57 57
@@ -146,7 +146,7 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
146 struct linux_dirent __user * dirent; 146 struct linux_dirent __user * dirent;
147 struct getdents_callback * buf = (struct getdents_callback *) __buf; 147 struct getdents_callback * buf = (struct getdents_callback *) __buf;
148 unsigned long d_ino; 148 unsigned long d_ino;
149 int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 2); 149 int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 2, sizeof(long));
150 150
151 buf->error = -EINVAL; /* only used if we fail.. */ 151 buf->error = -EINVAL; /* only used if we fail.. */
152 if (reclen > buf->count) 152 if (reclen > buf->count)
@@ -219,8 +219,6 @@ out:
219 return error; 219 return error;
220} 220}
221 221
222#define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
223
224struct getdents_callback64 { 222struct getdents_callback64 {
225 struct linux_dirent64 __user * current_dir; 223 struct linux_dirent64 __user * current_dir;
226 struct linux_dirent64 __user * previous; 224 struct linux_dirent64 __user * previous;
@@ -233,7 +231,7 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
233{ 231{
234 struct linux_dirent64 __user *dirent; 232 struct linux_dirent64 __user *dirent;
235 struct getdents_callback64 * buf = (struct getdents_callback64 *) __buf; 233 struct getdents_callback64 * buf = (struct getdents_callback64 *) __buf;
236 int reclen = ROUND_UP64(NAME_OFFSET(dirent) + namlen + 1); 234 int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1, sizeof(u64));
237 235
238 buf->error = -EINVAL; /* only used if we fail.. */ 236 buf->error = -EINVAL; /* only used if we fail.. */
239 if (reclen > buf->count) 237 if (reclen > buf->count)
diff --git a/fs/select.c b/fs/select.c
index f163db20eb5a..d86224154dec 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -14,6 +14,7 @@
14 * of fds to overcome nfds < 16390 descriptors limit (Tigran Aivazian). 14 * of fds to overcome nfds < 16390 descriptors limit (Tigran Aivazian).
15 */ 15 */
16 16
17#include <linux/kernel.h>
17#include <linux/syscalls.h> 18#include <linux/syscalls.h>
18#include <linux/module.h> 19#include <linux/module.h>
19#include <linux/slab.h> 20#include <linux/slab.h>
@@ -25,7 +26,6 @@
25 26
26#include <asm/uaccess.h> 27#include <asm/uaccess.h>
27 28
28#define ROUND_UP(x,y) (((x)+(y)-1)/(y))
29#define DEFAULT_POLLMASK (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM) 29#define DEFAULT_POLLMASK (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
30 30
31struct poll_table_page { 31struct poll_table_page {
@@ -398,7 +398,7 @@ asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp,
398 if ((u64)tv.tv_sec >= (u64)MAX_INT64_SECONDS) 398 if ((u64)tv.tv_sec >= (u64)MAX_INT64_SECONDS)
399 timeout = -1; /* infinite */ 399 timeout = -1; /* infinite */
400 else { 400 else {
401 timeout = ROUND_UP(tv.tv_usec, USEC_PER_SEC/HZ); 401 timeout = DIV_ROUND_UP(tv.tv_usec, USEC_PER_SEC/HZ);
402 timeout += tv.tv_sec * HZ; 402 timeout += tv.tv_sec * HZ;
403 } 403 }
404 } 404 }
@@ -453,7 +453,7 @@ asmlinkage long sys_pselect7(int n, fd_set __user *inp, fd_set __user *outp,
453 if ((u64)ts.tv_sec >= (u64)MAX_INT64_SECONDS) 453 if ((u64)ts.tv_sec >= (u64)MAX_INT64_SECONDS)
454 timeout = -1; /* infinite */ 454 timeout = -1; /* infinite */
455 else { 455 else {
456 timeout = ROUND_UP(ts.tv_nsec, NSEC_PER_SEC/HZ); 456 timeout = DIV_ROUND_UP(ts.tv_nsec, NSEC_PER_SEC/HZ);
457 timeout += ts.tv_sec * HZ; 457 timeout += ts.tv_sec * HZ;
458 } 458 }
459 } 459 }
@@ -775,7 +775,7 @@ asmlinkage long sys_ppoll(struct pollfd __user *ufds, unsigned int nfds,
775 if ((u64)ts.tv_sec >= (u64)MAX_INT64_SECONDS) 775 if ((u64)ts.tv_sec >= (u64)MAX_INT64_SECONDS)
776 timeout = -1; /* infinite */ 776 timeout = -1; /* infinite */
777 else { 777 else {
778 timeout = ROUND_UP(ts.tv_nsec, NSEC_PER_SEC/HZ); 778 timeout = DIV_ROUND_UP(ts.tv_nsec, NSEC_PER_SEC/HZ);
779 timeout += ts.tv_sec * HZ; 779 timeout += ts.tv_sec * HZ;
780 } 780 }
781 } 781 }