The File object is tightly coupled to the Dir object. Since they both have locks there is plenty of potential for deadlocks. In order to mitigate this, we use the following conventions File may **only** call these methods from Dir with the File lock held. Dir.Fs Dir.VFS (As these are read only an
| 40 | |
| 41 | // File represents a file or a symlink |
| 42 | type File struct { |
| 43 | inode uint64 // inode number - read only |
| 44 | size atomic.Int64 // size of file |
| 45 | ctx context.Context // context for VFS operations - read only |
| 46 | |
| 47 | muRW sync.Mutex // synchronize RWFileHandle.openPending(), RWFileHandle.close() and File.Remove |
| 48 | |
| 49 | mu sync.RWMutex // protects the following |
| 50 | d *Dir // parent directory |
| 51 | dPath string // path of parent directory. NB dir rename means all Files are flushed |
| 52 | o fs.Object // NB o may be nil if file is being written |
| 53 | leaf string // leaf name of the object |
| 54 | writers []Handle // writers for this file |
| 55 | virtualModTime *time.Time // modtime for backends with Precision == fs.ModTimeNotSupported |
| 56 | pendingModTime time.Time // will be applied once o becomes available, i.e. after file was written |
| 57 | pendingRenameFun func(ctx context.Context) error // will be run/renamed after all writers close |
| 58 | sys atomic.Value // user defined info to be attached here |
| 59 | nwriters atomic.Int32 // len(writers) |
| 60 | appendMode bool // file was opened with O_APPEND |
| 61 | isLink bool // file represents a symlink |
| 62 | } |
| 63 | |
| 64 | // newFile creates a new File |
| 65 | // |
nothing calls this directly
no outgoing calls
no test coverage detected