]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: always pass a UserPerm to truncate variants
authorGreg Farnum <gfarnum@redhat.com>
Wed, 27 Jul 2016 23:45:46 +0000 (16:45 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Wed, 21 Sep 2016 23:33:47 +0000 (16:33 -0700)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/client/Client.cc
src/client/Client.h
src/client/SyntheticClient.cc
src/libcephfs.cc

index 2a91a78df2ae4f3293e166b166e7d9939386b41a..29d6f11654485a89c9723cd3ab9d2ccbdf01b8cd 100644 (file)
@@ -8706,16 +8706,14 @@ int Client::_flush(Fh *f)
   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;
@@ -8731,7 +8729,7 @@ int Client::ftruncate(int fd, loff_t length)
 #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) 
index f25593c0454a117cdf88044c1cef0482da90d952..9b6843784c6c2ad7a5145ae6cc3065045dc11e19 100644 (file)
@@ -1083,7 +1083,7 @@ public:
   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);
@@ -1100,7 +1100,7 @@ public:
   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);
index 482992f18d8eed3318f5062e395193bfff94957b..a71dfe2388af69e605bd4f5d27c188bf2d54e195 100644 (file)
@@ -849,7 +849,7 @@ int SyntheticClient::run()
         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();
       }
@@ -1199,12 +1199,12 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only)
     } 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();
@@ -3314,7 +3314,7 @@ void SyntheticClient::import_find(const char *base, const char *find, bool data)
        if (data) {
          client->write(fd, "", 0, size);
        } else {
-         client->truncate(f.c_str(), size);
+         client->truncate(f.c_str(), size, perms);
        }
        client->close(fd);
 
index a66c145bedc4765e1be2f808eb3e5959845f6e8a..8d47cf5d3dd2440c7a2c8ca45fddfe71d73422e8 100644 (file)
@@ -794,7 +794,8 @@ extern "C" int ceph_truncate(struct ceph_mount_info *cmount, const char *path,
 {
   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
@@ -874,7 +875,8 @@ extern "C" int ceph_ftruncate(struct ceph_mount_info *cmount, int fd, int64_t si
 {
   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)