]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add some new functions: lchmod, fsetattr, lutime 78/head
authorAndras Elso <elso.andras@gmail.com>
Tue, 26 Feb 2013 23:24:20 +0000 (00:24 +0100)
committerAndras Elso <elso.andras@gmail.com>
Wed, 27 Feb 2013 00:53:09 +0000 (01:53 +0100)
Signed-off-by: Andras Elso <elso.andras@gmail.com>
src/client/Client.cc
src/client/Client.h

index eee7fdd6c1fb54e9709126f2079164aa8a5efbfb..f1bfe0dabc7dbaf24a573e9fcdd19326273fea43 100644 (file)
@@ -4313,6 +4313,19 @@ int Client::setattr(const char *relpath, struct stat *attr, int mask)
   return _setattr(in, attr, mask); 
 }
 
+int Client::fsetattr(int fd, struct stat *attr, int mask)
+{
+  Mutex::Locker lock(client_lock);
+  tout(cct) << "fsetattr" << std::endl;
+  tout(cct) << fd << std::endl;
+  tout(cct) << mask  << std::endl;
+
+  Fh *f = get_filehandle(fd);
+  if (!f)
+    return -EBADF;
+  return _setattr(f->inode, attr, mask); 
+}
+
 int Client::stat(const char *relpath, struct stat *stbuf,
                          frag_info_t *dirstat, int mask)
 {
@@ -4435,6 +4448,23 @@ int Client::fchmod(int fd, mode_t mode)
   return _setattr(f->inode, &attr, CEPH_SETATTR_MODE);
 }
 
+int Client::lchmod(const char *relpath, mode_t mode)
+{
+  Mutex::Locker lock(client_lock);
+  tout(cct) << "lchmod" << std::endl;
+  tout(cct) << relpath << std::endl;
+  tout(cct) << mode << std::endl;
+  filepath path(relpath);
+  Inode *in;
+  // don't follow symlinks
+  int r = path_walk(path, &in, false);
+  if (r < 0)
+    return r;
+  struct stat attr;
+  attr.st_mode = mode;
+  return _setattr(in, &attr, CEPH_SETATTR_MODE);
+}
+
 int Client::chown(const char *relpath, int uid, int gid)
 {
   Mutex::Locker lock(client_lock);
@@ -4517,6 +4547,26 @@ int Client::utime(const char *relpath, struct utimbuf *buf)
   return _setattr(in, &attr, CEPH_SETATTR_MTIME|CEPH_SETATTR_ATIME);
 }
 
+int Client::lutime(const char *relpath, struct utimbuf *buf)
+{
+  Mutex::Locker lock(client_lock);
+  tout(cct) << "lutime" << std::endl;
+  tout(cct) << relpath << std::endl;
+  tout(cct) << buf->modtime << std::endl;
+  tout(cct) << buf->actime << std::endl;
+  filepath path(relpath);
+  Inode *in;
+  // don't follow symlinks
+  int r = path_walk(path, &in, false);
+  if (r < 0)
+    return r;
+  struct stat attr;
+  attr.st_mtim.tv_sec = buf->modtime;
+  attr.st_mtim.tv_nsec = 0;
+  attr.st_atim.tv_sec = buf->actime;
+  attr.st_atim.tv_nsec = 0;
+  return _setattr(in, &attr, CEPH_SETATTR_MTIME|CEPH_SETATTR_ATIME);
+}
 
 int Client::opendir(const char *relpath, dir_result_t **dirpp) 
 {
index 3ebf27fd0a9ad0d132f17b2143be7e04d3d1509a..8846e3f9ad72b3209c92afee8478fd0ebcfa88b3 100644 (file)
@@ -620,12 +620,15 @@ public:
   int lstatlite(const char *path, struct statlite *buf);
 
   int setattr(const char *relpath, struct stat *attr, int mask);
+  int fsetattr(int fd, struct stat *attr, int mask);
   int chmod(const char *path, mode_t mode);
   int fchmod(int fd, mode_t mode);
+  int lchmod(const char *path, mode_t mode);
   int chown(const char *path, int uid, int gid);
   int fchown(int fd, int uid, int gid);
   int lchown(const char *path, int uid, int gid);
   int utime(const char *path, struct utimbuf *buf);
+  int lutime(const char *path, struct utimbuf *buf);
   int truncate(const char *path, loff_t size);
 
   // file ops