summaryrefslogtreecommitdiffstats
path: root/src/deal.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/deal.go')
-rw-r--r--src/deal.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/deal.go b/src/deal.go
index d3b5da0..56f6d1d 100644
--- a/src/deal.go
+++ b/src/deal.go
@@ -65,6 +65,8 @@ func deal() {
65 go deletePid(cooked) 65 go deletePid(cooked)
66 case FILEOPEN: 66 case FILEOPEN:
67 fileOpen(cooked) 67 fileOpen(cooked)
68 case FILEWRITE:
69 fileWrite(cooked)
68 case FILECLOSE: 70 case FILECLOSE:
69 fileClose(cooked) 71 fileClose(cooked)
70 } 72 }
@@ -234,3 +236,23 @@ func fileClose(cooked Event) {
234 "close_timestamp": bson.M{"$exists": false}, 236 "close_timestamp": bson.M{"$exists": false},
235 }, bson.M{"$set": bson.M{"close_timestamp": cooked.timestamp}}) 237 }, bson.M{"$set": bson.M{"close_timestamp": cooked.timestamp}})
236} 238}
239
240func fileWrite(cooked Event) {
241 // 直接看文件表有无记录
242 res, err := fdCol.Finddoc(bson.M{
243 "pid": cooked.pid,
244 "fd": cooked.syscallParam[0],
245 "close_timestamp": bson.M{"$exists": false},
246 })
247 if err != nil {
248 fmt.Printf("Err closing fd %d of pid %d: %v\n", cooked.syscallParam[0], cooked.pid, err)
249 }
250 if len(res) == 0 {
251 return
252 }
253 fdCol.UpdateOne(bson.M{
254 "pid": cooked.pid,
255 "fd": cooked.syscallParam[0],
256 "close_timestamp": bson.M{"$exists": false},
257 }, bson.M{"$push": bson.M{"written": cooked.timestamp}})
258}