Skip to content

Commit

Permalink
Replace kernelFSID with unix.Fsid
Browse files Browse the repository at this point in the history
  • Loading branch information
opcoder0 committed Dec 23, 2022
1 parent a06014e commit 05ab819
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions fanotify_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@ type fanotifyEventInfoHeader struct {
Len uint16
}

type kernelFSID struct {
val [2]int32
}

// FanotifyEventInfoFID represents a unique file identifier info record.
// This structure is used for records of types FAN_EVENT_INFO_TYPE_FID,
// FAN_EVENT_INFO_TYPE_DFID and FAN_EVENT_INFO_TYPE_DFID_NAME.
// For FAN_EVENT_INFO_TYPE_DFID_NAME there is additionally a null terminated
// name immediately after the file handle.
type fanotifyEventInfoFID struct {
Header fanotifyEventInfoHeader
fsid kernelFSID
fsid unix.Fsid
fileHandle byte
}

Expand Down Expand Up @@ -332,7 +328,7 @@ func getFileHandle(metadataLen uint16, buf []byte, i int) *unix.FileHandle {
var fhType int32 // this is int handle_type; but Go uses int32

sizeOfFanotifyEventInfoHeader := uint32(unsafe.Sizeof(fanotifyEventInfoHeader{}))
sizeOfKernelFSIDType := uint32(unsafe.Sizeof(kernelFSID{}))
sizeOfKernelFSIDType := uint32(unsafe.Sizeof(unix.Fsid{}))
sizeOfUint32 := uint32(unsafe.Sizeof(fhSize))
j := uint32(i) + uint32(metadataLen) + sizeOfFanotifyEventInfoHeader + sizeOfKernelFSIDType
binary.Read(bytes.NewReader(buf[j:j+sizeOfUint32]), binary.LittleEndian, &fhSize)
Expand All @@ -350,7 +346,7 @@ func getFileHandleWithName(metadataLen uint16, buf []byte, i int) (*unix.FileHan
var nameBytes bytes.Buffer

sizeOfFanotifyEventInfoHeader := uint32(unsafe.Sizeof(fanotifyEventInfoHeader{}))
sizeOfKernelFSIDType := uint32(unsafe.Sizeof(kernelFSID{}))
sizeOfKernelFSIDType := uint32(unsafe.Sizeof(unix.Fsid{}))
sizeOfUint32 := uint32(unsafe.Sizeof(fhSize))
j := uint32(i) + uint32(metadataLen) + sizeOfFanotifyEventInfoHeader + sizeOfKernelFSIDType
binary.Read(bytes.NewReader(buf[j:j+sizeOfUint32]), binary.LittleEndian, &fhSize)
Expand Down

0 comments on commit 05ab819

Please sign in to comment.