patch-2.3.31 linux/fs/open.c
Next file: linux/include/asm-alpha/system.h
Previous file: linux/fs/nls/nls_koi8-r.c
Back to the patch index
Back to the overall index
- Lines: 68
- Date:
Tue Dec 7 15:32:51 1999
- Orig file:
v2.3.30/linux/fs/open.c
- Orig date:
Tue Dec 7 09:32:48 1999
diff -u --recursive --new-file v2.3.30/linux/fs/open.c linux/fs/open.c
@@ -79,13 +79,18 @@
return error;
}
-asmlinkage long sys_truncate(const char * path, unsigned long length)
+static inline long do_sys_truncate(const char * path, loff_t length)
{
struct dentry * dentry;
struct inode * inode;
int error;
lock_kernel();
+
+ error = -EINVAL;
+ if (length < 0) /* sorry, but loff_t says... */
+ goto out;
+
dentry = namei(path);
error = PTR_ERR(dentry);
@@ -128,13 +133,21 @@
return error;
}
-asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length)
+asmlinkage long sys_truncate(const char * path, unsigned long length)
+{
+ return do_sys_truncate(path, length);
+}
+
+static inline long do_sys_ftruncate(unsigned int fd, loff_t length)
{
struct inode * inode;
struct dentry *dentry;
struct file * file;
int error;
+ error = -EINVAL;
+ if (length < 0)
+ goto out;
error = -EBADF;
file = fget(fd);
if (!file)
@@ -162,6 +175,24 @@
out:
return error;
}
+
+asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length)
+{
+ return do_sys_ftruncate(fd, length);
+}
+
+/* LFS versions of truncate are only needed on 32 bit machines */
+#if BITS_PER_LONG == 32
+asmlinkage long sys_truncate64(const char * path, loff_t length)
+{
+ return do_sys_truncate(path, length);
+}
+
+asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length)
+{
+ return do_sys_ftruncate(fd, length);
+}
+#endif
#if !(defined(__alpha__) || defined(__ia64__))
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)