]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/parisc/kernel/sys_parisc32.c
compat: move cp_compat_stat to common code
[linux-2.6-omap-h63xx.git] / arch / parisc / kernel / sys_parisc32.c
index bb23ff71c28e31f7f4fae940e701710dbbbabd06..2c3af17e049cb4c4bcc6633d22faab2a0097ce44 100644 (file)
@@ -49,7 +49,6 @@
 
 #include <asm/types.h>
 #include <asm/uaccess.h>
-#include <asm/semaphore.h>
 #include <asm/mmu_context.h>
 
 #include "sys32.h"
@@ -238,194 +237,6 @@ int sys32_settimeofday(struct compat_timeval __user *tv, struct timezone __user
        return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
 }
 
-int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
-{
-       compat_ino_t ino;
-       int err;
-
-       if (stat->size > MAX_NON_LFS || !new_valid_dev(stat->dev) ||
-           !new_valid_dev(stat->rdev))
-               return -EOVERFLOW;
-
-       ino = stat->ino;
-       if (sizeof(ino) < sizeof(stat->ino) && ino != stat->ino)
-               return -EOVERFLOW;
-
-       err  = put_user(new_encode_dev(stat->dev), &statbuf->st_dev);
-       err |= put_user(ino, &statbuf->st_ino);
-       err |= put_user(stat->mode, &statbuf->st_mode);
-       err |= put_user(stat->nlink, &statbuf->st_nlink);
-       err |= put_user(0, &statbuf->st_reserved1);
-       err |= put_user(0, &statbuf->st_reserved2);
-       err |= put_user(new_encode_dev(stat->rdev), &statbuf->st_rdev);
-       err |= put_user(stat->size, &statbuf->st_size);
-       err |= put_user(stat->atime.tv_sec, &statbuf->st_atime);
-       err |= put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec);
-       err |= put_user(stat->mtime.tv_sec, &statbuf->st_mtime);
-       err |= put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec);
-       err |= put_user(stat->ctime.tv_sec, &statbuf->st_ctime);
-       err |= put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec);
-       err |= put_user(stat->blksize, &statbuf->st_blksize);
-       err |= put_user(stat->blocks, &statbuf->st_blocks);
-       err |= put_user(0, &statbuf->__unused1);
-       err |= put_user(0, &statbuf->__unused2);
-       err |= put_user(0, &statbuf->__unused3);
-       err |= put_user(0, &statbuf->__unused4);
-       err |= put_user(0, &statbuf->__unused5);
-       err |= put_user(0, &statbuf->st_fstype); /* not avail */
-       err |= put_user(0, &statbuf->st_realdev); /* not avail */
-       err |= put_user(0, &statbuf->st_basemode); /* not avail */
-       err |= put_user(0, &statbuf->st_spareshort);
-       err |= put_user(stat->uid, &statbuf->st_uid);
-       err |= put_user(stat->gid, &statbuf->st_gid);
-       err |= put_user(0, &statbuf->st_spare4[0]);
-       err |= put_user(0, &statbuf->st_spare4[1]);
-       err |= put_user(0, &statbuf->st_spare4[2]);
-
-       return err;
-}
-
-struct linux32_dirent {
-       u32             d_ino;
-       compat_off_t    d_off;
-       u16             d_reclen;
-       char            d_name[1];
-};
-
-struct old_linux32_dirent {
-       u32     d_ino;
-       u32     d_offset;
-       u16     d_namlen;
-       char    d_name[1];
-};
-
-struct getdents32_callback {
-       struct linux32_dirent __user * current_dir;
-       struct linux32_dirent __user * previous;
-       int count;
-       int error;
-};
-
-struct readdir32_callback {
-       struct old_linux32_dirent __user * dirent;
-       int count;
-};
-
-#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
-static int filldir32 (void *__buf, const char *name, int namlen,
-                       loff_t offset, u64 ino, unsigned int d_type)
-{
-       struct linux32_dirent __user * dirent;
-       struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
-       int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1, 4);
-       u32 d_ino;
-
-       buf->error = -EINVAL;   /* only used if we fail.. */
-       if (reclen > buf->count)
-               return -EINVAL;
-       d_ino = ino;
-       if (sizeof(d_ino) < sizeof(ino) && d_ino != ino)
-               return -EOVERFLOW;
-       dirent = buf->previous;
-       if (dirent)
-               put_user(offset, &dirent->d_off);
-       dirent = buf->current_dir;
-       buf->previous = dirent;
-       put_user(d_ino, &dirent->d_ino);
-       put_user(reclen, &dirent->d_reclen);
-       copy_to_user(dirent->d_name, name, namlen);
-       put_user(0, dirent->d_name + namlen);
-       dirent = ((void __user *)dirent) + reclen;
-       buf->current_dir = dirent;
-       buf->count -= reclen;
-       return 0;
-}
-
-asmlinkage long
-sys32_getdents (unsigned int fd, void __user * dirent, unsigned int count)
-{
-       struct file * file;
-       struct linux32_dirent __user * lastdirent;
-       struct getdents32_callback buf;
-       int error;
-
-       error = -EFAULT;
-       if (!access_ok(VERIFY_WRITE, dirent, count))
-               goto out;
-
-       error = -EBADF;
-       file = fget(fd);
-       if (!file)
-               goto out;
-
-       buf.current_dir = (struct linux32_dirent __user *) dirent;
-       buf.previous = NULL;
-       buf.count = count;
-       buf.error = 0;
-
-       error = vfs_readdir(file, filldir32, &buf);
-       if (error < 0)
-               goto out_putf;
-       error = buf.error;
-       lastdirent = buf.previous;
-       if (lastdirent) {
-               if (put_user(file->f_pos, &lastdirent->d_off))
-                       error = -EFAULT;
-               else
-                       error = count - buf.count;
-       }
-
-out_putf:
-       fput(file);
-out:
-       return error;
-}
-
-static int fillonedir32(void * __buf, const char * name, int namlen,
-                       loff_t offset, u64 ino, unsigned int d_type)
-{
-       struct readdir32_callback * buf = (struct readdir32_callback *) __buf;
-       struct old_linux32_dirent __user * dirent;
-       u32 d_ino;
-
-       if (buf->count)
-               return -EINVAL;
-       d_ino = ino;
-       if (sizeof(d_ino) < sizeof(ino) && d_ino != ino)
-               return -EOVERFLOW;
-       buf->count++;
-       dirent = buf->dirent;
-       put_user(d_ino, &dirent->d_ino);
-       put_user(offset, &dirent->d_offset);
-       put_user(namlen, &dirent->d_namlen);
-       copy_to_user(dirent->d_name, name, namlen);
-       put_user(0, dirent->d_name + namlen);
-       return 0;
-}
-
-asmlinkage long
-sys32_readdir (unsigned int fd, void __user * dirent, unsigned int count)
-{
-       int error;
-       struct file * file;
-       struct readdir32_callback buf;
-
-       error = -EBADF;
-       file = fget(fd);
-       if (!file)
-               goto out;
-
-       buf.count = 0;
-       buf.dirent = dirent;
-
-       error = vfs_readdir(file, fillonedir32, &buf);
-       if (error >= 0)
-               error = buf.count;
-       fput(file);
-out:
-       return error;
-}
-
 /*** copied from mips64 ***/
 /*
  * Ooo, nasty.  We need here to frob 32-bit unsigned longs to
@@ -614,3 +425,10 @@ long sys32_lookup_dcookie(u32 cookie_high, u32 cookie_low, char __user *buf,
        return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low,
                                  buf, len);
 }
+
+asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
+                               u32 lenhi, u32 lenlo)
+{
+        return sys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
+                             ((loff_t)lenhi << 32) | lenlo);
+}