diff options
author | We-unite <3205135446@qq.com> | 2024-07-29 11:46:02 +0800 |
---|---|---|
committer | We-unite <3205135446@qq.com> | 2024-07-29 11:46:02 +0800 |
commit | a345258c3082903702c81c6c830ff1fd35758861 (patch) | |
tree | a8521e954630b299c85adc10182ee3470a982415 /src/mongo.go | |
parent | ec260a31927ef77295eaa07ba370b58b416f47f5 (diff) | |
download | godo-a345258c3082903702c81c6c830ff1fd35758861.tar.gz godo-a345258c3082903702c81c6c830ff1fd35758861.zip |
Hear file Open and close, especially O_TRUNC
this commit i successfully catch open/close syscall, and insert them
as an independent collection in mongodb otherwise along with pids.
and now I've record those open flag "O_TRUNC" as written.
Diffstat (limited to 'src/mongo.go')
-rw-r--r-- | src/mongo.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo.go b/src/mongo.go index d00abd2..54f9533 100644 --- a/src/mongo.go +++ b/src/mongo.go | |||
@@ -15,6 +15,18 @@ type mongoClient struct { | |||
15 | col *mongo.Collection | 15 | col *mongo.Collection |
16 | } | 16 | } |
17 | 17 | ||
18 | func (mc *mongoClient) init(dbName, colName string) error { | ||
19 | var err error | ||
20 | if err = mc.Connect(dbName, colName); err != nil { | ||
21 | return err | ||
22 | } | ||
23 | if err = mc.Drop(); err != nil { | ||
24 | return err | ||
25 | } | ||
26 | |||
27 | return nil | ||
28 | } | ||
29 | |||
18 | func (mc *mongoClient) Connect(dbName, colName string) error { | 30 | func (mc *mongoClient) Connect(dbName, colName string) error { |
19 | var err error | 31 | var err error |
20 | mc.client, err = mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017")) | 32 | mc.client, err = mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017")) |