]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/parisc/hpux/fs.c
fix typo in arch/parisc/hpux/fs.c
[linux-2.6-omap-h63xx.git] / arch / parisc / hpux / fs.c
index c7a81a2c014c98657ccb52357c315a2cfa2103f0..12c04c5e558be01c1a219214721bfbd1901c1b4e 100644 (file)
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/file.h>
-#include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/ptrace.h>
 #include <asm/errno.h>
@@ -70,7 +71,6 @@ struct getdents_callback {
 };
 
 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
-#define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
 
 static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
                u64 ino, unsigned d_type)
@@ -78,32 +78,37 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
        struct hpux_dirent __user * dirent;
        struct getdents_callback * buf = (struct getdents_callback *) __buf;
        ino_t d_ino;
-       int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
+       int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1, sizeof(long));
 
        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)
+       if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) {
+               buf->error = -EOVERFLOW;
                return -EOVERFLOW;
+       }
        dirent = buf->previous;
        if (dirent)
-               put_user(offset, &dirent->d_off);
+               if (put_user(offset, &dirent->d_off))
+                       goto Efault;
        dirent = buf->current_dir;
+       if (put_user(d_ino, &dirent->d_ino) ||
+           put_user(reclen, &dirent->d_reclen) ||
+           put_user(namlen, &dirent->d_namlen) ||
+           copy_to_user(dirent->d_name, name, namlen) ||
+           put_user(0, dirent->d_name + namlen))
+               goto Efault;
        buf->previous = dirent;
-       put_user(d_ino, &dirent->d_ino);
-       put_user(reclen, &dirent->d_reclen);
-       put_user(namlen, &dirent->d_namlen);
-       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->current_dir = (void __user *)dirent + reclen;
        buf->count -= reclen;
        return 0;
+Efault:
+       buf->error = -EFAULT;
+       return -EFAULT;
 }
 
 #undef NAME_OFFSET
-#undef ROUND_UP
 
 int hpux_getdents(unsigned int fd, struct hpux_dirent __user *dirent, unsigned int count)
 {
@@ -127,8 +132,10 @@ int hpux_getdents(unsigned int fd, struct hpux_dirent __user *dirent, unsigned i
        error = buf.error;
        lastdirent = buf.previous;
        if (lastdirent) {
-               put_user(file->f_pos, &lastdirent->d_off);
-               error = count - buf.count;
+               if (put_user(file->f_pos, &lastdirent->d_off))
+                       error = -EFAULT;
+               else
+                       error = count - buf.count;
        }
 
 out_putf: