]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: always pass a UserPerm to utime variants
authorGreg Farnum <gfarnum@redhat.com>
Wed, 27 Jul 2016 23:07:30 +0000 (16:07 -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 4e6699bdf1b39664069fe17797e5cfdd98fbc8ee..2a91a78df2ae4f3293e166b166e7d9939386b41a 100644 (file)
@@ -6836,7 +6836,8 @@ int Client::lchown(const char *relpath, uid_t new_uid, gid_t new_gid,
   return _setattr(in, &attr, mask, perms);
 }
 
-int Client::utime(const char *relpath, struct utimbuf *buf)
+int Client::utime(const char *relpath, struct utimbuf *buf,
+                 const UserPerm& perms)
 {
   Mutex::Locker lock(client_lock);
   tout(cct) << "utime" << std::endl;
@@ -6845,7 +6846,7 @@ int Client::utime(const char *relpath, struct utimbuf *buf)
   tout(cct) << buf->actime << std::endl;
   filepath path(relpath);
   InodeRef in;
-  int r = path_walk(path, &in);
+  int r = path_walk(path, &in, perms);
   if (r < 0)
     return r;
   struct stat attr;
@@ -6853,10 +6854,11 @@ int Client::utime(const char *relpath, struct utimbuf *buf)
   stat_set_mtime_nsec(&attr, 0);
   stat_set_atime_sec(&attr, buf->actime);
   stat_set_atime_nsec(&attr, 0);
-  return _setattr(in, &attr, CEPH_SETATTR_MTIME|CEPH_SETATTR_ATIME);
+  return _setattr(in, &attr, CEPH_SETATTR_MTIME|CEPH_SETATTR_ATIME, perms);
 }
 
-int Client::lutime(const char *relpath, struct utimbuf *buf)
+int Client::lutime(const char *relpath, struct utimbuf *buf,
+                  const UserPerm& perms)
 {
   Mutex::Locker lock(client_lock);
   tout(cct) << "lutime" << std::endl;
@@ -6866,7 +6868,7 @@ int Client::lutime(const char *relpath, struct utimbuf *buf)
   filepath path(relpath);
   InodeRef in;
   // don't follow symlinks
-  int r = path_walk(path, &in, false);
+  int r = path_walk(path, &in, perms, false);
   if (r < 0)
     return r;
   struct stat attr;
@@ -6874,7 +6876,7 @@ int Client::lutime(const char *relpath, struct utimbuf *buf)
   stat_set_mtime_nsec(&attr, 0);
   stat_set_atime_sec(&attr, buf->actime);
   stat_set_atime_nsec(&attr, 0);
-  return _setattr(in, &attr, CEPH_SETATTR_MTIME|CEPH_SETATTR_ATIME);
+  return _setattr(in, &attr, CEPH_SETATTR_MTIME|CEPH_SETATTR_ATIME, perms);
 }
 
 int Client::flock(int fd, int operation, uint64_t owner)
index 08c555871ddbadd570400ea105937ca3730977c4..f25593c0454a117cdf88044c1cef0482da90d952 100644 (file)
@@ -1080,8 +1080,8 @@ public:
   int fchown(int fd, uid_t new_uid, gid_t new_gid, const UserPerm& perms);
   int lchown(const char *path, uid_t new_uid, gid_t new_gid,
             const UserPerm& perms);
-  int utime(const char *path, struct utimbuf *buf);
-  int lutime(const char *path, struct utimbuf *buf);
+  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);
 
index b46ed8b1ba1d62eab5162872378ea5fcb885569d..482992f18d8eed3318f5062e395193bfff94957b 100644 (file)
@@ -1122,7 +1122,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only)
       struct utimbuf u;
       u.actime = b;
       u.modtime = c;
-      client->utime(a, &u);
+      client->utime(a, &u, perms);
     } else if (strcmp(op, "mknod") == 0) {
       const char *a = t.get_string(buf, p);
       int64_t b = t.get_int();
@@ -2737,9 +2737,9 @@ int SyntheticClient::random_walk(int num_req)
       struct utimbuf b;
       memset(&b, 1, sizeof(b));
       if (contents.empty()) 
-        r = client->utime( cwd.c_str(), &b );
+        r = client->utime(cwd.c_str(), &b, perms);
       else
-        r = client->utime( get_random_sub(), &b );
+        r = client->utime(get_random_sub(), &b, perms);
     }
     */
     if (op == CEPH_MDS_OP_LINK) {
@@ -3324,7 +3324,7 @@ void SyntheticClient::import_find(const char *base, const char *find, bool data)
        struct utimbuf ut;
        ut.modtime = mtime;
        ut.actime = mtime;
-       client->utime(f.c_str(), &ut);
+       client->utime(f.c_str(), &ut, perms);
       }
     }
   }
index 3ffada336b29a9d5cfcb891b62c68c766723d83f..a66c145bedc4765e1be2f808eb3e5959845f6e8a 100644 (file)
@@ -777,7 +777,8 @@ extern "C" int ceph_utime(struct ceph_mount_info *cmount, const char *path,
 {
   if (!cmount->is_mounted())
     return -ENOTCONN;
-  return cmount->get_client()->utime(path, buf);
+  UserPerm perms = cmount->get_client()->pick_my_perms();
+  return cmount->get_client()->utime(path, buf, perms);
 }
 
 extern "C" int ceph_flock(struct ceph_mount_info *cmount, int fd, int operation,