1use serde::{Deserialize, Serialize};
2use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
3use std::net::{Shutdown, SocketAddr};
4use std::time::{Duration, SystemTime};
5use std::{borrow::Cow, ops::Range};
6use virtual_net::{IpCidr, StreamSecurity};
7use wasmer_wasix_types::wasi::{
8 Addressfamily, Advice, EpollCtl, EpollEventCtl, EventFdFlags, ExitCode, Fdflags, Fdflagsext,
9 FileDelta, Filesize, Fstflags, LookupFlags, Oflags, Rights, SiFlags, Snapshot0Clockid,
10 SockProto, Sockoption, Socktype, Timestamp, Tty, Whence,
11};
12use wasmer_wasix_types::wasix::{ThreadStartType, WasiMemoryLayout};
13
14use crate::{base64, SnapshotTrigger};
15
16type Fd = u32;
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(rename_all = "snake_case")]
20pub enum SocketJournalEvent {
21 TcpListen {
22 listen_addr: SocketAddr,
23 reuse_port: bool,
24 reuse_addr: bool,
25 },
26 TcpStream {
27 local_addr: SocketAddr,
28 peer_addr: SocketAddr,
29 },
30 UdpSocket {
31 local_addr: SocketAddr,
32 peer_addr: SocketAddr,
33 reuse_port: bool,
34 reuse_addr: bool,
35 },
36 Icmp {
37 addr: SocketAddr,
38 },
39}
40
41#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialOrd, Ord, PartialEq, Eq, Hash)]
42#[serde(rename_all = "snake_case")]
43pub enum SocketShutdownHow {
44 Read,
45 Write,
46 Both,
47}
48impl From<Shutdown> for SocketShutdownHow {
49 fn from(value: Shutdown) -> Self {
50 match value {
51 Shutdown::Read => Self::Read,
52 Shutdown::Write => Self::Write,
53 Shutdown::Both => Self::Both,
54 }
55 }
56}
57impl From<SocketShutdownHow> for Shutdown {
58 fn from(value: SocketShutdownHow) -> Self {
59 match value {
60 SocketShutdownHow::Read => Self::Read,
61 SocketShutdownHow::Write => Self::Write,
62 SocketShutdownHow::Both => Self::Both,
63 }
64 }
65}
66
67#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialOrd, Ord, PartialEq, Eq, Hash)]
68#[serde(rename_all = "snake_case")]
69pub enum SocketOptTimeType {
70 ReadTimeout,
71 WriteTimeout,
72 AcceptTimeout,
73 ConnectTimeout,
74 BindTimeout,
75 Linger,
76}
77
78#[allow(clippy::large_enum_variant)]
81#[derive(derive_more::Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
82#[serde(rename_all = "snake_case")]
83pub enum JournalEntry<'a> {
84 InitModuleV1 {
85 wasm_hash: Box<[u8]>,
86 },
87 ClearEtherealV1,
88 UpdateMemoryRegionV1 {
89 region: Range<u64>,
90 #[debug(ignore)]
91 #[serde(with = "base64")]
92 compressed_data: Cow<'a, [u8]>,
93 },
94 ProcessExitV1 {
95 exit_code: Option<ExitCode>,
96 },
97 SetThreadV1 {
98 id: u32,
99 #[debug(ignore)]
100 #[serde(with = "base64")]
101 call_stack: Cow<'a, [u8]>,
102 #[debug(ignore)]
103 #[serde(with = "base64")]
104 memory_stack: Cow<'a, [u8]>,
105 #[debug(ignore)]
106 #[serde(with = "base64")]
107 store_data: Cow<'a, [u8]>,
108 start: ThreadStartType,
109 layout: WasiMemoryLayout,
110 is_64bit: bool,
111 },
112 CloseThreadV1 {
113 id: u32,
114 exit_code: Option<ExitCode>,
115 },
116 FileDescriptorSeekV1 {
117 fd: Fd,
118 offset: FileDelta,
119 whence: Whence,
120 },
121 FileDescriptorWriteV1 {
122 fd: Fd,
123 offset: u64,
124 #[debug(ignore)]
125 #[serde(with = "base64")]
126 data: Cow<'a, [u8]>,
127 is_64bit: bool,
128 },
129 SetClockTimeV1 {
130 clock_id: Snapshot0Clockid,
131 time: Timestamp,
132 },
133 CloseFileDescriptorV1 {
134 fd: Fd,
135 },
136 OpenFileDescriptorV1 {
137 fd: Fd,
138 dirfd: Fd,
139 dirflags: LookupFlags,
140 path: Cow<'a, str>,
141 o_flags: Oflags,
142 #[debug(ignore)]
143 fs_rights_base: Rights,
144 #[debug(ignore)]
145 fs_rights_inheriting: Rights,
146 fs_flags: Fdflags,
147 },
148 OpenFileDescriptorV2 {
149 fd: Fd,
150 dirfd: Fd,
151 dirflags: LookupFlags,
152 path: Cow<'a, str>,
153 o_flags: Oflags,
154 #[debug(ignore)]
155 fs_rights_base: Rights,
156 #[debug(ignore)]
157 fs_rights_inheriting: Rights,
158 fs_flags: Fdflags,
159 fd_flags: Fdflagsext,
160 },
161 RenumberFileDescriptorV1 {
162 old_fd: Fd,
163 new_fd: Fd,
164 },
165 DuplicateFileDescriptorV1 {
166 original_fd: Fd,
167 copied_fd: Fd,
168 },
169 DuplicateFileDescriptorV2 {
170 original_fd: Fd,
171 copied_fd: Fd,
172 cloexec: bool,
173 },
174 CreateDirectoryV1 {
175 fd: Fd,
176 path: Cow<'a, str>,
177 },
178 RemoveDirectoryV1 {
179 fd: Fd,
180 path: Cow<'a, str>,
181 },
182 PathSetTimesV1 {
183 fd: Fd,
184 flags: LookupFlags,
185 path: Cow<'a, str>,
186 st_atim: Timestamp,
187 st_mtim: Timestamp,
188 fst_flags: Fstflags,
189 },
190 FileDescriptorSetTimesV1 {
191 fd: Fd,
192 st_atim: Timestamp,
193 st_mtim: Timestamp,
194 fst_flags: Fstflags,
195 },
196 FileDescriptorSetFdFlagsV1 {
197 fd: Fd,
198 flags: Fdflagsext,
199 },
200 FileDescriptorSetFlagsV1 {
201 fd: Fd,
202 flags: Fdflags,
203 },
204 FileDescriptorSetRightsV1 {
205 fd: Fd,
206 fs_rights_base: Rights,
207 fs_rights_inheriting: Rights,
208 },
209 FileDescriptorSetSizeV1 {
210 fd: Fd,
211 st_size: Filesize,
212 },
213 FileDescriptorAdviseV1 {
214 fd: Fd,
215 offset: Filesize,
216 len: Filesize,
217 advice: Advice,
218 },
219 FileDescriptorAllocateV1 {
220 fd: Fd,
221 offset: Filesize,
222 len: Filesize,
223 },
224 CreateHardLinkV1 {
225 old_fd: Fd,
226 old_path: Cow<'a, str>,
227 old_flags: LookupFlags,
228 new_fd: Fd,
229 new_path: Cow<'a, str>,
230 },
231 CreateSymbolicLinkV1 {
232 old_path: Cow<'a, str>,
233 fd: Fd,
234 new_path: Cow<'a, str>,
235 },
236 UnlinkFileV1 {
237 fd: Fd,
238 path: Cow<'a, str>,
239 },
240 PathRenameV1 {
241 old_fd: Fd,
242 old_path: Cow<'a, str>,
243 new_fd: Fd,
244 new_path: Cow<'a, str>,
245 },
246 ChangeDirectoryV1 {
247 path: Cow<'a, str>,
248 },
249 EpollCreateV1 {
250 fd: Fd,
251 },
252 EpollCtlV1 {
253 epfd: Fd,
254 op: EpollCtl,
255 fd: Fd,
256 event: Option<EpollEventCtl>,
257 },
258 TtySetV1 {
259 tty: Tty,
260 line_feeds: bool,
261 },
262 CreatePipeV1 {
263 read_fd: Fd,
264 write_fd: Fd,
265 },
266 CreateEventV1 {
267 initial_val: u64,
268 flags: EventFdFlags,
269 fd: Fd,
270 },
271 PortAddAddrV1 {
272 cidr: IpCidr,
273 },
274 PortDelAddrV1 {
275 addr: IpAddr,
276 },
277 PortAddrClearV1,
278 PortBridgeV1 {
279 network: Cow<'a, str>,
280 token: Cow<'a, str>,
281 security: StreamSecurity,
282 },
283 PortUnbridgeV1,
284 PortDhcpAcquireV1,
285 PortGatewaySetV1 {
286 ip: IpAddr,
287 },
288 PortRouteAddV1 {
289 cidr: IpCidr,
290 via_router: IpAddr,
291 preferred_until: Option<Duration>,
292 expires_at: Option<Duration>,
293 },
294 PortRouteClearV1,
295 PortRouteDelV1 {
296 ip: IpAddr,
297 },
298 SocketOpenV1 {
299 af: Addressfamily,
300 ty: Socktype,
301 pt: SockProto,
302 fd: Fd,
303 },
304 SocketPairV1 {
305 fd1: Fd,
306 fd2: Fd,
307 },
308 SocketListenV1 {
309 fd: Fd,
310 backlog: u32,
311 },
312 SocketBindV1 {
313 fd: Fd,
314 addr: SocketAddr,
315 },
316 SocketConnectedV1 {
317 fd: Fd,
318 local_addr: SocketAddr,
319 peer_addr: SocketAddr,
320 },
321 SocketAcceptedV1 {
322 listen_fd: Fd,
323 fd: Fd,
324 local_addr: SocketAddr,
325 peer_addr: SocketAddr,
326 fd_flags: Fdflags,
327 non_blocking: bool,
328 },
329 SocketJoinIpv4MulticastV1 {
330 fd: Fd,
331 multiaddr: Ipv4Addr,
332 iface: Ipv4Addr,
333 },
334 SocketJoinIpv6MulticastV1 {
335 fd: Fd,
336 multi_addr: Ipv6Addr,
337 iface: u32,
338 },
339 SocketLeaveIpv4MulticastV1 {
340 fd: Fd,
341 multi_addr: Ipv4Addr,
342 iface: Ipv4Addr,
343 },
344 SocketLeaveIpv6MulticastV1 {
345 fd: Fd,
346 multi_addr: Ipv6Addr,
347 iface: u32,
348 },
349 SocketSendFileV1 {
350 socket_fd: Fd,
351 file_fd: Fd,
352 offset: Filesize,
353 count: Filesize,
354 },
355 SocketSendToV1 {
356 fd: Fd,
357 #[debug(ignore)]
358 #[serde(with = "base64")]
359 data: Cow<'a, [u8]>,
360 flags: SiFlags,
361 addr: SocketAddr,
362 is_64bit: bool,
363 },
364 SocketSendV1 {
365 fd: Fd,
366 #[debug(ignore)]
367 #[serde(with = "base64")]
368 data: Cow<'a, [u8]>,
369 flags: SiFlags,
370 is_64bit: bool,
371 },
372 SocketSetOptFlagV1 {
373 fd: Fd,
374 opt: Sockoption,
375 flag: bool,
376 },
377 SocketSetOptSizeV1 {
378 fd: Fd,
379 opt: Sockoption,
380 size: u64,
381 },
382 SocketSetOptTimeV1 {
383 fd: Fd,
384 ty: SocketOptTimeType,
385 time: Option<Duration>,
386 },
387 SocketShutdownV1 {
388 fd: Fd,
389 how: SocketShutdownHow,
390 },
391 SnapshotV1 {
393 when: SystemTime,
394 trigger: SnapshotTrigger,
395 },
396}
397
398impl<'a> JournalEntry<'a> {
399 pub fn into_owned(self) -> JournalEntry<'static> {
400 match self {
401 Self::InitModuleV1 { wasm_hash } => JournalEntry::InitModuleV1 { wasm_hash },
402 Self::ClearEtherealV1 => JournalEntry::ClearEtherealV1,
403 Self::UpdateMemoryRegionV1 {
404 region,
405 compressed_data,
406 } => JournalEntry::UpdateMemoryRegionV1 {
407 region,
408 compressed_data: compressed_data.into_owned().into(),
409 },
410 Self::ProcessExitV1 { exit_code } => JournalEntry::ProcessExitV1 { exit_code },
411 Self::SetThreadV1 {
412 id,
413 call_stack,
414 memory_stack,
415 store_data,
416 is_64bit,
417 start,
418 layout,
419 } => JournalEntry::SetThreadV1 {
420 id,
421 call_stack: call_stack.into_owned().into(),
422 memory_stack: memory_stack.into_owned().into(),
423 store_data: store_data.into_owned().into(),
424 start,
425 layout,
426 is_64bit,
427 },
428 Self::CloseThreadV1 { id, exit_code } => JournalEntry::CloseThreadV1 { id, exit_code },
429 Self::FileDescriptorSeekV1 { fd, offset, whence } => {
430 JournalEntry::FileDescriptorSeekV1 { fd, offset, whence }
431 }
432 Self::FileDescriptorWriteV1 {
433 fd,
434 offset,
435 data,
436 is_64bit,
437 } => JournalEntry::FileDescriptorWriteV1 {
438 fd,
439 offset,
440 data: data.into_owned().into(),
441 is_64bit,
442 },
443 Self::SetClockTimeV1 { clock_id, time } => {
444 JournalEntry::SetClockTimeV1 { clock_id, time }
445 }
446 Self::CloseFileDescriptorV1 { fd } => JournalEntry::CloseFileDescriptorV1 { fd },
447 Self::OpenFileDescriptorV1 {
448 fd,
449 dirfd,
450 dirflags,
451 path,
452 o_flags,
453 fs_rights_base,
454 fs_rights_inheriting,
455 fs_flags,
456 } => JournalEntry::OpenFileDescriptorV1 {
457 fd,
458 dirfd,
459 dirflags,
460 path: path.into_owned().into(),
461 o_flags,
462 fs_rights_base,
463 fs_rights_inheriting,
464 fs_flags,
465 },
466 Self::OpenFileDescriptorV2 {
467 fd,
468 dirfd,
469 dirflags,
470 path,
471 o_flags,
472 fs_rights_base,
473 fs_rights_inheriting,
474 fs_flags,
475 fd_flags,
476 } => JournalEntry::OpenFileDescriptorV2 {
477 fd,
478 dirfd,
479 dirflags,
480 path: path.into_owned().into(),
481 o_flags,
482 fs_rights_base,
483 fs_rights_inheriting,
484 fs_flags,
485 fd_flags,
486 },
487 Self::RenumberFileDescriptorV1 { old_fd, new_fd } => {
488 JournalEntry::RenumberFileDescriptorV1 { old_fd, new_fd }
489 }
490 Self::DuplicateFileDescriptorV1 {
491 original_fd,
492 copied_fd,
493 } => JournalEntry::DuplicateFileDescriptorV1 {
494 original_fd,
495 copied_fd,
496 },
497 Self::DuplicateFileDescriptorV2 {
498 original_fd,
499 copied_fd,
500 cloexec,
501 } => JournalEntry::DuplicateFileDescriptorV2 {
502 original_fd,
503 copied_fd,
504 cloexec,
505 },
506 Self::CreateDirectoryV1 { fd, path } => JournalEntry::CreateDirectoryV1 {
507 fd,
508 path: path.into_owned().into(),
509 },
510 Self::RemoveDirectoryV1 { fd, path } => JournalEntry::RemoveDirectoryV1 {
511 fd,
512 path: path.into_owned().into(),
513 },
514 Self::PathSetTimesV1 {
515 fd,
516 flags,
517 path,
518 st_atim,
519 st_mtim,
520 fst_flags,
521 } => JournalEntry::PathSetTimesV1 {
522 fd,
523 flags,
524 path: path.into_owned().into(),
525 st_atim,
526 st_mtim,
527 fst_flags,
528 },
529 Self::FileDescriptorSetTimesV1 {
530 fd,
531 st_atim,
532 st_mtim,
533 fst_flags,
534 } => JournalEntry::FileDescriptorSetTimesV1 {
535 fd,
536 st_atim,
537 st_mtim,
538 fst_flags,
539 },
540 Self::FileDescriptorSetFdFlagsV1 { fd, flags } => {
541 JournalEntry::FileDescriptorSetFdFlagsV1 { fd, flags }
542 }
543 Self::FileDescriptorSetFlagsV1 { fd, flags } => {
544 JournalEntry::FileDescriptorSetFlagsV1 { fd, flags }
545 }
546 Self::FileDescriptorSetRightsV1 {
547 fd,
548 fs_rights_base,
549 fs_rights_inheriting,
550 } => JournalEntry::FileDescriptorSetRightsV1 {
551 fd,
552 fs_rights_base,
553 fs_rights_inheriting,
554 },
555 Self::FileDescriptorSetSizeV1 { fd, st_size } => {
556 JournalEntry::FileDescriptorSetSizeV1 { fd, st_size }
557 }
558 Self::FileDescriptorAdviseV1 {
559 fd,
560 offset,
561 len,
562 advice,
563 } => JournalEntry::FileDescriptorAdviseV1 {
564 fd,
565 offset,
566 len,
567 advice,
568 },
569 Self::FileDescriptorAllocateV1 { fd, offset, len } => {
570 JournalEntry::FileDescriptorAllocateV1 { fd, offset, len }
571 }
572 Self::CreateHardLinkV1 {
573 old_fd,
574 old_path,
575 old_flags,
576 new_fd,
577 new_path,
578 } => JournalEntry::CreateHardLinkV1 {
579 old_fd,
580 old_path: old_path.into_owned().into(),
581 old_flags,
582 new_fd,
583 new_path: new_path.into_owned().into(),
584 },
585 Self::CreateSymbolicLinkV1 {
586 old_path,
587 fd,
588 new_path,
589 } => JournalEntry::CreateSymbolicLinkV1 {
590 old_path: old_path.into_owned().into(),
591 fd,
592 new_path: new_path.into_owned().into(),
593 },
594 Self::UnlinkFileV1 { fd, path } => JournalEntry::UnlinkFileV1 {
595 fd,
596 path: path.into_owned().into(),
597 },
598 Self::PathRenameV1 {
599 old_fd,
600 old_path,
601 new_fd,
602 new_path,
603 } => JournalEntry::PathRenameV1 {
604 old_fd,
605 old_path: old_path.into_owned().into(),
606 new_fd,
607 new_path: new_path.into_owned().into(),
608 },
609 Self::ChangeDirectoryV1 { path } => JournalEntry::ChangeDirectoryV1 {
610 path: path.into_owned().into(),
611 },
612 Self::EpollCreateV1 { fd } => JournalEntry::EpollCreateV1 { fd },
613 Self::EpollCtlV1 {
614 epfd,
615 op,
616 fd,
617 event,
618 } => JournalEntry::EpollCtlV1 {
619 epfd,
620 op,
621 fd,
622 event,
623 },
624 Self::TtySetV1 { tty, line_feeds } => JournalEntry::TtySetV1 { tty, line_feeds },
625 Self::CreatePipeV1 { read_fd, write_fd } => {
626 JournalEntry::CreatePipeV1 { read_fd, write_fd }
627 }
628 Self::CreateEventV1 {
629 initial_val,
630 flags,
631 fd,
632 } => JournalEntry::CreateEventV1 {
633 initial_val,
634 flags,
635 fd,
636 },
637 Self::PortAddAddrV1 { cidr } => JournalEntry::PortAddAddrV1 { cidr },
638 Self::PortDelAddrV1 { addr } => JournalEntry::PortDelAddrV1 { addr },
639 Self::PortAddrClearV1 => JournalEntry::PortAddrClearV1,
640 Self::PortBridgeV1 {
641 network,
642 token,
643 security,
644 } => JournalEntry::PortBridgeV1 {
645 network: network.into_owned().into(),
646 token: token.into_owned().into(),
647 security,
648 },
649 Self::PortUnbridgeV1 => JournalEntry::PortUnbridgeV1,
650 Self::PortDhcpAcquireV1 => JournalEntry::PortDhcpAcquireV1,
651 Self::PortGatewaySetV1 { ip } => JournalEntry::PortGatewaySetV1 { ip },
652 Self::PortRouteAddV1 {
653 cidr,
654 via_router,
655 preferred_until,
656 expires_at,
657 } => JournalEntry::PortRouteAddV1 {
658 cidr,
659 via_router,
660 preferred_until,
661 expires_at,
662 },
663 Self::PortRouteClearV1 => JournalEntry::PortRouteClearV1,
664 Self::PortRouteDelV1 { ip } => JournalEntry::PortRouteDelV1 { ip },
665 Self::SocketOpenV1 { af, ty, pt, fd } => JournalEntry::SocketOpenV1 { af, ty, pt, fd },
666 Self::SocketPairV1 { fd1, fd2 } => JournalEntry::SocketPairV1 { fd1, fd2 },
667 Self::SocketListenV1 { fd, backlog } => JournalEntry::SocketListenV1 { fd, backlog },
668 Self::SocketBindV1 { fd, addr } => JournalEntry::SocketBindV1 { fd, addr },
669 Self::SocketConnectedV1 {
670 fd,
671 local_addr,
672 peer_addr,
673 } => JournalEntry::SocketConnectedV1 {
674 fd,
675 local_addr,
676 peer_addr,
677 },
678 Self::SocketAcceptedV1 {
679 listen_fd,
680 fd,
681 local_addr,
682 peer_addr,
683 fd_flags,
684 non_blocking: nonblocking,
685 } => JournalEntry::SocketAcceptedV1 {
686 listen_fd,
687 fd,
688 local_addr,
689 peer_addr,
690 fd_flags,
691 non_blocking: nonblocking,
692 },
693 Self::SocketJoinIpv4MulticastV1 {
694 fd,
695 multiaddr,
696 iface,
697 } => JournalEntry::SocketJoinIpv4MulticastV1 {
698 fd,
699 multiaddr,
700 iface,
701 },
702 Self::SocketJoinIpv6MulticastV1 {
703 fd,
704 multi_addr: multiaddr,
705 iface,
706 } => JournalEntry::SocketJoinIpv6MulticastV1 {
707 fd,
708 multi_addr: multiaddr,
709 iface,
710 },
711 Self::SocketLeaveIpv4MulticastV1 {
712 fd,
713 multi_addr: multiaddr,
714 iface,
715 } => JournalEntry::SocketLeaveIpv4MulticastV1 {
716 fd,
717 multi_addr: multiaddr,
718 iface,
719 },
720 Self::SocketLeaveIpv6MulticastV1 {
721 fd,
722 multi_addr: multiaddr,
723 iface,
724 } => JournalEntry::SocketLeaveIpv6MulticastV1 {
725 fd,
726 multi_addr: multiaddr,
727 iface,
728 },
729 Self::SocketSendFileV1 {
730 socket_fd,
731 file_fd,
732 offset,
733 count,
734 } => JournalEntry::SocketSendFileV1 {
735 socket_fd,
736 file_fd,
737 offset,
738 count,
739 },
740 Self::SocketSendToV1 {
741 fd,
742 data,
743 flags,
744 addr,
745 is_64bit,
746 } => JournalEntry::SocketSendToV1 {
747 fd,
748 data: data.into_owned().into(),
749 flags,
750 addr,
751 is_64bit,
752 },
753 Self::SocketSendV1 {
754 fd,
755 data,
756 flags,
757 is_64bit,
758 } => JournalEntry::SocketSendV1 {
759 fd,
760 data: data.into_owned().into(),
761 flags,
762 is_64bit,
763 },
764 Self::SocketSetOptFlagV1 { fd, opt, flag } => {
765 JournalEntry::SocketSetOptFlagV1 { fd, opt, flag }
766 }
767 Self::SocketSetOptSizeV1 { fd, opt, size } => {
768 JournalEntry::SocketSetOptSizeV1 { fd, opt, size }
769 }
770 Self::SocketSetOptTimeV1 { fd, ty, time } => {
771 JournalEntry::SocketSetOptTimeV1 { fd, ty, time }
772 }
773 Self::SocketShutdownV1 { fd, how } => JournalEntry::SocketShutdownV1 { fd, how },
774 Self::SnapshotV1 { when, trigger } => JournalEntry::SnapshotV1 { when, trigger },
775 }
776 }
777
778 pub fn estimate_size(&self) -> usize {
779 let base_size = std::mem::size_of_val(self);
780 match self {
781 JournalEntry::InitModuleV1 { .. } => base_size,
782 JournalEntry::ClearEtherealV1 => base_size,
783 JournalEntry::UpdateMemoryRegionV1 {
784 compressed_data, ..
785 } => base_size + compressed_data.len(),
786 JournalEntry::ProcessExitV1 { .. } => base_size,
787 JournalEntry::SetThreadV1 {
788 call_stack,
789 memory_stack,
790 store_data,
791 ..
792 } => base_size + call_stack.len() + memory_stack.len() + store_data.len(),
793 JournalEntry::CloseThreadV1 { .. } => base_size,
794 JournalEntry::FileDescriptorSeekV1 { .. } => base_size,
795 JournalEntry::FileDescriptorWriteV1 { data, .. } => base_size + data.len(),
796 JournalEntry::SetClockTimeV1 { .. } => base_size,
797 JournalEntry::CloseFileDescriptorV1 { .. } => base_size,
798 JournalEntry::OpenFileDescriptorV1 { path, .. } => base_size + path.as_bytes().len(),
799 JournalEntry::OpenFileDescriptorV2 { path, .. } => base_size + path.as_bytes().len(),
800 JournalEntry::RenumberFileDescriptorV1 { .. } => base_size,
801 JournalEntry::DuplicateFileDescriptorV1 { .. } => base_size,
802 JournalEntry::DuplicateFileDescriptorV2 { .. } => base_size,
803 JournalEntry::CreateDirectoryV1 { path, .. } => base_size + path.as_bytes().len(),
804 JournalEntry::RemoveDirectoryV1 { path, .. } => base_size + path.as_bytes().len(),
805 JournalEntry::PathSetTimesV1 { path, .. } => base_size + path.as_bytes().len(),
806 JournalEntry::FileDescriptorSetTimesV1 { .. } => base_size,
807 JournalEntry::FileDescriptorSetFdFlagsV1 { .. } => base_size,
808 JournalEntry::FileDescriptorSetFlagsV1 { .. } => base_size,
809 JournalEntry::FileDescriptorSetRightsV1 { .. } => base_size,
810 JournalEntry::FileDescriptorSetSizeV1 { .. } => base_size,
811 JournalEntry::FileDescriptorAdviseV1 { .. } => base_size,
812 JournalEntry::FileDescriptorAllocateV1 { .. } => base_size,
813 JournalEntry::CreateHardLinkV1 {
814 old_path, new_path, ..
815 } => base_size + old_path.as_bytes().len() + new_path.as_bytes().len(),
816 JournalEntry::CreateSymbolicLinkV1 {
817 old_path, new_path, ..
818 } => base_size + old_path.as_bytes().len() + new_path.as_bytes().len(),
819 JournalEntry::UnlinkFileV1 { path, .. } => base_size + path.as_bytes().len(),
820 JournalEntry::PathRenameV1 {
821 old_path, new_path, ..
822 } => base_size + old_path.as_bytes().len() + new_path.as_bytes().len(),
823 JournalEntry::ChangeDirectoryV1 { path } => base_size + path.as_bytes().len(),
824 JournalEntry::EpollCreateV1 { .. } => base_size,
825 JournalEntry::EpollCtlV1 { .. } => base_size,
826 JournalEntry::TtySetV1 { .. } => base_size,
827 JournalEntry::CreatePipeV1 { .. } => base_size,
828 JournalEntry::CreateEventV1 { .. } => base_size,
829 JournalEntry::PortAddAddrV1 { .. } => base_size,
830 JournalEntry::PortDelAddrV1 { .. } => base_size,
831 JournalEntry::PortAddrClearV1 => base_size,
832 JournalEntry::PortBridgeV1 { network, token, .. } => {
833 base_size + network.as_bytes().len() + token.as_bytes().len()
834 }
835 JournalEntry::PortUnbridgeV1 => base_size,
836 JournalEntry::PortDhcpAcquireV1 => base_size,
837 JournalEntry::PortGatewaySetV1 { .. } => base_size,
838 JournalEntry::PortRouteAddV1 { .. } => base_size,
839 JournalEntry::PortRouteClearV1 => base_size,
840 JournalEntry::PortRouteDelV1 { .. } => base_size,
841 JournalEntry::SocketOpenV1 { .. } => base_size,
842 JournalEntry::SocketPairV1 { .. } => base_size,
843 JournalEntry::SocketListenV1 { .. } => base_size,
844 JournalEntry::SocketBindV1 { .. } => base_size,
845 JournalEntry::SocketConnectedV1 { .. } => base_size,
846 JournalEntry::SocketAcceptedV1 { .. } => base_size,
847 JournalEntry::SocketJoinIpv4MulticastV1 { .. } => base_size,
848 JournalEntry::SocketJoinIpv6MulticastV1 { .. } => base_size,
849 JournalEntry::SocketLeaveIpv4MulticastV1 { .. } => base_size,
850 JournalEntry::SocketLeaveIpv6MulticastV1 { .. } => base_size,
851 JournalEntry::SocketSendFileV1 { .. } => base_size,
852 JournalEntry::SocketSendToV1 { data, .. } => base_size + data.len(),
853 JournalEntry::SocketSendV1 { data, .. } => base_size + data.len(),
854 JournalEntry::SocketSetOptFlagV1 { .. } => base_size,
855 JournalEntry::SocketSetOptSizeV1 { .. } => base_size,
856 JournalEntry::SocketSetOptTimeV1 { .. } => base_size,
857 JournalEntry::SocketShutdownV1 { .. } => base_size,
858 JournalEntry::SnapshotV1 { .. } => base_size,
859 }
860 }
861}