File: debug_solaris.go

package info (click to toggle)
golang-fsnotify 1.8.0-3
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 728 kB
  • sloc: ansic: 98; makefile: 4
file content (45 lines) | stat: -rw-r--r-- 965 bytes parent folder | download | duplicates (2)
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
package internal

import (
	"fmt"
	"os"
	"strings"
	"time"

	"golang.org/x/sys/unix"
)

func Debug(name string, mask int32) {
	names := []struct {
		n string
		m int32
	}{
		{"FILE_ACCESS", unix.FILE_ACCESS},
		{"FILE_MODIFIED", unix.FILE_MODIFIED},
		{"FILE_ATTRIB", unix.FILE_ATTRIB},
		{"FILE_TRUNC", unix.FILE_TRUNC},
		{"FILE_NOFOLLOW", unix.FILE_NOFOLLOW},
		{"FILE_DELETE", unix.FILE_DELETE},
		{"FILE_RENAME_TO", unix.FILE_RENAME_TO},
		{"FILE_RENAME_FROM", unix.FILE_RENAME_FROM},
		{"UNMOUNTED", unix.UNMOUNTED},
		{"MOUNTEDOVER", unix.MOUNTEDOVER},
		{"FILE_EXCEPTION", unix.FILE_EXCEPTION},
	}

	var (
		l       []string
		unknown = mask
	)
	for _, n := range names {
		if mask&n.m == n.m {
			l = append(l, n.n)
			unknown ^= n.m
		}
	}
	if unknown > 0 {
		l = append(l, fmt.Sprintf("0x%x", unknown))
	}
	fmt.Fprintf(os.Stderr, "FSNOTIFY_DEBUG: %s  %10d:%-30s → %q\n",
		time.Now().Format("15:04:05.000000000"), mask, strings.Join(l, " | "), name)
}