@@ -47,7 +47,7 @@ type Filesystem struct {
47
47
baseDir string
48
48
49
49
// used by the 'read only' methods
50
- fs fs.FS
50
+ fs fs.StatFS
51
51
52
52
// FixedFSGroup is an optional field which will set the gid ownership of all
53
53
// volume's data directories to this value.
@@ -71,7 +71,7 @@ func NewFilesystem(log logr.Logger, baseDir string) (*Filesystem, error) {
71
71
baseDir : baseDir ,
72
72
// Use the rootfs as the DirFS so that paths passed to both read &
73
73
// write methods on this struct use a consistent root.
74
- fs : os .DirFS ("/" ),
74
+ fs : os .DirFS ("/" ).(fs. StatFS ) ,
75
75
}
76
76
77
77
notMnt , err := mount .IsNotMountPoint (mount .New ("" ), f .tempfsPath ())
@@ -110,7 +110,7 @@ func (f *Filesystem) ListVolumes() ([]string, error) {
110
110
111
111
var vols []string
112
112
for _ , dir := range dirs {
113
- file , err := f .fs .Open (f .metadataPathForVolumeID (dir .Name ()))
113
+ _ , err := f .fs .Stat (f .metadataPathForVolumeID (dir .Name ()))
114
114
switch {
115
115
case errors .Is (err , fs .ErrNotExist ):
116
116
f .log .Info ("Directory exists but does not contain a metadata file - deleting directory and its contents" , "volume_id" , dir .Name ())
@@ -123,8 +123,6 @@ func (f *Filesystem) ListVolumes() ([]string, error) {
123
123
// discovered a volume/directory that does not contain a metadata file
124
124
return nil , err
125
125
}
126
- // immediately close the file as we just need to verify it exists
127
- file .Close ()
128
126
vols = append (vols , dir .Name ())
129
127
}
130
128
0 commit comments