File: mount_ring.go

package info (click to toggle)
golang-gvisor-gvisor 0.0~20240729.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,276 kB
  • sloc: asm: 3,361; ansic: 1,197; cpp: 348; makefile: 92; python: 89; sh: 83
file content (66 lines) | stat: -rw-r--r-- 1,204 bytes parent folder | download | duplicates (3)
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
package vfs

// Entry is an element in the circular linked list.
//
// +stateify savable
type mountEntry struct {
	next      *mountEntry
	prev      *mountEntry
	container *Mount
}

// Init instantiates an Element to be an item in a ring (circularly-linked
// list).
//
//go:nosplit
func (e *mountEntry) Init(container *Mount) {
	e.next = e
	e.prev = e
	e.container = container
}

// Add adds new to old's ring.
//
//go:nosplit
func (e *mountEntry) Add(new *mountEntry) {
	next := e.next
	prev := e

	next.prev = new
	new.next = next
	new.prev = prev
	e.next = new
}

// Remove removes e from its ring and reinitializes it.
//
//go:nosplit
func (e *mountEntry) Remove() {
	next := e.next
	prev := e.prev

	next.prev = prev
	prev.next = next
	e.Init(e.container)
}

// Empty returns true if there are no other elements in the ring.
//
//go:nosplit
func (e *mountEntry) Empty() bool {
	return e.next == e
}

// Next returns the next containing object pointed to by the list.
//
//go:nosplit
func (e *mountEntry) Next() *Mount {
	return e.next.container
}

// Prev returns the previous containing object pointed to by the list.
//
//go:nosplit
func (e *mountEntry) Prev() *Mount {
	return e.prev.container
}