Debian Codegraph @

inotify/inotify.go

raw
1 /*
2 Copyright 2020 The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package inotify // import "k8s.io/utils/inotify"
18
19 import (
20 "sync"
21 )
22
23 // Event represents a notification
24 type Event struct {
25 Mask uint32 // Mask of events
26 Cookie uint32 // Unique cookie associating related events (for rename(2))
27 Name string // File name (optional)
28 }
29
30 type watch struct {
31 wd uint32 // Watch descriptor (as returned by the inotify_add_watch() syscall)
32 flags uint32 // inotify flags of this watch (see inotify(7) for the list of valid flags)
33 }
34
35 // Watcher represents an inotify instance
36 type Watcher struct {
37 mu sync.Mutex
38 fd int // File descriptor (as returned by the inotify_init() syscall)
39 watches map[string]*watch // Map of inotify watches (key: path)
40 paths map[int]string // Map of watched paths (key: watch descriptor)
41 Error chan error // Errors are sent on this channel
42 Event chan *Event // Events are returned on this channel
43 done chan bool // Channel for sending a "quit message" to the reader goroutine
44 isClosed bool // Set to true when Close() is first called
45 }