MCPcopy Create free account
hub / github.com/ceph/ceph / fill_stat

Method fill_stat

src/client/Client.cc:9067–9142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9065}
9066
9067int Client::fill_stat(Inode *in, struct stat *st, frag_info_t *dirstat, nest_info_t *rstat)
9068{
9069 ldout(cct, 10) << __func__ << " on " << in->ino << " snap/dev" << in->snapid
9070 << " mode 0" << oct << in->mode << dec
9071 << " mtime " << in->mtime << " ctime " << in->ctime << dendl;
9072 memset(st, 0, sizeof(struct stat));
9073 if (use_faked_inos())
9074 st->st_ino = in->faked_ino;
9075 else
9076 st->st_ino = in->ino;
9077 st->st_dev = in->snapid;
9078 st->st_mode = in->mode;
9079 st->st_rdev = in->rdev;
9080 if (in->is_dir()) {
9081 switch (in->nlink) {
9082 case 0:
9083 st->st_nlink = 0; /* dir is unlinked */
9084 break;
9085 case 1:
9086 st->st_nlink = 1 /* parent dentry */
9087 + 1 /* <dir>/. */
9088 + in->dirstat.nsubdirs; /* include <dir>/. self-reference */
9089 break;
9090 default:
9091 ceph_abort();
9092 }
9093 } else {
9094 st->st_nlink = in->nlink;
9095 }
9096 st->st_uid = in->uid;
9097 st->st_gid = in->gid;
9098 if (in->ctime > in->mtime) {
9099 stat_set_ctime_sec(st, in->ctime.sec());
9100 stat_set_ctime_nsec(st, in->ctime.nsec());
9101 } else {
9102 stat_set_ctime_sec(st, in->mtime.sec());
9103 stat_set_ctime_nsec(st, in->mtime.nsec());
9104 }
9105 stat_set_atime_sec(st, in->atime.sec());
9106 stat_set_atime_nsec(st, in->atime.nsec());
9107 stat_set_mtime_sec(st, in->mtime.sec());
9108 stat_set_mtime_nsec(st, in->mtime.nsec());
9109 if (in->is_dir()) {
9110 if (cct->_conf->client_dirsize_rbytes) {
9111 st->st_size = in->rstat.rbytes;
9112 } else if (in->snapid == CEPH_SNAPDIR) {
9113 SnapRealm *realm = get_snap_realm_maybe(in->vino().ino);
9114 if (realm) {
9115 st->st_size = realm->my_snaps.size();
9116 put_snap_realm(realm);
9117 }
9118 } else {
9119 st->st_size = in->dirstat.size();
9120 }
9121// The Windows "stat" structure provides just a subset of the fields that are
9122// available on Linux.
9123#ifndef _WIN32
9124 st->st_blocks = 1;

Callers

nothing calls this directly

Calls 13

stat_set_ctime_secFunction · 0.85
stat_set_ctime_nsecFunction · 0.85
stat_set_atime_secFunction · 0.85
stat_set_atime_nsecFunction · 0.85
stat_set_mtime_secFunction · 0.85
stat_set_mtime_nsecFunction · 0.85
nsecMethod · 0.80
caps_issuedMethod · 0.80
is_dirMethod · 0.45
secMethod · 0.45
vinoMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected