Skip to content

Commit dceed30

Browse files
committed
Dedup AFP file/dir bitmap constants onto core/protocol/afp (P2, part 1)
core/service/afp/parms.go redefined its own fdBitmap*/fileBitmap*/ dirBitmap* constants -- an exact byte-for-byte duplicate (same names minus casing, same bit values) of core/protocol/afp's already-exported FDBitmap*/FileBitmap*/DirBitmap* constants in afp.go. Per the plan's staged approach (constants first as the near-zero-risk half of the AFP DTO-duplication cleanup, struct unification separately since that's the higher-blast-radius half): deleted the private const block and repointed every one of its 18 usages, across 11 files, at the protocol package (aliased `protocol`, matching the core/service/smb -> core/protocol/smb convention already used elsewhere in this codebase, since core/protocol/afp and core/service/afp share the plain package name "afp"). Careful about the false-positive collision here: catsearch.go/ handlers.go/dispatch_test.go also have LOCAL VARIABLES literally named `fileBitmap`/`dirBitmap` (the request-parsed runtime values, completely unrelated to the exported constants of almost the same name) -- confirmed the replacement only touched the 18 specific full constant identifiers (fdBitmapAttributes, fileBitmapFileNum, etc.), never the bare local-variable names, before running it. No new tests added for this pass: the existing service/afp test suite (parms_test.go, catsearch_test.go, dispatch_test.go, golden_test.go, forkio_test.go, and the rest -- 109 passing subtests) already exercises every bitmap path this touches and is the safety net a pure constant-value rename needs; nothing here changes behavior. Full build/vet/test/archtest swept clean after.
1 parent ec1a14e commit dceed30

11 files changed

Lines changed: 114 additions & 126 deletions

File tree

core/service/afp/catsearch.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
bp "github.com/ObsoleteMadness/ClassicStack/core/binaryprimitives"
77
"github.com/ObsoleteMadness/ClassicStack/core/fs"
8+
protocol "github.com/ObsoleteMadness/ClassicStack/core/protocol/afp"
89
)
910

1011
// FPCatSearch (Inside Macintosh: Networking, AFP 2.1 §"FPCatSearch") searches a
@@ -91,8 +92,8 @@ func (s *Service) afpCatSearch(a *afpSession, block []byte) ([]byte, int32) {
9192
// A search asking for neither file nor dir parameters has nothing to return;
9293
// default both to long-name+parent so a bitmap-0 client still gets usable hits.
9394
if fileBitmap == 0 && dirBitmap == 0 {
94-
fileBitmap = fdBitmapLongName | fdBitmapParentDID | fileBitmapFileNum
95-
dirBitmap = fdBitmapLongName | fdBitmapParentDID | dirBitmapDirID
95+
fileBitmap = protocol.FDBitmapLongName | protocol.FDBitmapParentDID | protocol.FileBitmapFileNum
96+
dirBitmap = protocol.FDBitmapLongName | protocol.FDBitmapParentDID | protocol.DirBitmapDirID
9697
}
9798

9899
results, next, err := searcher.CatSearch(crit, cursor)

core/service/afp/catsearch_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
bp "github.com/ObsoleteMadness/ClassicStack/core/binaryprimitives"
8+
protocol "github.com/ObsoleteMadness/ClassicStack/core/protocol/afp"
89
)
910

1011
// catSearchReq builds an FPCatSearch command block: a partial- or full-name
@@ -46,7 +47,7 @@ func catSearchReq(volID uint16, reqMatches int, cursor [16]byte, fileBitmap, dir
4647
// long names it carries. Each record is StructLength(1) fileDir(1) then a
4748
// parameter block whose LongName field is a 2-byte offset (from the start of the
4849
// parameter block, i.e. just after the fileDir byte) to a Pascal string. The test
49-
// requests fdBitmapLongName as the first (and here only addressed) field, so the
50+
// requests protocol.FDBitmapLongName as the first (and here only addressed) field, so the
5051
// LongName offset pointer is the first packed field.
5152
func catSearchNames(t *testing.T, reply []byte) []string {
5253
t.Helper()
@@ -98,7 +99,7 @@ func TestCatSearch_PartialNameAcrossTree(t *testing.T) {
9899
sessID, volID := openVolForFork(t, svc, r)
99100

100101
var zero [16]byte
101-
req := catSearchReq(volID, 50, zero, fdBitmapLongName|fileBitmapFileNum, 0, true, "report")
102+
req := catSearchReq(volID, 50, zero, protocol.FDBitmapLongName|protocol.FileBitmapFileNum, 0, true, "report")
102103
code, reply := sendCmd(t, svc, r, sessID, 9, req)
103104
// Last page (all results fit) → kFPEOFErr per AFP/Netatalk convention.
104105
if code != afpErrEOFErr && code != afpNoErr {
@@ -124,7 +125,7 @@ func TestCatSearch_FullNameExact(t *testing.T) {
124125
sessID, volID := openVolForFork(t, svc, r)
125126

126127
var zero [16]byte
127-
req := catSearchReq(volID, 50, zero, fdBitmapLongName, 0, false /*full*/, "ALPHA.TXT")
128+
req := catSearchReq(volID, 50, zero, protocol.FDBitmapLongName, 0, false /*full*/, "ALPHA.TXT")
128129
_, reply := sendCmd(t, svc, r, sessID, 9, req)
129130
names := catSearchNames(t, reply)
130131
if !contains(names, "alpha.txt") {
@@ -149,7 +150,7 @@ func TestCatSearch_Paged(t *testing.T) {
149150

150151
// Page 1: ask for 2 of the 3 "hit-" files.
151152
var zero [16]byte
152-
req := catSearchReq(volID, 2, zero, fdBitmapLongName, 0, true, "hit-")
153+
req := catSearchReq(volID, 2, zero, protocol.FDBitmapLongName, 0, true, "hit-")
153154
code, reply := sendCmd(t, svc, r, sessID, 9, req)
154155
if code != afpNoErr {
155156
t.Fatalf("CatSearch page 1 result = %d, want NoErr (more pages follow)", code)
@@ -167,7 +168,7 @@ func TestCatSearch_Paged(t *testing.T) {
167168
}
168169

169170
// Page 2: resume from the cursor; should get the remaining hit and finish.
170-
req2 := catSearchReq(volID, 2, cursor, fdBitmapLongName, 0, true, "hit-")
171+
req2 := catSearchReq(volID, 2, cursor, protocol.FDBitmapLongName, 0, true, "hit-")
171172
code, reply = sendCmd(t, svc, r, sessID, 10, req2)
172173
if code != afpErrEOFErr {
173174
t.Fatalf("CatSearch page 2 result = %d, want EOFErr (last page)", code)
@@ -211,7 +212,7 @@ func TestCatSearch_PayloadCapPagesForward(t *testing.T) {
211212
packed := 0
212213
pages := 0
213214
for seq := uint16(9); ; seq++ {
214-
req := catSearchReq(volID, 1000, cursor, fdBitmapLongName, 0, true, "hit-")
215+
req := catSearchReq(volID, 1000, cursor, protocol.FDBitmapLongName, 0, true, "hit-")
215216
code, reply := sendCmd(t, svc, r, sessID, seq, req)
216217
pages++
217218
if pages > 20 {

core/service/afp/conn_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
bp "github.com/ObsoleteMadness/ClassicStack/core/binaryprimitives"
77
"github.com/ObsoleteMadness/ClassicStack/core/fs"
8+
protocol "github.com/ObsoleteMadness/ClassicStack/core/protocol/afp"
89
)
910

1011
// newSeamService builds an AFP service with one memfs volume but NO router and NO
@@ -109,7 +110,7 @@ func TestConn_FullSequenceOverSeam(t *testing.T) {
109110
openFork := []byte{cmdOpenFork, forkFlagData}
110111
openFork = bp.AppendBE16(openFork, volID)
111112
openFork = bp.AppendBE32(openFork, 2) // dirID root
112-
openFork = bp.AppendBE16(openFork, fileBitmapDataForkLen)
113+
openFork = bp.AppendBE16(openFork, protocol.FileBitmapDataForkLen)
113114
openFork = bp.AppendBE16(openFork, accessRead|accessWrite)
114115
openFork = append(openFork, PathTypeUTF8Names)
115116
openFork = putPString(openFork, []byte("doc.txt"))
@@ -138,7 +139,7 @@ func TestConn_CloseDrainsForks(t *testing.T) {
138139
openFork := []byte{cmdOpenFork, forkFlagData}
139140
openFork = bp.AppendBE16(openFork, volID)
140141
openFork = bp.AppendBE32(openFork, 2)
141-
openFork = bp.AppendBE16(openFork, fileBitmapDataForkLen)
142+
openFork = bp.AppendBE16(openFork, protocol.FileBitmapDataForkLen)
142143
openFork = bp.AppendBE16(openFork, accessRead|accessWrite)
143144
openFork = append(openFork, PathTypeUTF8Names)
144145
openFork = putPString(openFork, []byte("doc.txt"))

core/service/afp/desktop_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
bp "github.com/ObsoleteMadness/ClassicStack/core/binaryprimitives"
77

8+
protocol "github.com/ObsoleteMadness/ClassicStack/core/protocol/afp"
89
"github.com/ObsoleteMadness/ClassicStack/core/protocol/asp"
910
"github.com/ObsoleteMadness/ClassicStack/core/protocol/atp"
1011
)
@@ -270,13 +271,13 @@ func TestDesktop_APPLRoundTrip(t *testing.T) {
270271
getAppl = bp.AppendBE16(getAppl, dtRef)
271272
getAppl = append(getAppl, creator[:]...)
272273
getAppl = bp.AppendBE16(getAppl, 0) // index
273-
getAppl = bp.AppendBE16(getAppl, fdBitmapLongName)
274+
getAppl = bp.AppendBE16(getAppl, protocol.FDBitmapLongName)
274275
code, reply := sendCmd(t, svc, r, sessID, 7, getAppl)
275276
if code != afpNoErr {
276277
t.Fatalf("GetAPPL result = %d, want 0", code)
277278
}
278-
if bp.BE16(reply[0:2]) != fdBitmapLongName {
279-
t.Errorf("GetAPPL bitmap = %#x, want %#x", bp.BE16(reply[0:2]), fdBitmapLongName)
279+
if bp.BE16(reply[0:2]) != protocol.FDBitmapLongName {
280+
t.Errorf("GetAPPL bitmap = %#x, want %#x", bp.BE16(reply[0:2]), protocol.FDBitmapLongName)
280281
}
281282
if bp.BE32(reply[2:6]) != tag {
282283
t.Errorf("GetAPPL tag = %#x, want %#x", bp.BE32(reply[2:6]), tag)

core/service/afp/dispatch_test.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
bp "github.com/ObsoleteMadness/ClassicStack/core/binaryprimitives"
1111

1212
"github.com/ObsoleteMadness/ClassicStack/core/fs"
13+
protocol "github.com/ObsoleteMadness/ClassicStack/core/protocol/afp"
1314
"github.com/ObsoleteMadness/ClassicStack/core/protocol/asp"
1415
"github.com/ObsoleteMadness/ClassicStack/core/protocol/atp"
1516
"github.com/ObsoleteMadness/ClassicStack/core/protocol/ddp"
@@ -291,8 +292,8 @@ func TestDispatch_LoginGetSrvrParmsOpenVolEnumerate(t *testing.T) {
291292
enum := []byte{cmdEnumerate, 0}
292293
enum = bp.AppendBE16(enum, volID) // volID
293294
enum = bp.AppendBE32(enum, 2) // dirID = root
294-
enum = bp.AppendBE16(enum, fdBitmapLongName|fileBitmapDataForkLen)
295-
enum = bp.AppendBE16(enum, fdBitmapLongName|dirBitmapOffspring)
295+
enum = bp.AppendBE16(enum, protocol.FDBitmapLongName|protocol.FileBitmapDataForkLen)
296+
enum = bp.AppendBE16(enum, protocol.FDBitmapLongName|protocol.DirBitmapOffspring)
296297
enum = bp.AppendBE16(enum, 10) // reqCount
297298
enum = bp.AppendBE16(enum, 1) // startIndex (1-based)
298299
enum = bp.AppendBE16(enum, 4624) // maxReplySize
@@ -341,8 +342,8 @@ func TestDispatch_GetFileDirParmsByNameStripsPascalLen(t *testing.T) {
341342
req := []byte{cmdGetFileDirParms, 0}
342343
req = bp.AppendBE16(req, volID)
343344
req = bp.AppendBE32(req, 2) // DID = root
344-
req = bp.AppendBE16(req, fdBitmapLongName)
345-
req = bp.AppendBE16(req, fdBitmapLongName|dirBitmapDirID)
345+
req = bp.AppendBE16(req, protocol.FDBitmapLongName)
346+
req = bp.AppendBE16(req, protocol.FDBitmapLongName|protocol.DirBitmapDirID)
346347
req = append(req, PathTypeUTF8Names)
347348
req = putPString(req, []byte("Configuration"))
348349
svc.Inbound(ddpTo(svc.Socket(), atpTReq(aspUserData(asp.SPFuncCommand, sessID, 4), req)), from)
@@ -382,8 +383,8 @@ func TestDispatch_SubdirDIDRoundTrips(t *testing.T) {
382383
req := []byte{cmdGetFileDirParms, 0}
383384
req = bp.AppendBE16(req, volID)
384385
req = bp.AppendBE32(req, 2)
385-
req = bp.AppendBE16(req, 0) // fileBitmap (n/a, it's a dir)
386-
req = bp.AppendBE16(req, dirBitmapDirID|fdBitmapLongName) // dirBitmap
386+
req = bp.AppendBE16(req, 0) // fileBitmap (n/a, it's a dir)
387+
req = bp.AppendBE16(req, protocol.DirBitmapDirID|protocol.FDBitmapLongName) // dirBitmap
387388
req = append(req, PathTypeUTF8Names)
388389
req = putPString(req, []byte("subdir"))
389390
svc.Inbound(ddpTo(svc.Socket(), atpTReq(aspUserData(asp.SPFuncCommand, sessID, 4), req)), from)
@@ -404,8 +405,8 @@ func TestDispatch_SubdirDIDRoundTrips(t *testing.T) {
404405
enum := []byte{cmdEnumerate, 0}
405406
enum = bp.AppendBE16(enum, volID)
406407
enum = bp.AppendBE32(enum, subdirDID)
407-
enum = bp.AppendBE16(enum, fdBitmapLongName|fileBitmapDataForkLen)
408-
enum = bp.AppendBE16(enum, fdBitmapLongName)
408+
enum = bp.AppendBE16(enum, protocol.FDBitmapLongName|protocol.FileBitmapDataForkLen)
409+
enum = bp.AppendBE16(enum, protocol.FDBitmapLongName)
409410
enum = bp.AppendBE16(enum, 10)
410411
enum = bp.AppendBE16(enum, 1)
411412
enum = bp.AppendBE16(enum, 4624)
@@ -469,8 +470,8 @@ func TestDispatch_EnumeratePagingSkipsHiddenEntriesWithoutDuplicates(t *testing.
469470
enum := []byte{cmdEnumerate, 0}
470471
enum = bp.AppendBE16(enum, volID)
471472
enum = bp.AppendBE32(enum, 2) // dirID = root
472-
enum = bp.AppendBE16(enum, fdBitmapLongName)
473-
enum = bp.AppendBE16(enum, fdBitmapLongName)
473+
enum = bp.AppendBE16(enum, protocol.FDBitmapLongName)
474+
enum = bp.AppendBE16(enum, protocol.FDBitmapLongName)
474475
enum = bp.AppendBE16(enum, pageSize)
475476
enum = bp.AppendBE16(enum, startIndex)
476477
enum = bp.AppendBE16(enum, 4624)
@@ -523,7 +524,7 @@ func TestDispatch_GetFileDirParmsParentOfRootByVolumeName(t *testing.T) {
523524
req = bp.AppendBE16(req, volID)
524525
req = bp.AppendBE32(req, 1) // DID = parent-of-root
525526
req = bp.AppendBE16(req, 0)
526-
req = bp.AppendBE16(req, fdBitmapLongName|dirBitmapDirID)
527+
req = bp.AppendBE16(req, protocol.FDBitmapLongName|protocol.DirBitmapDirID)
527528
req = append(req, PathTypeUTF8Names)
528529
req = putPString(req, []byte("Share"))
529530
svc.Inbound(ddpTo(svc.Socket(), atpTReq(aspUserData(asp.SPFuncCommand, sessID, 4), req)), from)
@@ -540,7 +541,7 @@ func TestDispatch_GetFileDirParmsParentOfRootByVolumeName(t *testing.T) {
540541
req2 = bp.AppendBE16(req2, volID)
541542
req2 = bp.AppendBE32(req2, 1)
542543
req2 = bp.AppendBE16(req2, 0)
543-
req2 = bp.AppendBE16(req2, dirBitmapDirID)
544+
req2 = bp.AppendBE16(req2, protocol.DirBitmapDirID)
544545
req2 = append(req2, PathTypeUTF8Names)
545546
req2 = putPString(req2, []byte("Not The Volume"))
546547
svc.Inbound(ddpTo(svc.Socket(), atpTReq(aspUserData(asp.SPFuncCommand, sessID, 5), req2)), from)
@@ -573,7 +574,7 @@ func TestDispatch_GetFileDirParmsRootHasVolumeName(t *testing.T) {
573574
req = bp.AppendBE16(req, volID)
574575
req = bp.AppendBE32(req, 2) // DID = root
575576
req = bp.AppendBE16(req, 0) // fileBitmap (n/a, root is a dir)
576-
req = bp.AppendBE16(req, fdBitmapLongName|dirBitmapDirID)
577+
req = bp.AppendBE16(req, protocol.FDBitmapLongName|protocol.DirBitmapDirID)
577578
req = append(req, PathTypeUTF8Names)
578579
req = putPString(req, nil) // empty path → the root itself
579580
svc.Inbound(ddpTo(svc.Socket(), atpTReq(aspUserData(asp.SPFuncCommand, sessID, 4), req)), from)
@@ -614,7 +615,7 @@ func TestDispatch_SetFileDirParmsAcksFinderInfo(t *testing.T) {
614615
req := []byte{cmdSetFileDirParms, 0}
615616
req = bp.AppendBE16(req, volID)
616617
req = bp.AppendBE32(req, 2)
617-
req = bp.AppendBE16(req, fdBitmapFinderInfo)
618+
req = bp.AppendBE16(req, protocol.FDBitmapFinderInfo)
618619
req = append(req, PathTypeUTF8Names)
619620
req = putPString(req, []byte("doc.txt")) // nameLen=7 (odd) → params word-aligned
620621
if len("doc.txt")%2 != 0 {
@@ -795,8 +796,8 @@ func TestDispatch_GetFileDirParms(t *testing.T) {
795796
req := []byte{cmdGetFileDirParms, 0}
796797
req = bp.AppendBE16(req, volID)
797798
req = bp.AppendBE32(req, 2) // dirID root
798-
req = bp.AppendBE16(req, fdBitmapLongName|fileBitmapDataForkLen)
799-
req = bp.AppendBE16(req, fdBitmapLongName)
799+
req = bp.AppendBE16(req, protocol.FDBitmapLongName|protocol.FileBitmapDataForkLen)
800+
req = bp.AppendBE16(req, protocol.FDBitmapLongName)
800801
req = append(req, PathTypeUTF8Names)
801802
req = putPString(req, []byte("report.doc"))
802803
svc.Inbound(ddpTo(svc.Socket(), atpTReq(aspUserData(asp.SPFuncCommand, sessID, 4), req)), from)

core/service/afp/filedir_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
bp "github.com/ObsoleteMadness/ClassicStack/core/binaryprimitives"
77

88
"github.com/ObsoleteMadness/ClassicStack/core/fs"
9+
protocol "github.com/ObsoleteMadness/ClassicStack/core/protocol/afp"
910
)
1011

1112
// buildPathReq assembles a cmd(1) pad(1) volID(2) dirID(4) ... pathType(1)
@@ -30,7 +31,7 @@ func TestGetFileParms(t *testing.T) {
3031
b := []byte{cmd, 0}
3132
b = bp.AppendBE16(b, volID)
3233
b = bp.AppendBE32(b, 2) // root dirID
33-
b = bp.AppendBE16(b, fileBitmapDataForkLen)
34+
b = bp.AppendBE16(b, protocol.FileBitmapDataForkLen)
3435
b = append(b, PathTypeUTF8Names)
3536
return appendPascal(b, name)
3637
}

core/service/afp/forkio.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/ObsoleteMadness/ClassicStack/core/fs"
1212
"github.com/ObsoleteMadness/ClassicStack/core/log"
13+
protocol "github.com/ObsoleteMadness/ClassicStack/core/protocol/afp"
1314
)
1415

1516
// --- fork I/O (FPOpenFork / FPRead / FPWrite / FPCloseFork / FPGetForkParms;
@@ -360,7 +361,7 @@ func (s *Service) afpSetForkParms(a *afpSession, block []byte) ([]byte, int32) {
360361
bitmap := bp.BE16(block[4:6])
361362
// Per AFP 2.x §5.1.31 the bitmap must set exactly one fork-length bit; with
362363
// neither set there is nothing to size, which main answered as kFPBitmapErr.
363-
if bitmap&(fileBitmapDataForkLen|fileBitmapRsrcForkLen) == 0 {
364+
if bitmap&(protocol.FileBitmapDataForkLen|protocol.FileBitmapRsrcForkLen) == 0 {
364365
return nil, afpErrBitmapErr
365366
}
366367
forkLen := int64(int32(bp.BE32(block[6:10])))

core/service/afp/forkio_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
bp "github.com/ObsoleteMadness/ClassicStack/core/binaryprimitives"
77

8+
protocol "github.com/ObsoleteMadness/ClassicStack/core/protocol/afp"
89
"github.com/ObsoleteMadness/ClassicStack/core/protocol/asp"
910
)
1011

@@ -48,7 +49,7 @@ func TestForkIO_OpenWriteReadClose(t *testing.T) {
4849
openFork := []byte{cmdOpenFork, forkFlagData}
4950
openFork = bp.AppendBE16(openFork, volID)
5051
openFork = bp.AppendBE32(openFork, 2) // dirID root
51-
openFork = bp.AppendBE16(openFork, fileBitmapDataForkLen)
52+
openFork = bp.AppendBE16(openFork, protocol.FileBitmapDataForkLen)
5253
openFork = bp.AppendBE16(openFork, accessRead|accessWrite)
5354
openFork = append(openFork, PathTypeUTF8Names)
5455
openFork = putPString(openFork, []byte("doc.txt"))
@@ -203,7 +204,7 @@ func TestForkIO_WriteToReadOnlyFork(t *testing.T) {
203204
// FPSetForkParms is a write to the fork; a read-only handle is likewise denied.
204205
setLen := []byte{cmdSetForkParms, 0}
205206
setLen = bp.AppendBE16(setLen, forkRef)
206-
setLen = bp.AppendBE16(setLen, fileBitmapDataForkLen)
207+
setLen = bp.AppendBE16(setLen, protocol.FileBitmapDataForkLen)
207208
setLen = bp.AppendBE32(setLen, 0)
208209
code, _ = sendCmd(t, svc, r, sessID, 6, setLen)
209210
if code != afpErrAccessDenied {
@@ -224,7 +225,7 @@ func TestForkIO_SetForkParms(t *testing.T) {
224225
openFork := []byte{cmdOpenFork, forkFlagData}
225226
openFork = bp.AppendBE16(openFork, volID)
226227
openFork = bp.AppendBE32(openFork, 2)
227-
openFork = bp.AppendBE16(openFork, fileBitmapDataForkLen)
228+
openFork = bp.AppendBE16(openFork, protocol.FileBitmapDataForkLen)
228229
openFork = bp.AppendBE16(openFork, accessRead|accessWrite)
229230
openFork = append(openFork, PathTypeUTF8Names)
230231
openFork = putPString(openFork, []byte("size.bin"))
@@ -239,7 +240,7 @@ func TestForkIO_SetForkParms(t *testing.T) {
239240
t.Helper()
240241
gp := []byte{cmdGetForkParms, 0}
241242
gp = bp.AppendBE16(gp, forkRef)
242-
gp = bp.AppendBE16(gp, fileBitmapDataForkLen)
243+
gp = bp.AppendBE16(gp, protocol.FileBitmapDataForkLen)
243244
c, rep := sendCmd(t, svc, r, sessID, seq, gp)
244245
if c != afpNoErr {
245246
t.Fatalf("GetForkParms result = %d, want 0", c)
@@ -251,7 +252,7 @@ func TestForkIO_SetForkParms(t *testing.T) {
251252
// Grow the fork to 55808 bytes (the size the capture's client pre-allocates).
252253
setLen := []byte{cmdSetForkParms, 0}
253254
setLen = bp.AppendBE16(setLen, forkRef)
254-
setLen = bp.AppendBE16(setLen, fileBitmapDataForkLen)
255+
setLen = bp.AppendBE16(setLen, protocol.FileBitmapDataForkLen)
255256
setLen = bp.AppendBE32(setLen, 55808)
256257
code, _ = sendCmd(t, svc, r, sessID, 5, setLen)
257258
if code != afpNoErr {
@@ -264,7 +265,7 @@ func TestForkIO_SetForkParms(t *testing.T) {
264265
// Truncate back to 10 bytes.
265266
setLen = []byte{cmdSetForkParms, 0}
266267
setLen = bp.AppendBE16(setLen, forkRef)
267-
setLen = bp.AppendBE16(setLen, fileBitmapDataForkLen)
268+
setLen = bp.AppendBE16(setLen, protocol.FileBitmapDataForkLen)
268269
setLen = bp.AppendBE32(setLen, 10)
269270
code, _ = sendCmd(t, svc, r, sessID, 7, setLen)
270271
if code != afpNoErr {
@@ -289,7 +290,7 @@ func TestForkIO_ByteRangeLock(t *testing.T) {
289290
openFork := []byte{cmdOpenFork, forkFlagData}
290291
openFork = bp.AppendBE16(openFork, volID)
291292
openFork = bp.AppendBE32(openFork, 2)
292-
openFork = bp.AppendBE16(openFork, fileBitmapDataForkLen)
293+
openFork = bp.AppendBE16(openFork, protocol.FileBitmapDataForkLen)
293294
openFork = bp.AppendBE16(openFork, accessRead|accessWrite)
294295
openFork = append(openFork, PathTypeUTF8Names)
295296
openFork = putPString(openFork, []byte("lock.txt"))

core/service/afp/handlers.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
bp "github.com/ObsoleteMadness/ClassicStack/core/binaryprimitives"
1111
"github.com/ObsoleteMadness/ClassicStack/core/encoding"
1212
"github.com/ObsoleteMadness/ClassicStack/core/log"
13+
protocol "github.com/ObsoleteMadness/ClassicStack/core/protocol/afp"
1314
)
1415

1516
// --- Pascal-string helpers; big-endian integer codecs come from
@@ -710,22 +711,22 @@ func (s *Service) afpSetFileDirParms(a *afpSession, block []byte) ([]byte, int32
710711
// the block is too short.
711712
func setParamsFinderInfo(block []byte, off int, bitmap uint16) ([32]byte, bool) {
712713
var fi [32]byte
713-
if bitmap&fdBitmapFinderInfo == 0 {
714+
if bitmap&protocol.FDBitmapFinderInfo == 0 {
714715
return fi, false
715716
}
716-
if bitmap&fdBitmapAttributes != 0 {
717+
if bitmap&protocol.FDBitmapAttributes != 0 {
717718
off += 2
718719
}
719-
if bitmap&fdBitmapParentDID != 0 {
720+
if bitmap&protocol.FDBitmapParentDID != 0 {
720721
off += 4
721722
}
722-
if bitmap&fdBitmapCreateDate != 0 {
723+
if bitmap&protocol.FDBitmapCreateDate != 0 {
723724
off += 4
724725
}
725-
if bitmap&fdBitmapModDate != 0 {
726+
if bitmap&protocol.FDBitmapModDate != 0 {
726727
off += 4
727728
}
728-
if bitmap&fdBitmapBackupDate != 0 {
729+
if bitmap&protocol.FDBitmapBackupDate != 0 {
729730
off += 4
730731
}
731732
if off+32 > len(block) {

0 commit comments

Comments
 (0)