summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndras Elso <elso.andras@gmail.com>2013-02-27 00:24:20 +0100
committerAndras Elso <elso.andras@gmail.com>2013-02-27 01:53:09 +0100
commit1d8e1195aaa1ebdb64c6df7f72a8c8dc2460ed10 (patch)
treee97431260124a4ff2bbdbd9ce16c9c9113efdf1e
parentac9ed33a075e1464cfc954f0069f0a7fb97e54f6 (diff)
downloadceph-1d8e1195aaa1ebdb64c6df7f72a8c8dc2460ed10.tar.gz
client: add some new functions: lchmod, fsetattr, lutime
Signed-off-by: Andras Elso <elso.andras@gmail.com>
-rw-r--r--src/client/Client.cc50
-rw-r--r--src/client/Client.h3
2 files changed, 53 insertions, 0 deletions
diff --git a/src/client/Client.cc b/src/client/Client.cc
index eee7fdd6c1f..f1bfe0dabc7 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 3ebf27fd0a9..8846e3f9ad7 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