Skip to content

Commit 8bad91b

Browse files
committed
add log to print pid
1 parent 04d7d60 commit 8bad91b

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
dnl Process this file with autoconf to produce a configure script.
1919

2020
AC_PREREQ(2.59)
21-
AC_INIT(cosfs, 1.0.5)
21+
AC_INIT(cosfs, 1.0.6)
2222
AC_CONFIG_HEADER([config.h])
2323

2424
AC_CANONICAL_SYSTEM

src/s3fs.cpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,7 @@ static int s3fs_mknod(const char *path, mode_t mode, dev_t rdev)
907907
if(NULL == (pcxt = fuse_get_context())){
908908
return -EIO;
909909
}
910+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
910911

911912
if(0 != (result = create_file_object(path, mode, pcxt->uid, pcxt->gid))){
912913
S3FS_PRN_ERR("could not create object for special file(result=%d)", result);
@@ -928,6 +929,7 @@ static int s3fs_create(const char* path, mode_t mode, struct fuse_file_info* fi)
928929
if(NULL == (pcxt = fuse_get_context())){
929930
return -EIO;
930931
}
932+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
931933

932934
// check parent directory attribute.
933935
if(0 != (result = check_parent_object_access(path, X_OK))){
@@ -993,6 +995,7 @@ static int s3fs_mkdir(const char* path, mode_t mode)
993995
if(NULL == (pcxt = fuse_get_context())){
994996
return -EIO;
995997
}
998+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
996999

9971000
// check parent directory attribute.
9981001
if(0 != (result = check_parent_object_access(path, W_OK | X_OK))){
@@ -1018,6 +1021,11 @@ static int s3fs_unlink(const char* path)
10181021

10191022
S3FS_PRN_INFO("[path=%s]", path);
10201023

1024+
struct fuse_context* pcxt;
1025+
if(NULL != (pcxt = fuse_get_context())){
1026+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
1027+
}
1028+
10211029
if(0 != (result = check_parent_object_access(path, W_OK | X_OK))){
10221030
return result;
10231031
}
@@ -1053,6 +1061,11 @@ static int s3fs_rmdir(const char* path)
10531061

10541062
S3FS_PRN_INFO("[path=%s]", path);
10551063

1064+
struct fuse_context* pcxt;
1065+
if(NULL != (pcxt = fuse_get_context())){
1066+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
1067+
}
1068+
10561069
if(0 != (result = check_parent_object_access(path, W_OK | X_OK))){
10571070
return result;
10581071
}
@@ -1111,6 +1124,8 @@ static int s3fs_symlink(const char* from, const char* to)
11111124
if(NULL == (pcxt = fuse_get_context())){
11121125
return -EIO;
11131126
}
1127+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
1128+
11141129
if(0 != (result = check_parent_object_access(to, W_OK | X_OK))){
11151130
return result;
11161131
}
@@ -1474,6 +1489,11 @@ static int s3fs_chmod(const char* path, mode_t mode)
14741489

14751490
S3FS_PRN_INFO("[path=%s][mode=%04o]", path, mode);
14761491

1492+
struct fuse_context* pcxt;
1493+
if(NULL != (pcxt = fuse_get_context())){
1494+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
1495+
}
1496+
14771497
if(0 == strcmp(path, "/")){
14781498
S3FS_PRN_ERR("Could not change mode for mount point.");
14791499
return -EIO;
@@ -1540,6 +1560,11 @@ static int s3fs_chmod_nocopy(const char* path, mode_t mode)
15401560

15411561
S3FS_PRN_INFO1("[path=%s][mode=%04o]", path, mode);
15421562

1563+
struct fuse_context* pcxt;
1564+
if(NULL != (pcxt = fuse_get_context())){
1565+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
1566+
}
1567+
15431568
if(0 == strcmp(path, "/")){
15441569
S3FS_PRN_ERR("Could not change mode for maount point.");
15451570
return -EIO;
@@ -1620,6 +1645,11 @@ static int s3fs_chown(const char* path, uid_t uid, gid_t gid)
16201645

16211646
S3FS_PRN_INFO("[path=%s][uid=%u][gid=%u]", path, (unsigned int)uid, (unsigned int)gid);
16221647

1648+
struct fuse_context* pcxt;
1649+
if(NULL != (pcxt = fuse_get_context())){
1650+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
1651+
}
1652+
16231653
if(0 == strcmp(path, "/")){
16241654
S3FS_PRN_ERR("Could not change owner for maount point.");
16251655
return -EIO;
@@ -1700,6 +1730,10 @@ static int s3fs_chown_nocopy(const char* path, uid_t uid, gid_t gid)
17001730
int nDirType = DIRTYPE_UNKNOWN;
17011731

17021732
S3FS_PRN_INFO1("[path=%s][uid=%u][gid=%u]", path, (unsigned int)uid, (unsigned int)gid);
1733+
struct fuse_context* pcxt;
1734+
if(NULL != (pcxt = fuse_get_context())){
1735+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
1736+
}
17031737

17041738
if(0 == strcmp(path, "/")){
17051739
S3FS_PRN_ERR("Could not change owner for maount point.");
@@ -1790,6 +1824,10 @@ static int s3fs_utimens(const char* path, const struct timespec ts[2])
17901824
int nDirType = DIRTYPE_UNKNOWN;
17911825

17921826
S3FS_PRN_INFO("[path=%s][mtime=%jd]", path, (intmax_t)(ts[1].tv_sec));
1827+
struct fuse_context* pcxt;
1828+
if(NULL != (pcxt = fuse_get_context())){
1829+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
1830+
}
17931831

17941832
if(0 == strcmp(path, "/")){
17951833
S3FS_PRN_ERR("Could not change mtime for maount point.");
@@ -1857,6 +1895,10 @@ static int s3fs_utimens_nocopy(const char* path, const struct timespec ts[2])
18571895
int nDirType = DIRTYPE_UNKNOWN;
18581896

18591897
S3FS_PRN_INFO1("[path=%s][mtime=%s]", path, str(ts[1].tv_sec).c_str());
1898+
struct fuse_context* pcxt;
1899+
if(NULL != (pcxt = fuse_get_context())){
1900+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
1901+
}
18601902

18611903
if(0 == strcmp(path, "/")){
18621904
S3FS_PRN_ERR("Could not change mtime for mount point.");
@@ -1971,6 +2013,8 @@ static int s3fs_truncate(const char* path, off_t size)
19712013
if(NULL == (pcxt = fuse_get_context())){
19722014
return -EIO;
19732015
}
2016+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
2017+
19742018
meta["Content-Type"] = string("application/octet-stream"); // Static
19752019
meta["x-cos-meta-mode"] = str(S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO);
19762020
meta["x-cos-meta-mtime"] = str(time(NULL));
@@ -2004,6 +2048,10 @@ static int s3fs_open(const char* path, struct fuse_file_info* fi)
20042048
bool needs_flush = false;
20052049

20062050
S3FS_PRN_INFO("[path=%s][flags=%d]", path, fi->flags);
2051+
struct fuse_context* pcxt;
2052+
if(NULL != (pcxt = fuse_get_context())){
2053+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
2054+
}
20072055

20082056
// clear stat for reading fresh stat.
20092057
// (if object stat is changed, we refresh it. then s3fs gets always
@@ -2060,6 +2108,10 @@ static int s3fs_read(const char* path, char* buf, size_t size, off_t offset, str
20602108
ssize_t res;
20612109

20622110
S3FS_PRN_DBG("[path=%s][size=%zu][offset=%jd][fd=%llu]", path, size, (intmax_t)offset, (unsigned long long)(fi->fh));
2111+
struct fuse_context* pcxt;
2112+
if(NULL != (pcxt = fuse_get_context())){
2113+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
2114+
}
20632115

20642116
FdEntity* ent;
20652117
if(NULL == (ent = FdManager::get()->ExistOpen(path, static_cast<int>(fi->fh)))){
@@ -2091,6 +2143,10 @@ static int s3fs_write(const char* path, const char* buf, size_t size, off_t offs
20912143
ssize_t res;
20922144

20932145
S3FS_PRN_DBG("[path=%s][size=%zu][offset=%jd][fd=%llu]", path, size, (intmax_t)offset, (unsigned long long)(fi->fh));
2146+
struct fuse_context* pcxt;
2147+
if(NULL != (pcxt = fuse_get_context())){
2148+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
2149+
}
20942150

20952151
FdEntity* ent;
20962152
if(NULL == (ent = FdManager::get()->ExistOpen(path, static_cast<int>(fi->fh)))){
@@ -2124,6 +2180,10 @@ static int s3fs_flush(const char* path, struct fuse_file_info* fi)
21242180
int result;
21252181

21262182
S3FS_PRN_INFO("[path=%s][fd=%llu]", path, (unsigned long long)(fi->fh));
2183+
struct fuse_context* pcxt;
2184+
if(NULL != (pcxt = fuse_get_context())){
2185+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
2186+
}
21272187

21282188
int mask = (O_RDONLY != (fi->flags & O_ACCMODE) ? W_OK : R_OK);
21292189
if(0 != (result = check_parent_object_access(path, X_OK))){
@@ -2157,6 +2217,10 @@ static int s3fs_fsync(const char* path, int datasync, struct fuse_file_info* fi)
21572217
int result = 0;
21582218

21592219
S3FS_PRN_INFO("[path=%s][fd=%llu]", path, (unsigned long long)(fi->fh));
2220+
struct fuse_context* pcxt;
2221+
if(NULL != (pcxt = fuse_get_context())){
2222+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
2223+
}
21602224

21612225
FdEntity* ent;
21622226
if(NULL != (ent = FdManager::get()->ExistOpen(path, static_cast<int>(fi->fh)))){
@@ -2178,6 +2242,10 @@ static int s3fs_release(const char* path, struct fuse_file_info* fi)
21782242
{
21792243
S3FS_PRN_INFO("[path=%s][fd=%llu]", path, (unsigned long long)(fi->fh));
21802244

2245+
struct fuse_context* pcxt;
2246+
if(NULL != (pcxt = fuse_get_context())){
2247+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
2248+
}
21812249
// [NOTICE]
21822250
// At first, we remove stats cache.
21832251
// Because fuse does not wait for response from "release" function. :-(
@@ -2211,6 +2279,11 @@ static int s3fs_release(const char* path, struct fuse_file_info* fi)
22112279

22122280
static int s3fs_opendir(const char* path, struct fuse_file_info* fi)
22132281
{
2282+
struct fuse_context* pcxt;
2283+
if(NULL != (pcxt = fuse_get_context())){
2284+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
2285+
}
2286+
22142287
int result;
22152288
int mask = (O_RDONLY != (fi->flags & O_ACCMODE) ? W_OK : R_OK) | X_OK;
22162289

@@ -2366,6 +2439,10 @@ static int s3fs_readdir(const char* path, void* buf, fuse_fill_dir_t filler, off
23662439
int result;
23672440

23682441
S3FS_PRN_INFO("[path=%s]", path);
2442+
struct fuse_context* pcxt;
2443+
if(NULL != (pcxt = fuse_get_context())){
2444+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
2445+
}
23692446

23702447
if(0 != (result = check_object_access(path, X_OK, NULL))){
23712448
return result;
@@ -3129,6 +3206,10 @@ static int s3fs_getxattr(const char* path, const char* name, char* value, size_t
31293206
static int s3fs_listxattr(const char* path, char* list, size_t size)
31303207
{
31313208
S3FS_PRN_INFO("[path=%s][list=%p][size=%zu]", path, list, size);
3209+
struct fuse_context* pcxt;
3210+
if(NULL != (pcxt = fuse_get_context())){
3211+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
3212+
}
31323213

31333214
if(!path){
31343215
return -EIO;
@@ -3197,6 +3278,10 @@ static int s3fs_listxattr(const char* path, char* list, size_t size)
31973278
static int s3fs_removexattr(const char* path, const char* name)
31983279
{
31993280
S3FS_PRN_INFO("[path=%s][name=%s]", path, name);
3281+
struct fuse_context* pcxt;
3282+
if(NULL != (pcxt = fuse_get_context())){
3283+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
3284+
}
32003285

32013286
if(!path || !name){
32023287
return -EIO;
@@ -3342,6 +3427,11 @@ static void s3fs_destroy(void*)
33423427

33433428
static int s3fs_access(const char* path, int mask)
33443429
{
3430+
struct fuse_context* pcxt;
3431+
if(NULL != (pcxt = fuse_get_context())){
3432+
S3FS_PRN_INFO("%s, uid=[%d], gid=[%d], pid=[%d]", __FUNCTION__, pcxt->uid, pcxt->gid, pcxt->pid);
3433+
}
3434+
33453435
S3FS_PRN_INFO("[path=%s][mask=%s%s%s%s]", path,
33463436
((mask & R_OK) == R_OK) ? "R_OK " : "",
33473437
((mask & W_OK) == W_OK) ? "W_OK " : "",

0 commit comments

Comments
 (0)