Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LU-2034 changelog: redo changelog using OSD llog
[fs/lustre-release.git]
/
libsysio
/
src
/
truncate.c
diff --git
a/libsysio/src/truncate.c
b/libsysio/src/truncate.c
index
718f0af
..
27ef6b6
100644
(file)
--- a/
libsysio/src/truncate.c
+++ b/
libsysio/src/truncate.c
@@
-43,6
+43,7
@@
#include <unistd.h>
#include <string.h>
#include <unistd.h>
#include <string.h>
+#include <fcntl.h>
#include <errno.h>
#include <assert.h>
#include <sys/types.h>
#include <errno.h>
#include <assert.h>
#include <sys/types.h>
@@
-52,6
+53,8
@@
#include "sysio.h"
#include "inode.h"
#include "file.h"
#include "sysio.h"
#include "inode.h"
#include "file.h"
+#include "fs.h"
+#include "mount.h"
#include "sysio-symbols.h"
#include "sysio-symbols.h"
@@
-71,9
+74,9
@@
do_truncate(struct pnode *pno, struct inode *ino, _SYSIO_OFF_T length)
ino = pno->p_base->pb_ino;
if (!ino)
return -EBADF;
ino = pno->p_base->pb_ino;
if (!ino)
return -EBADF;
- if (S_ISDIR(ino->i_
mode))
/* for others too? */
+ if (S_ISDIR(ino->i_
stbuf.st_mode))
/* for others too? */
return -EISDIR;
return -EISDIR;
- if (!S_ISREG(ino->i_mode))
+ if (!S_ISREG(ino->i_
stbuf.st_
mode))
return -EINVAL;
(void )memset(&stbuf, 0, sizeof(stbuf));
return -EINVAL;
(void )memset(&stbuf, 0, sizeof(stbuf));
@@
-101,7
+104,7
@@
out:
SYSIO_INTERFACE_RETURN(err ? -1 : 0, err);
}
SYSIO_INTERFACE_RETURN(err ? -1 : 0, err);
}
-#if _LARGEFILE64_SOURCE
+#if
def
_LARGEFILE64_SOURCE
#undef truncate64
sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(truncate)),
SYSIO_INTERFACE_NAME(truncate64))
#undef truncate64
sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(truncate)),
SYSIO_INTERFACE_NAME(truncate64))
@@
-133,12
+136,16
@@
PREPEND(_, SYSIO_INTERFACE_NAME(ftruncate))(int fd, _SYSIO_OFF_T length)
err = -EBADF;
goto out;
}
err = -EBADF;
goto out;
}
+ if (!F_CHKRW(fil, 'w')) {
+ err = -EBADF;
+ goto out;
+ }
err = do_truncate(NULL, fil->f_ino, length);
out:
SYSIO_INTERFACE_RETURN(err ? -1 : 0, err);
}
err = do_truncate(NULL, fil->f_ino, length);
out:
SYSIO_INTERFACE_RETURN(err ? -1 : 0, err);
}
-#if _LARGEFILE64_SOURCE
+#if
def
_LARGEFILE64_SOURCE
#undef ftruncate64
sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ftruncate)),
SYSIO_INTERFACE_NAME(ftruncate64))
#undef ftruncate64
sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ftruncate)),
SYSIO_INTERFACE_NAME(ftruncate64))