github.com/metacubex/gvisor@v0.0.0-20240320004321-933faba989ec/pkg/erofs/erofs_abi_autogen_unsafe.go (about) 1 // Automatically generated marshal implementation. See tools/go_marshal. 2 3 package erofs 4 5 import ( 6 "github.com/metacubex/gvisor/pkg/gohacks" 7 "github.com/metacubex/gvisor/pkg/hostarch" 8 "github.com/metacubex/gvisor/pkg/marshal" 9 "io" 10 "reflect" 11 "runtime" 12 "unsafe" 13 ) 14 15 // Marshallable types used by this file. 16 var _ marshal.Marshallable = (*Dirent)(nil) 17 var _ marshal.Marshallable = (*InodeCompact)(nil) 18 var _ marshal.Marshallable = (*InodeExtended)(nil) 19 var _ marshal.Marshallable = (*SuperBlock)(nil) 20 21 // SizeBytes implements marshal.Marshallable.SizeBytes. 22 func (d *Dirent) SizeBytes() int { 23 return 12 24 } 25 26 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 27 func (d *Dirent) MarshalBytes(dst []byte) []byte { 28 hostarch.ByteOrder.PutUint32(dst[:4], uint32(d.NidLow)) 29 dst = dst[4:] 30 hostarch.ByteOrder.PutUint32(dst[:4], uint32(d.NidHigh)) 31 dst = dst[4:] 32 hostarch.ByteOrder.PutUint16(dst[:2], uint16(d.NameOff)) 33 dst = dst[2:] 34 dst[0] = byte(d.FileType) 35 dst = dst[1:] 36 dst[0] = byte(d.Reserved) 37 dst = dst[1:] 38 return dst 39 } 40 41 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 42 func (d *Dirent) UnmarshalBytes(src []byte) []byte { 43 d.NidLow = uint32(hostarch.ByteOrder.Uint32(src[:4])) 44 src = src[4:] 45 d.NidHigh = uint32(hostarch.ByteOrder.Uint32(src[:4])) 46 src = src[4:] 47 d.NameOff = uint16(hostarch.ByteOrder.Uint16(src[:2])) 48 src = src[2:] 49 d.FileType = uint8(src[0]) 50 src = src[1:] 51 d.Reserved = uint8(src[0]) 52 src = src[1:] 53 return src 54 } 55 56 // Packed implements marshal.Marshallable.Packed. 57 //go:nosplit 58 func (d *Dirent) Packed() bool { 59 return true 60 } 61 62 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 63 func (d *Dirent) MarshalUnsafe(dst []byte) []byte { 64 size := d.SizeBytes() 65 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(d), uintptr(size)) 66 return dst[size:] 67 } 68 69 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 70 func (d *Dirent) UnmarshalUnsafe(src []byte) []byte { 71 size := d.SizeBytes() 72 gohacks.Memmove(unsafe.Pointer(d), unsafe.Pointer(&src[0]), uintptr(size)) 73 return src[size:] 74 } 75 76 // CopyOutN implements marshal.Marshallable.CopyOutN. 77 func (d *Dirent) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 78 // Construct a slice backed by dst's underlying memory. 79 var buf []byte 80 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 81 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(d))) 82 hdr.Len = d.SizeBytes() 83 hdr.Cap = d.SizeBytes() 84 85 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 86 // Since we bypassed the compiler's escape analysis, indicate that d 87 // must live until the use above. 88 runtime.KeepAlive(d) // escapes: replaced by intrinsic. 89 return length, err 90 } 91 92 // CopyOut implements marshal.Marshallable.CopyOut. 93 func (d *Dirent) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 94 return d.CopyOutN(cc, addr, d.SizeBytes()) 95 } 96 97 // CopyInN implements marshal.Marshallable.CopyInN. 98 func (d *Dirent) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 99 // Construct a slice backed by dst's underlying memory. 100 var buf []byte 101 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 102 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(d))) 103 hdr.Len = d.SizeBytes() 104 hdr.Cap = d.SizeBytes() 105 106 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 107 // Since we bypassed the compiler's escape analysis, indicate that d 108 // must live until the use above. 109 runtime.KeepAlive(d) // escapes: replaced by intrinsic. 110 return length, err 111 } 112 113 // CopyIn implements marshal.Marshallable.CopyIn. 114 func (d *Dirent) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 115 return d.CopyInN(cc, addr, d.SizeBytes()) 116 } 117 118 // WriteTo implements io.WriterTo.WriteTo. 119 func (d *Dirent) WriteTo(writer io.Writer) (int64, error) { 120 // Construct a slice backed by dst's underlying memory. 121 var buf []byte 122 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 123 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(d))) 124 hdr.Len = d.SizeBytes() 125 hdr.Cap = d.SizeBytes() 126 127 length, err := writer.Write(buf) 128 // Since we bypassed the compiler's escape analysis, indicate that d 129 // must live until the use above. 130 runtime.KeepAlive(d) // escapes: replaced by intrinsic. 131 return int64(length), err 132 } 133 134 // SizeBytes implements marshal.Marshallable.SizeBytes. 135 func (i *InodeCompact) SizeBytes() int { 136 return 32 137 } 138 139 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 140 func (i *InodeCompact) MarshalBytes(dst []byte) []byte { 141 hostarch.ByteOrder.PutUint16(dst[:2], uint16(i.Format)) 142 dst = dst[2:] 143 hostarch.ByteOrder.PutUint16(dst[:2], uint16(i.XattrCount)) 144 dst = dst[2:] 145 hostarch.ByteOrder.PutUint16(dst[:2], uint16(i.Mode)) 146 dst = dst[2:] 147 hostarch.ByteOrder.PutUint16(dst[:2], uint16(i.Nlink)) 148 dst = dst[2:] 149 hostarch.ByteOrder.PutUint32(dst[:4], uint32(i.Size)) 150 dst = dst[4:] 151 hostarch.ByteOrder.PutUint32(dst[:4], uint32(i.Reserved)) 152 dst = dst[4:] 153 hostarch.ByteOrder.PutUint32(dst[:4], uint32(i.RawBlockAddr)) 154 dst = dst[4:] 155 hostarch.ByteOrder.PutUint32(dst[:4], uint32(i.Ino)) 156 dst = dst[4:] 157 hostarch.ByteOrder.PutUint16(dst[:2], uint16(i.UID)) 158 dst = dst[2:] 159 hostarch.ByteOrder.PutUint16(dst[:2], uint16(i.GID)) 160 dst = dst[2:] 161 hostarch.ByteOrder.PutUint32(dst[:4], uint32(i.Reserved2)) 162 dst = dst[4:] 163 return dst 164 } 165 166 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 167 func (i *InodeCompact) UnmarshalBytes(src []byte) []byte { 168 i.Format = uint16(hostarch.ByteOrder.Uint16(src[:2])) 169 src = src[2:] 170 i.XattrCount = uint16(hostarch.ByteOrder.Uint16(src[:2])) 171 src = src[2:] 172 i.Mode = uint16(hostarch.ByteOrder.Uint16(src[:2])) 173 src = src[2:] 174 i.Nlink = uint16(hostarch.ByteOrder.Uint16(src[:2])) 175 src = src[2:] 176 i.Size = uint32(hostarch.ByteOrder.Uint32(src[:4])) 177 src = src[4:] 178 i.Reserved = uint32(hostarch.ByteOrder.Uint32(src[:4])) 179 src = src[4:] 180 i.RawBlockAddr = uint32(hostarch.ByteOrder.Uint32(src[:4])) 181 src = src[4:] 182 i.Ino = uint32(hostarch.ByteOrder.Uint32(src[:4])) 183 src = src[4:] 184 i.UID = uint16(hostarch.ByteOrder.Uint16(src[:2])) 185 src = src[2:] 186 i.GID = uint16(hostarch.ByteOrder.Uint16(src[:2])) 187 src = src[2:] 188 i.Reserved2 = uint32(hostarch.ByteOrder.Uint32(src[:4])) 189 src = src[4:] 190 return src 191 } 192 193 // Packed implements marshal.Marshallable.Packed. 194 //go:nosplit 195 func (i *InodeCompact) Packed() bool { 196 return true 197 } 198 199 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 200 func (i *InodeCompact) MarshalUnsafe(dst []byte) []byte { 201 size := i.SizeBytes() 202 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(i), uintptr(size)) 203 return dst[size:] 204 } 205 206 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 207 func (i *InodeCompact) UnmarshalUnsafe(src []byte) []byte { 208 size := i.SizeBytes() 209 gohacks.Memmove(unsafe.Pointer(i), unsafe.Pointer(&src[0]), uintptr(size)) 210 return src[size:] 211 } 212 213 // CopyOutN implements marshal.Marshallable.CopyOutN. 214 func (i *InodeCompact) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 215 // Construct a slice backed by dst's underlying memory. 216 var buf []byte 217 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 218 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i))) 219 hdr.Len = i.SizeBytes() 220 hdr.Cap = i.SizeBytes() 221 222 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 223 // Since we bypassed the compiler's escape analysis, indicate that i 224 // must live until the use above. 225 runtime.KeepAlive(i) // escapes: replaced by intrinsic. 226 return length, err 227 } 228 229 // CopyOut implements marshal.Marshallable.CopyOut. 230 func (i *InodeCompact) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 231 return i.CopyOutN(cc, addr, i.SizeBytes()) 232 } 233 234 // CopyInN implements marshal.Marshallable.CopyInN. 235 func (i *InodeCompact) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 236 // Construct a slice backed by dst's underlying memory. 237 var buf []byte 238 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 239 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i))) 240 hdr.Len = i.SizeBytes() 241 hdr.Cap = i.SizeBytes() 242 243 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 244 // Since we bypassed the compiler's escape analysis, indicate that i 245 // must live until the use above. 246 runtime.KeepAlive(i) // escapes: replaced by intrinsic. 247 return length, err 248 } 249 250 // CopyIn implements marshal.Marshallable.CopyIn. 251 func (i *InodeCompact) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 252 return i.CopyInN(cc, addr, i.SizeBytes()) 253 } 254 255 // WriteTo implements io.WriterTo.WriteTo. 256 func (i *InodeCompact) WriteTo(writer io.Writer) (int64, error) { 257 // Construct a slice backed by dst's underlying memory. 258 var buf []byte 259 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 260 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i))) 261 hdr.Len = i.SizeBytes() 262 hdr.Cap = i.SizeBytes() 263 264 length, err := writer.Write(buf) 265 // Since we bypassed the compiler's escape analysis, indicate that i 266 // must live until the use above. 267 runtime.KeepAlive(i) // escapes: replaced by intrinsic. 268 return int64(length), err 269 } 270 271 // SizeBytes implements marshal.Marshallable.SizeBytes. 272 func (i *InodeExtended) SizeBytes() int { 273 return 48 + 274 1*16 275 } 276 277 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 278 func (i *InodeExtended) MarshalBytes(dst []byte) []byte { 279 hostarch.ByteOrder.PutUint16(dst[:2], uint16(i.Format)) 280 dst = dst[2:] 281 hostarch.ByteOrder.PutUint16(dst[:2], uint16(i.XattrCount)) 282 dst = dst[2:] 283 hostarch.ByteOrder.PutUint16(dst[:2], uint16(i.Mode)) 284 dst = dst[2:] 285 hostarch.ByteOrder.PutUint16(dst[:2], uint16(i.Reserved)) 286 dst = dst[2:] 287 hostarch.ByteOrder.PutUint64(dst[:8], uint64(i.Size)) 288 dst = dst[8:] 289 hostarch.ByteOrder.PutUint32(dst[:4], uint32(i.RawBlockAddr)) 290 dst = dst[4:] 291 hostarch.ByteOrder.PutUint32(dst[:4], uint32(i.Ino)) 292 dst = dst[4:] 293 hostarch.ByteOrder.PutUint32(dst[:4], uint32(i.UID)) 294 dst = dst[4:] 295 hostarch.ByteOrder.PutUint32(dst[:4], uint32(i.GID)) 296 dst = dst[4:] 297 hostarch.ByteOrder.PutUint64(dst[:8], uint64(i.Mtime)) 298 dst = dst[8:] 299 hostarch.ByteOrder.PutUint32(dst[:4], uint32(i.MtimeNsec)) 300 dst = dst[4:] 301 hostarch.ByteOrder.PutUint32(dst[:4], uint32(i.Nlink)) 302 dst = dst[4:] 303 for idx := 0; idx < 16; idx++ { 304 dst[0] = byte(i.Reserved2[idx]) 305 dst = dst[1:] 306 } 307 return dst 308 } 309 310 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 311 func (i *InodeExtended) UnmarshalBytes(src []byte) []byte { 312 i.Format = uint16(hostarch.ByteOrder.Uint16(src[:2])) 313 src = src[2:] 314 i.XattrCount = uint16(hostarch.ByteOrder.Uint16(src[:2])) 315 src = src[2:] 316 i.Mode = uint16(hostarch.ByteOrder.Uint16(src[:2])) 317 src = src[2:] 318 i.Reserved = uint16(hostarch.ByteOrder.Uint16(src[:2])) 319 src = src[2:] 320 i.Size = uint64(hostarch.ByteOrder.Uint64(src[:8])) 321 src = src[8:] 322 i.RawBlockAddr = uint32(hostarch.ByteOrder.Uint32(src[:4])) 323 src = src[4:] 324 i.Ino = uint32(hostarch.ByteOrder.Uint32(src[:4])) 325 src = src[4:] 326 i.UID = uint32(hostarch.ByteOrder.Uint32(src[:4])) 327 src = src[4:] 328 i.GID = uint32(hostarch.ByteOrder.Uint32(src[:4])) 329 src = src[4:] 330 i.Mtime = uint64(hostarch.ByteOrder.Uint64(src[:8])) 331 src = src[8:] 332 i.MtimeNsec = uint32(hostarch.ByteOrder.Uint32(src[:4])) 333 src = src[4:] 334 i.Nlink = uint32(hostarch.ByteOrder.Uint32(src[:4])) 335 src = src[4:] 336 for idx := 0; idx < 16; idx++ { 337 i.Reserved2[idx] = uint8(src[0]) 338 src = src[1:] 339 } 340 return src 341 } 342 343 // Packed implements marshal.Marshallable.Packed. 344 //go:nosplit 345 func (i *InodeExtended) Packed() bool { 346 return true 347 } 348 349 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 350 func (i *InodeExtended) MarshalUnsafe(dst []byte) []byte { 351 size := i.SizeBytes() 352 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(i), uintptr(size)) 353 return dst[size:] 354 } 355 356 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 357 func (i *InodeExtended) UnmarshalUnsafe(src []byte) []byte { 358 size := i.SizeBytes() 359 gohacks.Memmove(unsafe.Pointer(i), unsafe.Pointer(&src[0]), uintptr(size)) 360 return src[size:] 361 } 362 363 // CopyOutN implements marshal.Marshallable.CopyOutN. 364 func (i *InodeExtended) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 365 // Construct a slice backed by dst's underlying memory. 366 var buf []byte 367 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 368 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i))) 369 hdr.Len = i.SizeBytes() 370 hdr.Cap = i.SizeBytes() 371 372 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 373 // Since we bypassed the compiler's escape analysis, indicate that i 374 // must live until the use above. 375 runtime.KeepAlive(i) // escapes: replaced by intrinsic. 376 return length, err 377 } 378 379 // CopyOut implements marshal.Marshallable.CopyOut. 380 func (i *InodeExtended) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 381 return i.CopyOutN(cc, addr, i.SizeBytes()) 382 } 383 384 // CopyInN implements marshal.Marshallable.CopyInN. 385 func (i *InodeExtended) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 386 // Construct a slice backed by dst's underlying memory. 387 var buf []byte 388 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 389 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i))) 390 hdr.Len = i.SizeBytes() 391 hdr.Cap = i.SizeBytes() 392 393 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 394 // Since we bypassed the compiler's escape analysis, indicate that i 395 // must live until the use above. 396 runtime.KeepAlive(i) // escapes: replaced by intrinsic. 397 return length, err 398 } 399 400 // CopyIn implements marshal.Marshallable.CopyIn. 401 func (i *InodeExtended) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 402 return i.CopyInN(cc, addr, i.SizeBytes()) 403 } 404 405 // WriteTo implements io.WriterTo.WriteTo. 406 func (i *InodeExtended) WriteTo(writer io.Writer) (int64, error) { 407 // Construct a slice backed by dst's underlying memory. 408 var buf []byte 409 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 410 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i))) 411 hdr.Len = i.SizeBytes() 412 hdr.Cap = i.SizeBytes() 413 414 length, err := writer.Write(buf) 415 // Since we bypassed the compiler's escape analysis, indicate that i 416 // must live until the use above. 417 runtime.KeepAlive(i) // escapes: replaced by intrinsic. 418 return int64(length), err 419 } 420 421 // SizeBytes implements marshal.Marshallable.SizeBytes. 422 func (sb *SuperBlock) SizeBytes() int { 423 return 58 + 424 1*16 + 425 1*16 + 426 1*38 427 } 428 429 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 430 func (sb *SuperBlock) MarshalBytes(dst []byte) []byte { 431 hostarch.ByteOrder.PutUint32(dst[:4], uint32(sb.Magic)) 432 dst = dst[4:] 433 hostarch.ByteOrder.PutUint32(dst[:4], uint32(sb.Checksum)) 434 dst = dst[4:] 435 hostarch.ByteOrder.PutUint32(dst[:4], uint32(sb.FeatureCompat)) 436 dst = dst[4:] 437 dst[0] = byte(sb.BlockSizeBits) 438 dst = dst[1:] 439 dst[0] = byte(sb.ExtSlots) 440 dst = dst[1:] 441 hostarch.ByteOrder.PutUint16(dst[:2], uint16(sb.RootNid)) 442 dst = dst[2:] 443 hostarch.ByteOrder.PutUint64(dst[:8], uint64(sb.Inodes)) 444 dst = dst[8:] 445 hostarch.ByteOrder.PutUint64(dst[:8], uint64(sb.BuildTime)) 446 dst = dst[8:] 447 hostarch.ByteOrder.PutUint32(dst[:4], uint32(sb.BuildTimeNsec)) 448 dst = dst[4:] 449 hostarch.ByteOrder.PutUint32(dst[:4], uint32(sb.Blocks)) 450 dst = dst[4:] 451 hostarch.ByteOrder.PutUint32(dst[:4], uint32(sb.MetaBlockAddr)) 452 dst = dst[4:] 453 hostarch.ByteOrder.PutUint32(dst[:4], uint32(sb.XattrBlockAddr)) 454 dst = dst[4:] 455 for idx := 0; idx < 16; idx++ { 456 dst[0] = byte(sb.UUID[idx]) 457 dst = dst[1:] 458 } 459 for idx := 0; idx < 16; idx++ { 460 dst[0] = byte(sb.VolumeName[idx]) 461 dst = dst[1:] 462 } 463 hostarch.ByteOrder.PutUint32(dst[:4], uint32(sb.FeatureIncompat)) 464 dst = dst[4:] 465 hostarch.ByteOrder.PutUint16(dst[:2], uint16(sb.Union1)) 466 dst = dst[2:] 467 hostarch.ByteOrder.PutUint16(dst[:2], uint16(sb.ExtraDevices)) 468 dst = dst[2:] 469 hostarch.ByteOrder.PutUint16(dst[:2], uint16(sb.DevTableSlotOff)) 470 dst = dst[2:] 471 for idx := 0; idx < 38; idx++ { 472 dst[0] = byte(sb.Reserved[idx]) 473 dst = dst[1:] 474 } 475 return dst 476 } 477 478 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 479 func (sb *SuperBlock) UnmarshalBytes(src []byte) []byte { 480 sb.Magic = uint32(hostarch.ByteOrder.Uint32(src[:4])) 481 src = src[4:] 482 sb.Checksum = uint32(hostarch.ByteOrder.Uint32(src[:4])) 483 src = src[4:] 484 sb.FeatureCompat = uint32(hostarch.ByteOrder.Uint32(src[:4])) 485 src = src[4:] 486 sb.BlockSizeBits = uint8(src[0]) 487 src = src[1:] 488 sb.ExtSlots = uint8(src[0]) 489 src = src[1:] 490 sb.RootNid = uint16(hostarch.ByteOrder.Uint16(src[:2])) 491 src = src[2:] 492 sb.Inodes = uint64(hostarch.ByteOrder.Uint64(src[:8])) 493 src = src[8:] 494 sb.BuildTime = uint64(hostarch.ByteOrder.Uint64(src[:8])) 495 src = src[8:] 496 sb.BuildTimeNsec = uint32(hostarch.ByteOrder.Uint32(src[:4])) 497 src = src[4:] 498 sb.Blocks = uint32(hostarch.ByteOrder.Uint32(src[:4])) 499 src = src[4:] 500 sb.MetaBlockAddr = uint32(hostarch.ByteOrder.Uint32(src[:4])) 501 src = src[4:] 502 sb.XattrBlockAddr = uint32(hostarch.ByteOrder.Uint32(src[:4])) 503 src = src[4:] 504 for idx := 0; idx < 16; idx++ { 505 sb.UUID[idx] = uint8(src[0]) 506 src = src[1:] 507 } 508 for idx := 0; idx < 16; idx++ { 509 sb.VolumeName[idx] = uint8(src[0]) 510 src = src[1:] 511 } 512 sb.FeatureIncompat = uint32(hostarch.ByteOrder.Uint32(src[:4])) 513 src = src[4:] 514 sb.Union1 = uint16(hostarch.ByteOrder.Uint16(src[:2])) 515 src = src[2:] 516 sb.ExtraDevices = uint16(hostarch.ByteOrder.Uint16(src[:2])) 517 src = src[2:] 518 sb.DevTableSlotOff = uint16(hostarch.ByteOrder.Uint16(src[:2])) 519 src = src[2:] 520 for idx := 0; idx < 38; idx++ { 521 sb.Reserved[idx] = uint8(src[0]) 522 src = src[1:] 523 } 524 return src 525 } 526 527 // Packed implements marshal.Marshallable.Packed. 528 //go:nosplit 529 func (sb *SuperBlock) Packed() bool { 530 return true 531 } 532 533 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 534 func (sb *SuperBlock) MarshalUnsafe(dst []byte) []byte { 535 size := sb.SizeBytes() 536 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(sb), uintptr(size)) 537 return dst[size:] 538 } 539 540 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 541 func (sb *SuperBlock) UnmarshalUnsafe(src []byte) []byte { 542 size := sb.SizeBytes() 543 gohacks.Memmove(unsafe.Pointer(sb), unsafe.Pointer(&src[0]), uintptr(size)) 544 return src[size:] 545 } 546 547 // CopyOutN implements marshal.Marshallable.CopyOutN. 548 func (sb *SuperBlock) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 549 // Construct a slice backed by dst's underlying memory. 550 var buf []byte 551 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 552 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(sb))) 553 hdr.Len = sb.SizeBytes() 554 hdr.Cap = sb.SizeBytes() 555 556 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 557 // Since we bypassed the compiler's escape analysis, indicate that sb 558 // must live until the use above. 559 runtime.KeepAlive(sb) // escapes: replaced by intrinsic. 560 return length, err 561 } 562 563 // CopyOut implements marshal.Marshallable.CopyOut. 564 func (sb *SuperBlock) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 565 return sb.CopyOutN(cc, addr, sb.SizeBytes()) 566 } 567 568 // CopyInN implements marshal.Marshallable.CopyInN. 569 func (sb *SuperBlock) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 570 // Construct a slice backed by dst's underlying memory. 571 var buf []byte 572 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 573 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(sb))) 574 hdr.Len = sb.SizeBytes() 575 hdr.Cap = sb.SizeBytes() 576 577 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 578 // Since we bypassed the compiler's escape analysis, indicate that sb 579 // must live until the use above. 580 runtime.KeepAlive(sb) // escapes: replaced by intrinsic. 581 return length, err 582 } 583 584 // CopyIn implements marshal.Marshallable.CopyIn. 585 func (sb *SuperBlock) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 586 return sb.CopyInN(cc, addr, sb.SizeBytes()) 587 } 588 589 // WriteTo implements io.WriterTo.WriteTo. 590 func (sb *SuperBlock) WriteTo(writer io.Writer) (int64, error) { 591 // Construct a slice backed by dst's underlying memory. 592 var buf []byte 593 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 594 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(sb))) 595 hdr.Len = sb.SizeBytes() 596 hdr.Cap = sb.SizeBytes() 597 598 length, err := writer.Write(buf) 599 // Since we bypassed the compiler's escape analysis, indicate that sb 600 // must live until the use above. 601 runtime.KeepAlive(sb) // escapes: replaced by intrinsic. 602 return int64(length), err 603 } 604