From: Greg Farnum Date: Thu, 28 Jul 2016 00:13:03 +0000 (-0700) Subject: client: always pass a UserPerm to stat variants X-Git-Tag: v11.0.1~36^2~74 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=882468abf2402fe4d8022b3af294fca0b9dba7f2;p=ceph.git client: always pass a UserPerm to stat variants Also remove the lstatlite() declaration, since it's not defined. Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 29d6f1165448..3fd8f8efaed4 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -6620,8 +6620,8 @@ int Client::fsetattr(int fd, struct stat *attr, int mask, return _setattr(f->inode, attr, mask, perms); } -int Client::stat(const char *relpath, struct stat *stbuf, - frag_info_t *dirstat, int mask) +int Client::stat(const char *relpath, struct stat *stbuf, const UserPerm& perms, + frag_info_t *dirstat, int mask) { ldout(cct, 3) << "stat enter (relpath " << relpath << " mask " << mask << ")" << dendl; Mutex::Locker lock(client_lock); @@ -6629,10 +6629,10 @@ int Client::stat(const char *relpath, struct stat *stbuf, tout(cct) << relpath << 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; - r = _getattr(in, mask); + r = _getattr(in, mask, perms); if (r < 0) { ldout(cct, 3) << "stat exit on error!" << dendl; return r; @@ -6643,7 +6643,7 @@ int Client::stat(const char *relpath, struct stat *stbuf, } int Client::lstat(const char *relpath, struct stat *stbuf, - frag_info_t *dirstat, int mask) + const UserPerm& perms, frag_info_t *dirstat, int mask) { ldout(cct, 3) << "lstat enter (relpath " << relpath << " mask " << mask << ")" << dendl; Mutex::Locker lock(client_lock); @@ -6652,10 +6652,10 @@ int Client::lstat(const char *relpath, struct stat *stbuf, 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; - r = _getattr(in, mask); + r = _getattr(in, mask, perms); if (r < 0) { ldout(cct, 3) << "lstat exit on error!" << dendl; return r; @@ -8828,7 +8828,7 @@ int Client::_fsync(Fh *f, bool syncdataonly) return _fsync(f->inode.get(), syncdataonly); } -int Client::fstat(int fd, struct stat *stbuf, int mask) +int Client::fstat(int fd, struct stat *stbuf, const UserPerm& perms, int mask) { Mutex::Locker lock(client_lock); tout(cct) << "fstat mask " << hex << mask << dec << std::endl; @@ -8837,7 +8837,7 @@ int Client::fstat(int fd, struct stat *stbuf, int mask) Fh *f = get_filehandle(fd); if (!f) return -EBADF; - int r = _getattr(f->inode, mask); + int r = _getattr(f->inode, mask, perms); if (r < 0) return r; fill_stat(f->inode, stbuf, NULL); diff --git a/src/client/Client.h b/src/client/Client.h index 6ef98d8751ed..9fb6f1f44457 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1057,9 +1057,10 @@ public: int symlink(const char *existing, const char *newname); // inode stuff - int stat(const char *path, struct stat *stbuf, frag_info_t *dirstat=0, int mask=CEPH_STAT_CAP_INODE_ALL); - int lstat(const char *path, struct stat *stbuf, frag_info_t *dirstat=0, int mask=CEPH_STAT_CAP_INODE_ALL); - int lstatlite(const char *path, struct statlite *buf); + int stat(const char *path, struct stat *stbuf, const UserPerm& perms, + frag_info_t *dirstat=0, int mask=CEPH_STAT_CAP_INODE_ALL); + int lstat(const char *path, struct stat *stbuf, const UserPerm& perms, + frag_info_t *dirstat=0, int mask=CEPH_STAT_CAP_INODE_ALL); int setattr(const char *relpath, struct stat *attr, int mask, const UserPerm& perms); int fsetattr(int fd, struct stat *attr, int mask, const UserPerm& perms); @@ -1093,7 +1094,8 @@ public: int fake_write_size(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 fstat(int fd, struct stat *stbuf, const UserPerm& perms, + int mask=CEPH_STAT_CAP_INODE_ALL); int fallocate(int fd, int mode, loff_t offset, loff_t length); // full path xattr ops diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index a71dfe2388af..839af89dfb8e 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -835,7 +835,7 @@ int SyntheticClient::run() client->mknod("test", 0777); struct stat st; for (int i=0; ilstat("test", &st); + client->lstat("test", &st, perms); client->chmod("test", 0777, perms); } } @@ -1105,7 +1105,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) strcmp(a, "/") != 0 && strcmp(a, "/lib") != 0 && // or /lib.. that would be a lookup. hack. a[0] != 0) // stop stating the root directory already - client->lstat(a, &st); + client->lstat(a, &st, perms); } else if (strcmp(op, "chmod") == 0) { const char *a = t.get_string(buf, p); int64_t b = t.get_int(); @@ -1577,7 +1577,7 @@ int SyntheticClient::clean_dir(string& basedir) if (time_to_stop()) break; struct stat st; - int r = client->lstat(file.c_str(), &st); + int r = client->lstat(file.c_str(), &st, perms); if (r < 0) { dout(1) << "stat error on " << file << " r=" << r << dendl; continue; @@ -1637,7 +1637,7 @@ int SyntheticClient::full_walk(string& basedir) struct stat st; frag_info_t dirstat; - int r = client->lstat(file.c_str(), &st, &dirstat); + int r = client->lstat(file.c_str(), &st, perms, &dirstat); if (r < 0) { dout(1) << "stat error on " << file << " r=" << r << dendl; continue; @@ -1698,6 +1698,8 @@ int SyntheticClient::full_walk(string& basedir) int SyntheticClient::dump_placement(string& fn) { + + UserPerm perms = client->pick_my_perms(); // open file int fd = client->open(fn.c_str(), O_RDONLY); @@ -1707,7 +1709,7 @@ int SyntheticClient::dump_placement(string& fn) { // How big is it? struct stat stbuf; - int lstat_result = client->lstat(fn.c_str(), &stbuf); + int lstat_result = client->lstat(fn.c_str(), &stbuf, perms); if (lstat_result < 0) { dout(0) << "lstat error for file " << fn << dendl; client->close(fd); @@ -1775,9 +1777,11 @@ int SyntheticClient::stat_dirs(const char *basedir, int dirs, int files, int dep { if (time_to_stop()) return 0; + UserPerm perms = client->pick_my_perms(); + // make sure base dir exists struct stat st; - int r = client->lstat(basedir, &st); + int r = client->lstat(basedir, &st, perms); if (r != 0) { dout(1) << "can't make base dir? " << basedir << dendl; return -1; @@ -1788,7 +1792,7 @@ int SyntheticClient::stat_dirs(const char *basedir, int dirs, int files, int dep dout(3) << "stat_dirs " << basedir << " dirs " << dirs << " files " << files << " depth " << depth << dendl; for (int i=0; ilstat(d, &st); + client->lstat(d, &st, perms); } if (depth == 0) return 0; @@ -1824,7 +1828,7 @@ int SyntheticClient::read_dirs(const char *basedir, int dirs, int files, int dep for (int i=0; icct); - if (client->lstat(d, &st) < 0) { + if (client->lstat(d, &st, perms) < 0) { dout(2) << "read_dirs failed stat on " << d << ", stopping" << dendl; return -1; } @@ -1875,7 +1879,7 @@ int SyntheticClient::make_files(int num, int count, int priv, bool more) client->mknod(d, 0644); if (more) { - client->lstat(d, &st); + client->lstat(d, &st, perms); int fd = client->open(d, O_RDONLY); client->unlink(d, perms); client->close(fd); @@ -2785,7 +2789,7 @@ int SyntheticClient::random_walk(int num_req) } else op = CEPH_MDS_OP_READDIR; } else - r = client->lstat(get_random_sub(), &st); + r = client->lstat(get_random_sub(), &st, perms); } if (op == CEPH_MDS_OP_READDIR) { @@ -3354,7 +3358,8 @@ int SyntheticClient::chunk_file(string &filename) return fd; struct stat st; - int ret = client->fstat(fd, &st); + UserPerm perms = client->pick_my_perms(); + int ret = client->fstat(fd, &st, perms); if (ret < 0) { client->close(fd); return ret; diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 8d47cf5d3dd2..a0a329d48119 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -612,7 +612,8 @@ extern "C" int ceph_stat(struct ceph_mount_info *cmount, const char *path, { if (!cmount->is_mounted()) return -ENOTCONN; - return cmount->get_client()->stat(path, stbuf); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->get_client()->stat(path, stbuf, perms); } extern "C" int ceph_lstat(struct ceph_mount_info *cmount, const char *path, @@ -620,7 +621,8 @@ extern "C" int ceph_lstat(struct ceph_mount_info *cmount, const char *path, { if (!cmount->is_mounted()) return -ENOTCONN; - return cmount->get_client()->lstat(path, stbuf); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->get_client()->lstat(path, stbuf, perms); } extern "C" int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath, @@ -898,7 +900,8 @@ extern "C" int ceph_fstat(struct ceph_mount_info *cmount, int fd, struct stat *s { if (!cmount->is_mounted()) return -ENOTCONN; - return cmount->get_client()->fstat(fd, stbuf); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->get_client()->fstat(fd, stbuf, perms); } extern "C" int ceph_sync_fs(struct ceph_mount_info *cmount)