summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-21 12:28:12 +0200
committerPaul Buetow <paul@buetow.org>2026-02-21 12:28:12 +0200
commit480162734c196b4b966a7f5a1c5df3749cd129c6 (patch)
tree31406644a6625a5d38d309d9219682c65e22fbb3 /internal
parent776910425e216bd2db9fbd78bfea8508ba7076c4 (diff)
Handle unknown flags for openat2
Amp-Thread-ID: https://ampcode.com/threads/T-019c7faf-baaa-704f-af15-8aeba9df4628 Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'internal')
-rw-r--r--internal/file/file.go18
-rw-r--r--internal/file/file_test.go17
2 files changed, 21 insertions, 14 deletions
diff --git a/internal/file/file.go b/internal/file/file.go
index 85894c9..ff8dae2 100644
--- a/internal/file/file.go
+++ b/internal/file/file.go
@@ -24,15 +24,15 @@ type FdFile struct {
}
func NewFd(fd int32, name string, flags int32) FdFile {
- f := FdFile{
- fd: fd,
- name: name,
- flags: Flags(flags),
- }
- if f.flags == -1 {
- panic(fmt.Sprintf("DEBUG with -1 flags: %v", f))
- }
- return f
+ f := FdFile{
+ fd: fd,
+ name: name,
+ flags: Flags(flags),
+ }
+ if f.flags == -1 {
+ f.flags = unknownFlag
+ }
+ return f
}
func NewFdWithPid(fd int32, pid uint32) (f FdFile) {
diff --git a/internal/file/file_test.go b/internal/file/file_test.go
index 22610ea..726de5a 100644
--- a/internal/file/file_test.go
+++ b/internal/file/file_test.go
@@ -6,10 +6,17 @@ import (
)
func TestStringValue(t *testing.T) {
- var array [128]byte
- copy(array[:], "test string")
+ var array [128]byte
+ copy(array[:], "test string")
- if str := types.StringValue(array[:]); str != "test string" {
- t.Errorf("epxected 'test string' but got '%s' with bytes '%v'", str, []byte(str))
- }
+ if str := types.StringValue(array[:]); str != "test string" {
+ t.Errorf("epxected 'test string' but got '%s' with bytes '%v'", str, []byte(str))
+ }
+}
+
+func TestNewFdUnknownFlags(t *testing.T) {
+ fdFile := NewFd(1, "test.txt", -1)
+ if fdFile.Flags() != unknownFlag {
+ t.Errorf("expected unknown flags, got %v", fdFile.Flags())
+ }
}