@@ -10,42 +10,42 @@ import (
10
10
"strings"
11
11
)
12
12
13
- // SmbStatusServerID represents a server_id output field
14
- type SmbStatusServerID struct {
13
+ // SMBStatusServerID represents a server_id output field
14
+ type SMBStatusServerID struct {
15
15
PID string `json:"pid"`
16
16
TaskID string `json:"task_id"`
17
17
VNN string `json:"vnn"`
18
18
UniqueID string `json:"unique_id"`
19
19
}
20
20
21
- // SmbStatusEncryption represents a encryption output field
22
- type SmbStatusEncryption struct {
21
+ // SMBStatusEncryption represents a encryption output field
22
+ type SMBStatusEncryption struct {
23
23
Cipher string `json:"cipher"`
24
24
Degree string `json:"degree"`
25
25
}
26
26
27
- // SmbStatusSigning represents a signing output field
28
- type SmbStatusSigning struct {
27
+ // SMBStatusSigning represents a signing output field
28
+ type SMBStatusSigning struct {
29
29
Cipher string `json:"cipher"`
30
30
Degree string `json:"degree"`
31
31
}
32
32
33
- // SmbStatusTreeCon represents a 'tcon' output field
34
- type SmbStatusTreeCon struct {
33
+ // SMBStatusTreeCon represents a 'tcon' output field
34
+ type SMBStatusTreeCon struct {
35
35
Service string `json:"service"`
36
- ServerID SmbStatusServerID `json:"server_id"`
36
+ ServerID SMBStatusServerID `json:"server_id"`
37
37
TConID string `json:"tcon_id"`
38
38
SessionID string `json:"session_id"`
39
39
Machine string `json:"machine"`
40
40
ConnectedAt string `json:"connected_at"`
41
- Encryption SmbStatusEncryption `json:"encryption"`
42
- Signing SmbStatusSigning `json:"signing"`
41
+ Encryption SMBStatusEncryption `json:"encryption"`
42
+ Signing SMBStatusSigning `json:"signing"`
43
43
}
44
44
45
- // SmbStatusSession represents a session output field
46
- type SmbStatusSession struct {
45
+ // SMBStatusSession represents a session output field
46
+ type SMBStatusSession struct {
47
47
SessionID string `json:"session_id"`
48
- ServerID SmbStatusServerID `json:"server_id"`
48
+ ServerID SMBStatusServerID `json:"server_id"`
49
49
UID int `json:"uid"`
50
50
GID int `json:"gid"`
51
51
Username string `json:"username"`
@@ -57,45 +57,45 @@ type SmbStatusSession struct {
57
57
Hostname string `json:"hostname"`
58
58
SessionDialect string `json:"session_dialect"`
59
59
ClientGUID string `json:"client_guid"`
60
- Encryption SmbStatusEncryption `json:"encryption"`
61
- Signing SmbStatusSigning `json:"signing"`
60
+ Encryption SMBStatusEncryption `json:"encryption"`
61
+ Signing SMBStatusSigning `json:"signing"`
62
62
}
63
63
64
- // SmbStatusFileID represents a fileid output field
65
- type SmbStatusFileID struct {
64
+ // SMBStatusFileID represents a fileid output field
65
+ type SMBStatusFileID struct {
66
66
DevID int64 `json:"devid"`
67
67
Inode int64 `json:"inode"`
68
68
Extid int32 `json:"extid"`
69
69
}
70
70
71
- // SmbStatusLockedFile represents a locked-file output field
72
- type SmbStatusLockedFile struct {
71
+ // SMBStatusLockedFile represents a locked-file output field
72
+ type SMBStatusLockedFile struct {
73
73
ServicePath string `json:"service_path"`
74
74
Filename string `json:"filename"`
75
- FileID SmbStatusFileID `json:"fileid"`
75
+ FileID SMBStatusFileID `json:"fileid"`
76
76
NumPendingDeletes int `json:"num_pending_deletes"`
77
77
}
78
78
79
- // SmbStatus represents output of 'smbstatus --json'
80
- type SmbStatus struct {
79
+ // SMBStatus represents output of 'smbstatus --json'
80
+ type SMBStatus struct {
81
81
Timestamp string `json:"timestamp"`
82
82
Version string `json:"version"`
83
83
SmbConf string `json:"smb_conf"`
84
- Sessions map [string ]SmbStatusSession `json:"sessions"`
85
- TCons map [string ]SmbStatusTreeCon `json:"tcons"`
86
- LockedFiles map [string ]SmbStatusLockedFile `json:"locked_files"`
84
+ Sessions map [string ]SMBStatusSession `json:"sessions"`
85
+ TCons map [string ]SMBStatusTreeCon `json:"tcons"`
86
+ LockedFiles map [string ]SMBStatusLockedFile `json:"locked_files"`
87
87
}
88
88
89
- // SmbStatusLocks represents output of 'smbstatus -L --json'
90
- type SmbStatusLocks struct {
89
+ // SMBStatusLocks represents output of 'smbstatus -L --json'
90
+ type SMBStatusLocks struct {
91
91
Timestamp string `json:"timestamp"`
92
92
Version string `json:"version"`
93
93
SmbConf string `json:"smb_conf"`
94
- OpenFiles map [string ]SmbStatusLockedFile `json:"open_files"`
94
+ OpenFiles map [string ]SMBStatusLockedFile `json:"open_files"`
95
95
}
96
96
97
- // LocateSmbStatus finds the local executable of 'smbstatus' on host.
98
- func LocateSmbStatus () (string , error ) {
97
+ // LocateSMBStatus finds the local executable of 'smbstatus' on host.
98
+ func LocateSMBStatus () (string , error ) {
99
99
knowns := []string {
100
100
"/usr/bin/smbstatus" ,
101
101
}
@@ -115,27 +115,27 @@ func LocateSmbStatus() (string, error) {
115
115
return "" , errors .New ("failed to locate smbstatus" )
116
116
}
117
117
118
- // RunSmbStatusVersion executes 'smbstatus --version' on host container
119
- func RunSmbStatusVersion () (string , error ) {
120
- ver , err := executeSmbStatusCommand ("--version" )
118
+ // RunSMBStatusVersion executes 'smbstatus --version' on host container
119
+ func RunSMBStatusVersion () (string , error ) {
120
+ ver , err := executeSMBStatusCommand ("--version" )
121
121
if err != nil {
122
122
return "" , err
123
123
}
124
124
return ver , nil
125
125
}
126
126
127
- // RunSmbStatusShares executes 'smbstatus --shares --json' on host
128
- func RunSmbStatusShares () ([]SmbStatusTreeCon , error ) {
129
- dat , err := executeSmbStatusCommand ("--shares --json" )
127
+ // RunSMBStatusShares executes 'smbstatus --shares --json' on host
128
+ func RunSMBStatusShares () ([]SMBStatusTreeCon , error ) {
129
+ dat , err := executeSMBStatusCommand ("--shares --json" )
130
130
if err != nil {
131
- return []SmbStatusTreeCon {}, err
131
+ return []SMBStatusTreeCon {}, err
132
132
}
133
- return parseSmbStatusTreeCons (dat )
133
+ return parseSMBStatusTreeCons (dat )
134
134
}
135
135
136
- func parseSmbStatusTreeCons (dat string ) ([]SmbStatusTreeCon , error ) {
137
- tcons := []SmbStatusTreeCon {}
138
- res , err := parseSmbStatus (dat )
136
+ func parseSMBStatusTreeCons (dat string ) ([]SMBStatusTreeCon , error ) {
137
+ tcons := []SMBStatusTreeCon {}
138
+ res , err := parseSMBStatus (dat )
139
139
if err != nil {
140
140
return tcons , err
141
141
}
@@ -145,18 +145,18 @@ func parseSmbStatusTreeCons(dat string) ([]SmbStatusTreeCon, error) {
145
145
return tcons , nil
146
146
}
147
147
148
- // RunSmbStatusLocks executes 'smbstatus --locks --json' on host
149
- func RunSmbStatusLocks () ([]SmbStatusLockedFile , error ) {
150
- dat , err := executeSmbStatusCommand ("--locks --json" )
148
+ // RunSMBStatusLocks executes 'smbstatus --locks --json' on host
149
+ func RunSMBStatusLocks () ([]SMBStatusLockedFile , error ) {
150
+ dat , err := executeSMBStatusCommand ("--locks --json" )
151
151
if err != nil {
152
- return []SmbStatusLockedFile {}, err
152
+ return []SMBStatusLockedFile {}, err
153
153
}
154
- return parseSmbStatusLockedFiles (dat )
154
+ return parseSMBStatusLockedFiles (dat )
155
155
}
156
156
157
- func parseSmbStatusLockedFiles (dat string ) ([]SmbStatusLockedFile , error ) {
158
- lockedFiles := []SmbStatusLockedFile {}
159
- res , err := parseSmbStatusLocks (dat )
157
+ func parseSMBStatusLockedFiles (dat string ) ([]SMBStatusLockedFile , error ) {
158
+ lockedFiles := []SMBStatusLockedFile {}
159
+ res , err := parseSMBStatusLocks (dat )
160
160
if err != nil {
161
161
return lockedFiles , err
162
162
}
@@ -166,26 +166,26 @@ func parseSmbStatusLockedFiles(dat string) ([]SmbStatusLockedFile, error) {
166
166
return lockedFiles , nil
167
167
}
168
168
169
- // SmbStatusSharesByMachine converts the output of RunSmbStatusShares into map
169
+ // SMBStatusSharesByMachine converts the output of RunSMBStatusShares into map
170
170
// indexed by machine's host
171
- func SmbStatusSharesByMachine () (map [string ][]SmbStatusTreeCon , error ) {
172
- tcons , err := RunSmbStatusShares ()
171
+ func SMBStatusSharesByMachine () (map [string ][]SMBStatusTreeCon , error ) {
172
+ tcons , err := RunSMBStatusShares ()
173
173
if err != nil {
174
- return map [string ][]SmbStatusTreeCon {}, err
174
+ return map [string ][]SMBStatusTreeCon {}, err
175
175
}
176
176
return makeSmbSharesMap (tcons ), nil
177
177
}
178
178
179
- func makeSmbSharesMap (tcons []SmbStatusTreeCon ) map [string ][]SmbStatusTreeCon {
180
- ret := map [string ][]SmbStatusTreeCon {}
179
+ func makeSmbSharesMap (tcons []SMBStatusTreeCon ) map [string ][]SMBStatusTreeCon {
180
+ ret := map [string ][]SMBStatusTreeCon {}
181
181
for _ , share := range tcons {
182
182
ret [share .Machine ] = append (ret [share .Machine ], share )
183
183
}
184
184
return ret
185
185
}
186
186
187
- func executeSmbStatusCommand (args ... string ) (string , error ) {
188
- loc , err := LocateSmbStatus ()
187
+ func executeSMBStatusCommand (args ... string ) (string , error ) {
188
+ loc , err := LocateSMBStatus ()
189
189
if err != nil {
190
190
return "" , err
191
191
}
@@ -202,18 +202,18 @@ func executeCommand(command string, arg ...string) (string, error) {
202
202
return res , nil
203
203
}
204
204
205
- // parseSmbStatus parses to output of 'smbstatus --json' into internal
205
+ // parseSMBStatus parses to output of 'smbstatus --json' into internal
206
206
// representation.
207
- func parseSmbStatus (data string ) (* SmbStatus , error ) {
208
- res := SmbStatus {}
207
+ func parseSMBStatus (data string ) (* SMBStatus , error ) {
208
+ res := SMBStatus {}
209
209
err := json .Unmarshal ([]byte (data ), & res )
210
210
return & res , err
211
211
}
212
212
213
- // parseSmbStatusLocks parses to output of 'smbstatus --locks --json' into
213
+ // parseSMBStatusLocks parses to output of 'smbstatus --locks --json' into
214
214
// internal representation.
215
- func parseSmbStatusLocks (data string ) (* SmbStatusLocks , error ) {
216
- res := SmbStatusLocks {}
215
+ func parseSMBStatusLocks (data string ) (* SMBStatusLocks , error ) {
216
+ res := SMBStatusLocks {}
217
217
err := json .Unmarshal ([]byte (data ), & res )
218
218
return & res , err
219
219
}
0 commit comments