GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — locks/merge_linux_test.go at master · asciimoth/locks

Expand file tree

/

merge_linux_test.go

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
70 lines (67 loc) · 1.84 KB
/

merge_linux_test.go

Copy path

File metadata and controls

70 lines (67 loc) · 1.84 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package locks
import (
"bytes"
"encoding/binary"
"errors"
"os"
"path/filepath"
"testing"
"golang.org/x/sys/unix"
)
func TestMergeMetadata(t *testing.T) {
for _, mismatch := range []bool{false, true} {
s, path := healthStore(t)
seedMergeTree(t, s, healthRecords(t, 2), 1)
acl := make([]byte, 4+5*8)
binary.LittleEndian.PutUint32(acl, 2)
for i, entry := range []struct {
tag, perm uint16
id uint32
}{
{1, 6, ^uint32(0)}, {2, 4, uint32(os.Getuid() + 1)}, {4, 0, ^uint32(0)}, {16, 4, ^uint32(0)}, {32, 0, ^uint32(0)},
} {
at := 4 + i*8
binary.LittleEndian.PutUint16(acl[at:], entry.tag)
binary.LittleEndian.PutUint16(acl[at+2:], entry.perm)
binary.LittleEndian.PutUint32(acl[at+4:], entry.id)
}
if err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if err = unix.Setxattr(path, "user.merge-test", []byte("kept"), 0); err != nil {
return err
}
value := bytes.Clone(acl)
prepareXattr("system.posix_acl_access", value, info.IsDir())
return unix.Setxattr(path, "system.posix_acl_access", value, 0)
}); err != nil {
t.Skip("ACLs unavailable", err)
}
if mismatch {
entries, err := os.ReadDir(path)
if err != nil {
t.Fatal(err)
}
if err := unix.Setxattr(filepath.Join(path, entries[1].Name()), "user.merge-test", []byte("different"), 0); err != nil {
t.Fatal(err)
}
if err := mergeRepair(s); !errors.Is(err, ErrDenied) {
t.Fatal(err)
}
continue
}
if err := mergeRepair(s); err != nil {
t.Fatal(err)
}
buf := make([]byte, 256)
n, err := unix.Getxattr(path, "user.merge-test", buf)
if err != nil || string(buf[:n]) != "kept" {
t.Fatal(n, err)
}
n, err = unix.Getxattr(path, "system.posix_acl_access", buf)
if err != nil || !bytes.Equal(buf[:n], acl) {
t.Fatal(n, err)
}
}
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.