1 // Copyright 2024 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 //! Data structures and logic for virtio-fs IOCTLs specific to ARCVM. 6 7 use zerocopy::AsBytes; 8 use zerocopy::FromBytes; 9 use zerocopy::FromZeroes; 10 11 pub const FS_IOCTL_PATH_MAX_LEN: usize = 128; 12 pub const FS_IOCTL_XATTR_NAME_MAX_LEN: usize = 128; 13 pub const FS_IOCTL_XATTR_VALUE_MAX_LEN: usize = 128; 14 15 #[repr(C)] 16 #[derive(Clone, Copy, AsBytes, FromZeroes, FromBytes)] 17 pub(crate) struct FsPermissionDataBuffer { 18 pub guest_uid: u32, 19 pub guest_gid: u32, 20 pub host_uid: u32, 21 pub host_gid: u32, 22 pub umask: u32, 23 pub pad: u32, 24 pub perm_path: [u8; FS_IOCTL_PATH_MAX_LEN], 25 } 26 27 #[derive(Debug, Clone, PartialEq)] 28 pub(crate) struct XattrData { 29 pub xattr_name: String, 30 pub xattr_value: String, 31 pub xattr_path: String, 32 } 33 34 impl XattrData { need_set_guest_xattr(&self, path: &str, name: &str) -> bool35 pub(crate) fn need_set_guest_xattr(&self, path: &str, name: &str) -> bool { 36 path.starts_with(&self.xattr_path) && (name == self.xattr_name) 37 } 38 } 39 #[repr(C)] 40 #[derive(Clone, Copy, AsBytes, FromZeroes, FromBytes)] 41 pub(crate) struct FsPathXattrDataBuffer { 42 pub path: [u8; FS_IOCTL_PATH_MAX_LEN], 43 pub xattr_name: [u8; FS_IOCTL_XATTR_NAME_MAX_LEN], 44 pub xattr_value: [u8; FS_IOCTL_XATTR_VALUE_MAX_LEN], 45 } 46