xref: /xnu-11215.41.3/osfmk/mach/doubleagent_mig.defs (revision 33de042d024d46de5ff4e89f2471de6608e37fa4) !
1/*
2 * Copyright (c) 2023 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29subsystem
30#if    KERNEL_USER
31    KernelUser
32#endif    /* KERNEL_USER */
33    doubleagent 6300;
34
35#include <mach/std_types.defs>
36#include <mach/mach_types.defs>
37import <mach/doubleagent_types.h>;
38
39#define MAX_NUM_OF_XATTRS 256
40#define DA_XATTR_MAXNAMELEN 127 // Must match the 'XATTR_MAXNAMELEN' in <sys/xattr.h>.
41#define XATTR_FINDERINFO_NAME_LEN 21 // sizeof("com.apple.FinderInfo") (including '\0')
42#define XATTR_RESOURCEFORK_NAME_LEN 23 // sizeof("com.apple.ResourceFork") (including '\0')
43
44#define LISTXATTR_RESULT_MAX_NAMES_LEN_MIG (XATTR_FINDERINFO_NAME_LEN + XATTR_RESOURCEFORK_NAME_LEN + (MAX_NUM_OF_XATTRS * ((DA_XATTR_MAXNAMELEN + 1)))) // Mig copy of LISTXATTR_RESULT_MAX_NAMES_LEN
45#define LISTXATTR_RESULT_MAX_HINTS_LEN_MIG (MAX_NUM_OF_XATTRS * 8) // Mig copy of LISTXATTR_RESULT_MAX_HINTS_LEN (8 = 2 * sizeof(uint32_t))
46#define LISTXATTR_RESULT_MAX_SIZE_MIG (LISTXATTR_RESULT_MAX_NAMES_LEN_MIG + LISTXATTR_RESULT_MAX_HINTS_LEN_MIG) // Mig copy of LISTXATTR_RESULT_MAX_SIZE
47#define LISTXATTR_RESULT_MAX_SIZE_INCLUDING_HEADER_MIG (LISTXATTR_RESULT_MAX_SIZE_MIG + 56) // 56 = 7 fields of uint64_t.
48
49
50type xattrname = c_string[*:DA_XATTR_MAXNAMELEN + 1];
51type listxattrs_result_t = struct [LISTXATTR_RESULT_MAX_SIZE_INCLUDING_HEADER_MIG] of uint8_t;
52
53routine doubleagent_lookup_xattr(
54    server                  : mach_port_t;
55    in file_port            : mach_port_move_send_t; /* fileport */
56    in file_size            : int64_t;      /* AD file size */
57    in name                 : xattrname;    /* xattr name to lookup */
58    out err                 : int;          /* error value */
59    out value_offset        : uint64_t;     /* returned xattr offset */
60    out value_length        : uint64_t      /* returned xattr length */
61);
62
63routine doubleagent_allocate_xattr(
64    server                  : mach_port_t;
65    in file_port            : mach_port_move_send_t; /* fileport */
66    in file_size            : int64_t;      /* AD file size */
67    in name                 : xattrname;    /* xattr name to allocate */
68    in size                 : uint64_t;     /* xattr size to allocate */
69    in options              : uint32_t;     /* how to allocate */
70    out err                 : int;          /* error value */
71    out value_offset        : uint64_t      /* returned xattr offset */
72);
73
74routine doubleagent_list_xattrs(
75    server                  : mach_port_t;
76    in file_port            : mach_port_move_send_t; /* fileport */
77    in file_size            : int64_t;             /* AD file size */
78    out err                 : int;                 /* error value */
79    out result              : listxattrs_result_t  /* listxattr result struct */
80);
81
82routine doubleagent_remove_xattr(
83    server                  : mach_port_t;
84    in file_port            : mach_port_move_send_t;  /* fileport */
85    in file_size            : int64_t;      /* AD file size */
86    in name                 : xattrname;    /* xattr name to remove */
87    out err                 : int;          /* error value */
88    out is_empty            : boolean_t     /* true if we've removed the last xattr in file */
89);
90