From 1d8e1195aaa1ebdb64c6df7f72a8c8dc2460ed10 Mon Sep 17 00:00:00 2001 From: Andras Elso Date: Wed, 27 Feb 2013 00:24:20 +0100 Subject: [PATCH] client: add some new functions: lchmod, fsetattr, lutime Signed-off-by: Andras Elso --- src/client/Client.cc | 50 ++++++++++++++++++++++++++++++++++++++++++++ src/client/Client.h | 3 +++ 2 files changed, 53 insertions(+) diff --git a/src/client/Client.cc b/src/client/Client.cc index eee7fdd6c1fb..f1bfe0dabc7d 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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) { diff --git a/src/client/Client.h b/src/client/Client.h index 3ebf27fd0a9a..8846e3f9ad72 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -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 -- 2.47.3