forked from TrueCloudLab/restic
fs: drop unused permission parameter from OpenFile
This commit is contained in:
parent
b402e8a6fc
commit
623ba92b98
12 changed files with 25 additions and 25 deletions
|
@ -497,7 +497,7 @@ func (arch *Archiver) save(ctx context.Context, snPath, target string, previous
|
|||
|
||||
// reopen file and do an fstat() on the open file to check it is still
|
||||
// a file (and has not been exchanged for e.g. a symlink)
|
||||
file, err := arch.FS.OpenFile(target, fs.O_RDONLY|fs.O_NOFOLLOW, 0)
|
||||
file, err := arch.FS.OpenFile(target, fs.O_RDONLY|fs.O_NOFOLLOW)
|
||||
if err != nil {
|
||||
debug.Log("Openfile() for %v returned error: %v", target, err)
|
||||
return filterError(err)
|
||||
|
|
|
@ -76,7 +76,7 @@ func saveFile(t testing.TB, repo archiverRepo, filename string, filesystem fs.FS
|
|||
startCallback = true
|
||||
}
|
||||
|
||||
file, err := arch.FS.OpenFile(filename, fs.O_RDONLY|fs.O_NOFOLLOW, 0)
|
||||
file, err := arch.FS.OpenFile(filename, fs.O_RDONLY|fs.O_NOFOLLOW)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -1665,8 +1665,8 @@ type MockFS struct {
|
|||
bytesRead map[string]int // tracks bytes read from all opened files
|
||||
}
|
||||
|
||||
func (m *MockFS) OpenFile(name string, flag int, perm os.FileMode) (fs.File, error) {
|
||||
f, err := m.FS.OpenFile(name, flag, perm)
|
||||
func (m *MockFS) OpenFile(name string, flag int) (fs.File, error) {
|
||||
f, err := m.FS.OpenFile(name, flag)
|
||||
if err != nil {
|
||||
return f, err
|
||||
}
|
||||
|
@ -2056,12 +2056,12 @@ type TrackFS struct {
|
|||
m sync.Mutex
|
||||
}
|
||||
|
||||
func (m *TrackFS) OpenFile(name string, flag int, perm os.FileMode) (fs.File, error) {
|
||||
func (m *TrackFS) OpenFile(name string, flag int) (fs.File, error) {
|
||||
m.m.Lock()
|
||||
m.opened[name]++
|
||||
m.m.Unlock()
|
||||
|
||||
return m.FS.OpenFile(name, flag, perm)
|
||||
return m.FS.OpenFile(name, flag)
|
||||
}
|
||||
|
||||
type failSaveRepo struct {
|
||||
|
@ -2228,9 +2228,9 @@ func (fs *StatFS) Lstat(name string) (os.FileInfo, error) {
|
|||
return fs.FS.Lstat(name)
|
||||
}
|
||||
|
||||
func (fs *StatFS) OpenFile(name string, flags int, perm os.FileMode) (fs.File, error) {
|
||||
func (fs *StatFS) OpenFile(name string, flags int) (fs.File, error) {
|
||||
if fi, ok := fs.OverrideLstat[fixpath(name)]; ok {
|
||||
f, err := fs.FS.OpenFile(name, flags, perm)
|
||||
f, err := fs.FS.OpenFile(name, flags)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -2242,7 +2242,7 @@ func (fs *StatFS) OpenFile(name string, flags int, perm os.FileMode) (fs.File, e
|
|||
return wrappedFile, nil
|
||||
}
|
||||
|
||||
return fs.FS.OpenFile(name, flags, perm)
|
||||
return fs.FS.OpenFile(name, flags)
|
||||
}
|
||||
|
||||
type fileStat struct {
|
||||
|
|
|
@ -153,7 +153,7 @@ func isDirExcludedByFile(dir, tagFilename, header string, fs fs.FS, warnf func(m
|
|||
// From this stage, errors mean tagFilename exists but it is malformed.
|
||||
// Warnings will be generated so that the user is informed that the
|
||||
// indented ignore-action is not performed.
|
||||
f, err := fs.OpenFile(tf, os.O_RDONLY, 0)
|
||||
f, err := fs.OpenFile(tf, os.O_RDONLY)
|
||||
if err != nil {
|
||||
warnf("could not open exclusion tagfile: %v", err)
|
||||
return false
|
||||
|
|
|
@ -72,7 +72,7 @@ func TestFileSaver(t *testing.T) {
|
|||
var results []futureNode
|
||||
|
||||
for _, filename := range files {
|
||||
f, err := testFs.OpenFile(filename, os.O_RDONLY, 0)
|
||||
f, err := testFs.OpenFile(filename, os.O_RDONLY)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ func ResetPermissions(path string) error {
|
|||
// Readdirnames returns a list of file in a directory. Flags are passed to fs.OpenFile.
|
||||
// O_RDONLY and O_DIRECTORY are implied.
|
||||
func Readdirnames(filesystem FS, dir string, flags int) ([]string, error) {
|
||||
f, err := filesystem.OpenFile(dir, O_RDONLY|O_DIRECTORY|flags, 0)
|
||||
f, err := filesystem.OpenFile(dir, O_RDONLY|O_DIRECTORY|flags)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("openfile for readdirnames failed: %w", err)
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ func (fs Local) VolumeName(path string) string {
|
|||
// (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful,
|
||||
// methods on the returned File can be used for I/O.
|
||||
// If there is an error, it will be of type *PathError.
|
||||
func (fs Local) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
|
||||
f, err := os.OpenFile(fixpath(name), flag, perm)
|
||||
func (fs Local) OpenFile(name string, flag int) (File, error) {
|
||||
f, err := os.OpenFile(fixpath(name), flag, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -127,8 +127,8 @@ func (fs *LocalVss) DeleteSnapshots() {
|
|||
}
|
||||
|
||||
// OpenFile wraps the Open method of the underlying file system.
|
||||
func (fs *LocalVss) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
|
||||
return fs.FS.OpenFile(fs.snapshotPath(name), flag, perm)
|
||||
func (fs *LocalVss) OpenFile(name string, flag int) (File, error) {
|
||||
return fs.FS.OpenFile(fs.snapshotPath(name), flag)
|
||||
}
|
||||
|
||||
// Stat wraps the Stat method of the underlying file system.
|
||||
|
|
|
@ -331,7 +331,7 @@ func TestVSSFS(t *testing.T) {
|
|||
rtest.OK(t, err)
|
||||
rtest.Equals(t, origFi.Mode(), lstatFi.Mode())
|
||||
|
||||
f, err := localVss.OpenFile(tempfile, os.O_RDONLY, 0)
|
||||
f, err := localVss.OpenFile(tempfile, os.O_RDONLY)
|
||||
rtest.OK(t, err)
|
||||
data, err := io.ReadAll(f)
|
||||
rtest.OK(t, err)
|
||||
|
|
|
@ -54,7 +54,7 @@ func (fs *Reader) fi() os.FileInfo {
|
|||
// (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful,
|
||||
// methods on the returned File can be used for I/O.
|
||||
// If there is an error, it will be of type *os.PathError.
|
||||
func (fs *Reader) OpenFile(name string, flag int, _ os.FileMode) (f File, err error) {
|
||||
func (fs *Reader) OpenFile(name string, flag int) (f File, err error) {
|
||||
if flag & ^(O_RDONLY|O_NOFOLLOW) != 0 {
|
||||
return nil, pathError("open", name,
|
||||
fmt.Errorf("invalid combination of flags 0x%x", flag))
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
)
|
||||
|
||||
func verifyFileContentOpenFile(t testing.TB, fs FS, filename string, want []byte) {
|
||||
f, err := fs.OpenFile(filename, O_RDONLY, 0)
|
||||
f, err := fs.OpenFile(filename, O_RDONLY)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func verifyFileContentOpenFile(t testing.TB, fs FS, filename string, want []byte
|
|||
}
|
||||
|
||||
func verifyDirectoryContents(t testing.TB, fs FS, dir string, want []string) {
|
||||
f, err := fs.OpenFile(dir, os.O_RDONLY, 0)
|
||||
f, err := fs.OpenFile(dir, os.O_RDONLY)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ func TestFSReader(t *testing.T) {
|
|||
{
|
||||
name: "file/Stat",
|
||||
f: func(t *testing.T, fs FS) {
|
||||
f, err := fs.OpenFile(filename, os.O_RDONLY, 0)
|
||||
f, err := fs.OpenFile(filename, os.O_RDONLY)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ func TestFSReaderMinFileSize(t *testing.T) {
|
|||
AllowEmptyFile: test.allowEmpty,
|
||||
}
|
||||
|
||||
f, err := fs.OpenFile("testfile", os.O_RDONLY, 0)
|
||||
f, err := fs.OpenFile("testfile", os.O_RDONLY)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ type Track struct {
|
|||
}
|
||||
|
||||
// OpenFile wraps the OpenFile method of the underlying file system.
|
||||
func (fs Track) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
|
||||
f, err := fs.FS.OpenFile(fixpath(name), flag, perm)
|
||||
func (fs Track) OpenFile(name string, flag int) (File, error) {
|
||||
f, err := fs.FS.OpenFile(fixpath(name), flag)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
// FS bundles all methods needed for a file system.
|
||||
type FS interface {
|
||||
OpenFile(name string, flag int, perm os.FileMode) (File, error)
|
||||
OpenFile(name string, flag int) (File, error)
|
||||
Stat(name string) (os.FileInfo, error)
|
||||
Lstat(name string) (os.FileInfo, error)
|
||||
DeviceID(fi os.FileInfo) (deviceID uint64, err error)
|
||||
|
|
Loading…
Reference in a new issue