return err;
}
-int Client::truncate(const char *relpath, loff_t length)
+int Client::truncate(const char *relpath, loff_t length, const UserPerm& perms)
{
struct stat attr;
attr.st_size = length;
- // FIXME
- UserPerm perms(get_uid(), get_gid());
return setattr(relpath, &attr, CEPH_SETATTR_SIZE, perms);
}
-int Client::ftruncate(int fd, loff_t length)
+int Client::ftruncate(int fd, loff_t length, const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
tout(cct) << "ftruncate" << std::endl;
#endif
struct stat attr;
attr.st_size = length;
- return _setattr(f->inode, &attr, CEPH_SETATTR_SIZE);
+ return _setattr(f->inode, &attr, CEPH_SETATTR_SIZE, perms);
}
int Client::fsync(int fd, bool syncdataonly)
int utime(const char *path, struct utimbuf *buf, const UserPerm& perms);
int lutime(const char *path, struct utimbuf *buf, const UserPerm& perms);
int flock(int fd, int operation, uint64_t owner);
- int truncate(const char *path, loff_t size);
+ int truncate(const char *path, loff_t size, const UserPerm& perms);
// file ops
int mknod(const char *path, mode_t mode, dev_t rdev=0);
int write(int fd, const char *buf, loff_t size, loff_t offset=-1);
int pwritev(int fd, const struct iovec *iov, int iovcnt, loff_t offset=-1);
int fake_write_size(int fd, loff_t size);
- int ftruncate(int fd, loff_t size);
+ int ftruncate(int fd, loff_t size, const UserPerm& perms);
int fsync(int fd, bool syncdataonly);
int fstat(int fd, struct stat *stbuf, int mask=CEPH_STAT_CAP_INODE_ALL);
int fallocate(int fd, int mode, loff_t offset, loff_t length);
sargs.push_front(file);
int iarg1 = iargs.front(); iargs.pop_front();
if (run_me()) {
- client->truncate(file.c_str(), iarg1);
+ client->truncate(file.c_str(), iarg1, perms);
}
did_run_me();
}
} else if (strcmp(op, "truncate") == 0) {
const char *a = t.get_string(buf, p);
int64_t l = t.get_int();
- client->truncate(a, l);
+ client->truncate(a, l, perms);
} else if (strcmp(op, "ftruncate") == 0) {
int64_t f = t.get_int();
int fd = open_files[f];
int64_t l = t.get_int();
- client->ftruncate(fd, l);
+ client->ftruncate(fd, l, perms);
} else if (strcmp(op, "fsync") == 0) {
int64_t f = t.get_int();
int64_t b = t.get_int();
if (data) {
client->write(fd, "", 0, size);
} else {
- client->truncate(f.c_str(), size);
+ client->truncate(f.c_str(), size, perms);
}
client->close(fd);
{
if (!cmount->is_mounted())
return -ENOTCONN;
- return cmount->get_client()->truncate(path, size);
+ UserPerm perms = cmount->get_client()->pick_my_perms();
+ return cmount->get_client()->truncate(path, size, perms);
}
// file ops
{
if (!cmount->is_mounted())
return -ENOTCONN;
- return cmount->get_client()->ftruncate(fd, size);
+ UserPerm perms = cmount->get_client()->pick_my_perms();
+ return cmount->get_client()->ftruncate(fd, size, perms);
}
extern "C" int ceph_fsync(struct ceph_mount_info *cmount, int fd, int syncdataonly)