aboutsummaryrefslogtreecommitdiffstats
path: root/fs/compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/compat.c')
-rw-r--r--fs/compat.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/fs/compat.c b/fs/compat.c
index 6490d2134ff3..718c7062aec1 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -8,13 +8,14 @@
8 * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com) 8 * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
9 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be) 9 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
10 * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs 10 * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs
11 * Copyright (C) 2003 Pavel Machek (pavel@suse.cz) 11 * Copyright (C) 2003 Pavel Machek (pavel@ucw.cz)
12 * 12 *
13 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as 14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation. 15 * published by the Free Software Foundation.
16 */ 16 */
17 17
18#include <linux/stddef.h>
18#include <linux/kernel.h> 19#include <linux/kernel.h>
19#include <linux/linkage.h> 20#include <linux/linkage.h>
20#include <linux/compat.h> 21#include <linux/compat.h>
@@ -76,7 +77,8 @@ int compat_printk(const char *fmt, ...)
76 * Not all architectures have sys_utime, so implement this in terms 77 * Not all architectures have sys_utime, so implement this in terms
77 * of sys_utimes. 78 * of sys_utimes.
78 */ 79 */
79asmlinkage long compat_sys_utime(char __user *filename, struct compat_utimbuf __user *t) 80asmlinkage long compat_sys_utime(const char __user *filename,
81 struct compat_utimbuf __user *t)
80{ 82{
81 struct timespec tv[2]; 83 struct timespec tv[2];
82 84
@@ -90,7 +92,7 @@ asmlinkage long compat_sys_utime(char __user *filename, struct compat_utimbuf __
90 return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0); 92 return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0);
91} 93}
92 94
93asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename, struct compat_timespec __user *t, int flags) 95asmlinkage long compat_sys_utimensat(unsigned int dfd, const char __user *filename, struct compat_timespec __user *t, int flags)
94{ 96{
95 struct timespec tv[2]; 97 struct timespec tv[2];
96 98
@@ -105,7 +107,7 @@ asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename, st
105 return do_utimes(dfd, filename, t ? tv : NULL, flags); 107 return do_utimes(dfd, filename, t ? tv : NULL, flags);
106} 108}
107 109
108asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename, struct compat_timeval __user *t) 110asmlinkage long compat_sys_futimesat(unsigned int dfd, const char __user *filename, struct compat_timeval __user *t)
109{ 111{
110 struct timespec tv[2]; 112 struct timespec tv[2];
111 113
@@ -124,7 +126,7 @@ asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename, st
124 return do_utimes(dfd, filename, t ? tv : NULL, 0); 126 return do_utimes(dfd, filename, t ? tv : NULL, 0);
125} 127}
126 128
127asmlinkage long compat_sys_utimes(char __user *filename, struct compat_timeval __user *t) 129asmlinkage long compat_sys_utimes(const char __user *filename, struct compat_timeval __user *t)
128{ 130{
129 return compat_sys_futimesat(AT_FDCWD, filename, t); 131 return compat_sys_futimesat(AT_FDCWD, filename, t);
130} 132}
@@ -168,7 +170,7 @@ static int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf)
168 return err; 170 return err;
169} 171}
170 172
171asmlinkage long compat_sys_newstat(char __user * filename, 173asmlinkage long compat_sys_newstat(const char __user * filename,
172 struct compat_stat __user *statbuf) 174 struct compat_stat __user *statbuf)
173{ 175{
174 struct kstat stat; 176 struct kstat stat;
@@ -180,7 +182,7 @@ asmlinkage long compat_sys_newstat(char __user * filename,
180 return cp_compat_stat(&stat, statbuf); 182 return cp_compat_stat(&stat, statbuf);
181} 183}
182 184
183asmlinkage long compat_sys_newlstat(char __user * filename, 185asmlinkage long compat_sys_newlstat(const char __user * filename,
184 struct compat_stat __user *statbuf) 186 struct compat_stat __user *statbuf)
185{ 187{
186 struct kstat stat; 188 struct kstat stat;
@@ -193,7 +195,8 @@ asmlinkage long compat_sys_newlstat(char __user * filename,
193} 195}
194 196
195#ifndef __ARCH_WANT_STAT64 197#ifndef __ARCH_WANT_STAT64
196asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user *filename, 198asmlinkage long compat_sys_newfstatat(unsigned int dfd,
199 const char __user *filename,
197 struct compat_stat __user *statbuf, int flag) 200 struct compat_stat __user *statbuf, int flag)
198{ 201{
199 struct kstat stat; 202 struct kstat stat;
@@ -266,7 +269,7 @@ asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_sta
266 error = user_path(pathname, &path); 269 error = user_path(pathname, &path);
267 if (!error) { 270 if (!error) {
268 struct kstatfs tmp; 271 struct kstatfs tmp;
269 error = vfs_statfs(path.dentry, &tmp); 272 error = vfs_statfs(&path, &tmp);
270 if (!error) 273 if (!error)
271 error = put_compat_statfs(buf, &tmp); 274 error = put_compat_statfs(buf, &tmp);
272 path_put(&path); 275 path_put(&path);
@@ -284,7 +287,7 @@ asmlinkage long compat_sys_fstatfs(unsigned int fd, struct compat_statfs __user
284 file = fget(fd); 287 file = fget(fd);
285 if (!file) 288 if (!file)
286 goto out; 289 goto out;
287 error = vfs_statfs(file->f_path.dentry, &tmp); 290 error = vfs_statfs(&file->f_path, &tmp);
288 if (!error) 291 if (!error)
289 error = put_compat_statfs(buf, &tmp); 292 error = put_compat_statfs(buf, &tmp);
290 fput(file); 293 fput(file);
@@ -334,7 +337,7 @@ asmlinkage long compat_sys_statfs64(const char __user *pathname, compat_size_t s
334 error = user_path(pathname, &path); 337 error = user_path(pathname, &path);
335 if (!error) { 338 if (!error) {
336 struct kstatfs tmp; 339 struct kstatfs tmp;
337 error = vfs_statfs(path.dentry, &tmp); 340 error = vfs_statfs(&path, &tmp);
338 if (!error) 341 if (!error)
339 error = put_compat_statfs64(buf, &tmp); 342 error = put_compat_statfs64(buf, &tmp);
340 path_put(&path); 343 path_put(&path);
@@ -355,7 +358,7 @@ asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct c
355 file = fget(fd); 358 file = fget(fd);
356 if (!file) 359 if (!file)
357 goto out; 360 goto out;
358 error = vfs_statfs(file->f_path.dentry, &tmp); 361 error = vfs_statfs(&file->f_path, &tmp);
359 if (!error) 362 if (!error)
360 error = put_compat_statfs64(buf, &tmp); 363 error = put_compat_statfs64(buf, &tmp);
361 fput(file); 364 fput(file);
@@ -378,7 +381,7 @@ asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u)
378 sb = user_get_super(new_decode_dev(dev)); 381 sb = user_get_super(new_decode_dev(dev));
379 if (!sb) 382 if (!sb)
380 return -EINVAL; 383 return -EINVAL;
381 err = vfs_statfs(sb->s_root, &sbuf); 384 err = statfs_by_dentry(sb->s_root, &sbuf);
382 drop_super(sb); 385 drop_super(sb);
383 if (err) 386 if (err)
384 return err; 387 return err;
@@ -836,9 +839,10 @@ static int do_nfs4_super_data_conv(void *raw_data)
836#define NCPFS_NAME "ncpfs" 839#define NCPFS_NAME "ncpfs"
837#define NFS4_NAME "nfs4" 840#define NFS4_NAME "nfs4"
838 841
839asmlinkage long compat_sys_mount(char __user * dev_name, char __user * dir_name, 842asmlinkage long compat_sys_mount(const char __user * dev_name,
840 char __user * type, unsigned long flags, 843 const char __user * dir_name,
841 void __user * data) 844 const char __user * type, unsigned long flags,
845 const void __user * data)
842{ 846{
843 char *kernel_type; 847 char *kernel_type;
844 unsigned long data_page; 848 unsigned long data_page;
@@ -891,8 +895,6 @@ asmlinkage long compat_sys_mount(char __user * dev_name, char __user * dir_name,
891 return retval; 895 return retval;
892} 896}
893 897
894#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
895
896struct compat_old_linux_dirent { 898struct compat_old_linux_dirent {
897 compat_ulong_t d_ino; 899 compat_ulong_t d_ino;
898 compat_ulong_t d_offset; 900 compat_ulong_t d_offset;
@@ -981,7 +983,8 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
981 struct compat_linux_dirent __user * dirent; 983 struct compat_linux_dirent __user * dirent;
982 struct compat_getdents_callback *buf = __buf; 984 struct compat_getdents_callback *buf = __buf;
983 compat_ulong_t d_ino; 985 compat_ulong_t d_ino;
984 int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 2, sizeof(compat_long_t)); 986 int reclen = ALIGN(offsetof(struct compat_linux_dirent, d_name) +
987 namlen + 2, sizeof(compat_long_t));
985 988
986 buf->error = -EINVAL; /* only used if we fail.. */ 989 buf->error = -EINVAL; /* only used if we fail.. */
987 if (reclen > buf->count) 990 if (reclen > buf->count)
@@ -1068,8 +1071,8 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
1068{ 1071{
1069 struct linux_dirent64 __user *dirent; 1072 struct linux_dirent64 __user *dirent;
1070 struct compat_getdents_callback64 *buf = __buf; 1073 struct compat_getdents_callback64 *buf = __buf;
1071 int jj = NAME_OFFSET(dirent); 1074 int reclen = ALIGN(offsetof(struct linux_dirent64, d_name) + namlen + 1,
1072 int reclen = ALIGN(jj + namlen + 1, sizeof(u64)); 1075 sizeof(u64));
1073 u64 off; 1076 u64 off;
1074 1077
1075 buf->error = -EINVAL; /* only used if we fail.. */ 1078 buf->error = -EINVAL; /* only used if we fail.. */
@@ -1193,11 +1196,10 @@ out:
1193 if (iov != iovstack) 1196 if (iov != iovstack)
1194 kfree(iov); 1197 kfree(iov);
1195 if ((ret + (type == READ)) > 0) { 1198 if ((ret + (type == READ)) > 0) {
1196 struct dentry *dentry = file->f_path.dentry;
1197 if (type == READ) 1199 if (type == READ)
1198 fsnotify_access(dentry); 1200 fsnotify_access(file);
1199 else 1201 else
1200 fsnotify_modify(dentry); 1202 fsnotify_modify(file);
1201 } 1203 }
1202 return ret; 1204 return ret;
1203} 1205}