Commit 8baa2cda authored by Stephen Rothwell's avatar Stephen Rothwell Committed by David S. Miller

[PATCH] compat_flock: generic

This moves struct flock32 to struct compat_flock and consolidates the
functions used to copy it to/from user mode.

This is just the generic part - subarchitectures will follow.
parent 24b79d7c
......@@ -16,6 +16,7 @@
#include <linux/errno.h>
#include <linux/time.h>
#include <linux/fs.h>
#include <linux/fcntl.h>
#include <asm/uaccess.h>
......@@ -70,3 +71,33 @@ asmlinkage long compat_sys_newfstat(unsigned int fd,
error = cp_compat_stat(&stat, statbuf);
return error;
}
int get_compat_flock(struct flock *kfl, struct compat_flock *ufl)
{
int err;
if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)))
return -EFAULT;
err = __get_user(kfl->l_type, &ufl->l_type);
err |= __get_user(kfl->l_whence, &ufl->l_whence);
err |= __get_user(kfl->l_start, &ufl->l_start);
err |= __get_user(kfl->l_len, &ufl->l_len);
err |= __get_user(kfl->l_pid, &ufl->l_pid);
return err;
}
int put_compat_flock(struct flock *kfl, struct compat_flock *ufl)
{
int err;
if (!access_ok(VERIFY_WRITE, ufl, sizeof(*ufl)))
return -EFAULT;
err = __put_user(kfl->l_type, &ufl->l_type);
err |= __put_user(kfl->l_whence, &ufl->l_whence);
err |= __put_user(kfl->l_start, &ufl->l_start);
err |= __put_user(kfl->l_len, &ufl->l_len);
err |= __put_user(kfl->l_pid, &ufl->l_pid);
return err;
}
......@@ -10,6 +10,7 @@
#include <linux/stat.h>
#include <linux/param.h> /* for HZ */
#include <linux/fcntl.h> /* for struct flock */
#include <asm/compat.h>
#define compat_jiffies_to_clock_t(x) \
......@@ -33,6 +34,8 @@ struct compat_tms {
};
extern int cp_compat_stat(struct kstat *, struct compat_stat *);
extern int get_compat_flock(struct flock *, struct compat_flock *);
extern int put_compat_flock(struct flock *, struct compat_flock *);
#endif /* CONFIG_COMPAT */
#endif /* _LINUX_COMPAT_H */
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