]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/ia64/ia32/sys_ia32.c
compat: move cp_compat_stat to common code
[linux-2.6-omap-h63xx.git] / arch / ia64 / ia32 / sys_ia32.c
index 465116aecb85adf03880caf8285abeecc8c300e3..2362a8eefb309745a1312d20f8c1a1325442bfbd 100644 (file)
@@ -118,41 +118,6 @@ sys32_execve (char __user *name, compat_uptr_t __user *argv, compat_uptr_t __use
        return error;
 }
 
-int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf)
-{
-       compat_ino_t ino;
-       int err;
-
-       if ((u64) stat->size > MAX_NON_LFS ||
-           !old_valid_dev(stat->dev) ||
-           !old_valid_dev(stat->rdev))
-               return -EOVERFLOW;
-
-       ino = stat->ino;
-       if (sizeof(ino) < sizeof(stat->ino) && ino != stat->ino)
-               return -EOVERFLOW;
-
-       if (clear_user(ubuf, sizeof(*ubuf)))
-               return -EFAULT;
-
-       err  = __put_user(old_encode_dev(stat->dev), &ubuf->st_dev);
-       err |= __put_user(ino, &ubuf->st_ino);
-       err |= __put_user(stat->mode, &ubuf->st_mode);
-       err |= __put_user(stat->nlink, &ubuf->st_nlink);
-       err |= __put_user(high2lowuid(stat->uid), &ubuf->st_uid);
-       err |= __put_user(high2lowgid(stat->gid), &ubuf->st_gid);
-       err |= __put_user(old_encode_dev(stat->rdev), &ubuf->st_rdev);
-       err |= __put_user(stat->size, &ubuf->st_size);
-       err |= __put_user(stat->atime.tv_sec, &ubuf->st_atime);
-       err |= __put_user(stat->atime.tv_nsec, &ubuf->st_atime_nsec);
-       err |= __put_user(stat->mtime.tv_sec, &ubuf->st_mtime);
-       err |= __put_user(stat->mtime.tv_nsec, &ubuf->st_mtime_nsec);
-       err |= __put_user(stat->ctime.tv_sec, &ubuf->st_ctime);
-       err |= __put_user(stat->ctime.tv_nsec, &ubuf->st_ctime_nsec);
-       err |= __put_user(stat->blksize, &ubuf->st_blksize);
-       err |= __put_user(stat->blocks, &ubuf->st_blocks);
-       return err;
-}
 
 #if PAGE_SHIFT > IA32_PAGE_SHIFT
 
@@ -1210,138 +1175,6 @@ sys32_settimeofday (struct compat_timeval __user *tv, struct timezone __user *tz
        return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
 }
 
-struct getdents32_callback {
-       struct compat_dirent __user *current_dir;
-       struct compat_dirent __user *previous;
-       int count;
-       int error;
-};
-
-struct readdir32_callback {
-       struct old_linux32_dirent __user * dirent;
-       int count;
-};
-
-static int
-filldir32 (void *__buf, const char *name, int namlen, loff_t offset, u64 ino,
-          unsigned int d_type)
-{
-       struct compat_dirent __user * dirent;
-       struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
-       int reclen = ROUND_UP(offsetof(struct compat_dirent, d_name) + 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;
-       buf->error = -EFAULT;   /* only used if we fail.. */
-       dirent = buf->previous;
-       if (dirent)
-               if (put_user(offset, &dirent->d_off))
-                       return -EFAULT;
-       dirent = buf->current_dir;
-       buf->previous = dirent;
-       if (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))
-               return -EFAULT;
-       dirent = (struct compat_dirent __user *) ((char __user *) dirent + reclen);
-       buf->current_dir = dirent;
-       buf->count -= reclen;
-       return 0;
-}
-
-asmlinkage long
-sys32_getdents (unsigned int fd, struct compat_dirent __user *dirent, unsigned int count)
-{
-       struct file * file;
-       struct compat_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 = 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;
-       if (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 -EFAULT;
-       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;
-}
-
 struct sel_arg_struct {
        unsigned int n;
        unsigned int inp;