libsmbclient: update to 4.4.6
[unleashed-userland.git] / components / network / samba / Solaris / include / samfs / stat.h
blob77844c6e99d5bd1f8e36063782739466cfdb502b
1 /*
2 * stat.h - SAM-FS file information definitions.
4 * Defines the SAM-FS file information structure and functions.
5 * The POSIX stat structure and associated macros are used to allow
6 * the sam_stat structure to be used on various client machine
7 * architectures.
9 */
12 * SAM-QFS_notice_begin
14 * CDDL HEADER START
16 * The contents of this file are subject to the terms of the
17 * Common Development and Distribution License (the "License").
18 * You may not use this file except in compliance with the License.
20 * You can obtain a copy of the license at pkg/OPENSOLARIS.LICENSE
21 * or http://www.opensolaris.org/os/licensing.
22 * See the License for the specific language governing permissions
23 * and limitations under the License.
25 * When distributing Covered Code, include this CDDL HEADER in each
26 * file and include the License file at pkg/OPENSOLARIS.LICENSE.
27 * If applicable, add the following below this CDDL HEADER, with the
28 * fields enclosed by brackets "[]" replaced with your own identifying
29 * information: Portions Copyright [yyyy] [name of copyright owner]
31 * CDDL HEADER END
34 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
36 * SAM-QFS_notice_end
39 #ifndef SAM_STAT_H
40 #define SAM_STAT_H
43 #ifdef linux
44 #include <sam/linux_types.h> /* u_longlong_t */
45 #endif /* linux */
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
51 #define MAX_ARCHIVE 4
52 #define SAM_MIN_SEGMENT_SIZE (1024*1024) /* Minimum segment size in bytes */
55 * If sam/stat.h and sys/stat.h are needed in the same module, then
56 * sys/stat.h must be included before sam/stat.h.
57 * The following is provided to avoid compilation errors:
59 #if defined(_SYS_STAT_H) || defined(_LINUX_STAT_H) || defined(_BITS_STAT_H)
60 #undef st_atime
61 #undef st_mtime
62 #undef st_ctime
63 #undef S_ISBLK
64 #undef S_ISCHR
65 #undef S_ISDIR
66 #undef S_ISFIFO
67 #undef S_ISGID
68 #undef S_ISREG
69 #undef S_ISUID
70 #undef S_ISLNK
71 #undef S_ISSOCK
73 #ifdef linux
74 #undef S_IRWXU
75 #undef S_IRUSR
76 #undef S_IWUSR
77 #undef S_IXUSR
78 #undef S_IRWXG
79 #undef S_IRGRP
80 #undef S_IWGRP
81 #undef S_IXGRP
82 #undef S_IRWXO
83 #undef S_IROTH
84 #undef S_IWOTH
85 #undef S_IXOTH
86 #endif /* linux */
88 #endif /* defined(_SYS_STAT_H) */
91 * NOTE that in order to pass the following structures from a 64-bit
92 * kernel to a 32-bit application, we need to conditionally define the
93 * positions of the 32-bit time and the pad differently for SPARC and X86.
97 * Begin: 32-bit align copyin() structs for amd64 only due to 32-bit x86 ABI
99 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
100 #pragma pack(4)
101 #endif
103 #if defined(__sparcv9) || defined(__amd64) || defined(linux)
106 * For each archive copy
108 struct sam_copy_s {
109 /* Location of archive file */
110 u_longlong_t position;
111 /* Time archive copy created */
112 time_t creation_time;
113 /* Location of copy in archive file - in units of 512 bytes */
114 uint_t offset;
115 ushort_t flags;
116 /* Number of VSNs the archive used */
117 short n_vsns;
118 /* Media type */
119 char media[4];
120 /* VSN */
121 char vsn[32];
125 * POSIX stat structure.
127 struct sam_stat {
128 uint_t st_mode; /* File mode */
129 uint_t st_ino; /* File serial number */
130 #ifdef sun
131 /* ID of the device containing the file */
132 dev_t st_dev;
133 #endif /* sun */
134 #ifdef linux
135 /* ID of the device containing the file */
136 ushort_t st_dev;
137 #endif /* linux */
138 uint_t st_nlink; /* Number of links */
139 uint_t st_uid; /* User ID of the file's owner */
140 uint_t st_gid; /* Group ID of the file's owner */
141 u_longlong_t st_size; /* The file size in bytes */
142 time_t st_atime; /* Time of last access */
143 time_t st_mtime; /* Time of last data modification */
144 time_t st_ctime; /* Time of last file status change */
146 /* SAM-FS information. */
147 time_t attribute_time; /* Time attributes last changed */
148 time_t creation_time; /* Time inode created */
149 time_t residence_time; /* Time file changed residence */
150 struct sam_copy_s copy[MAX_ARCHIVE];
151 uint_t old_attr; /* File attr, backwards compatible */
152 uchar_t cs_algo; /* Checksum algorithm indicator */
153 uchar_t flags; /* Flags: staging, stage err, etc. */
154 uchar_t stripe_width; /* Stripe Width set by setfa -s or -h */
155 uchar_t stripe_group; /* Stripe Group set by setfa -g or -o */
156 uint_t gen; /* File generation number */
157 uint_t partial_size; /* Partial size in kilobytes */
158 #ifdef sun
159 /* ID of device if S_IFBLK or S_IFCHR */
160 dev_t rdev;
161 #endif /* sun */
162 #ifdef linux
163 /* ID of device if S_IFBLK or S_IFCHR */
164 ushort_t rdev;
165 #endif /* linux */
166 /* Block count in units of 512 byte blocks */
167 u_longlong_t st_blocks;
168 /* Segment size in megabytes (SS_SEGMENT_A) */
169 uint_t segment_size;
170 /* Number of this segment */
171 /* 0 - SS_SEGMENT_F, 1 .. n - SS_SEGMENT_S */
172 uint_t segment_number;
173 /* Number of segments to stage ahead */
174 uint_t stage_ahead;
175 /* admin ID; inherited from dir */
176 uint_t admin_id;
177 /* Allocate ahead size set by setfa -A */
178 uint_t allocahead;
180 * Object stripe depth in kilobytes.
181 * If this field is used only for OSD support then it should be removed
182 * once it is determined that removing it is safe. Update the man page
183 * for sam_stat(3) when this is done.
185 uint_t obj_depth;
186 /* 128 bit checksum */
187 u_longlong_t cs_val[2];
188 /* WORM retention period start and duration. */
189 time_t rperiod_start_time;
190 uint_t rperiod_duration;
191 projid_t projid;
192 u_longlong_t attr; /* File attributes */
195 #else /* __sparcv9 || __amd64 || linux */
197 * For each archive copy.
199 struct sam_copy_s {
200 /* Location of archive file */
201 u_longlong_t position;
202 #if defined(__i386)
203 /* Time archive copy created */
204 time_t creation_time;
205 ulong_t pad0;
206 #else
207 ulong_t pad0;
208 /* Time archive copy created */
209 time_t creation_time;
210 #endif /* __i386 */
211 /* Location of copy in archive file - in units of 512 bytes */
212 ulong_t offset;
213 ushort_t flags;
214 short n_vsns; /* Number of VSNs the archive used */
215 char media[4]; /* Media type */
216 char vsn[32]; /* VSN */
220 * POSIX stat structure.
222 struct sam_stat {
223 /* File mode */
224 ulong_t st_mode;
225 /* File serial number */
226 ulong_t st_ino;
227 /* ID of the device containing the file */
228 dev_t st_dev;
229 long pad1;
230 ulong_t st_nlink; /* Number of links */
231 ulong_t st_uid; /* User ID of the file's owner */
232 ulong_t st_gid; /* Group ID of the file's owner */
233 u_longlong_t st_size; /* The file size in bytes */
234 #if defined(__i386)
235 time_t st_atime; /* Time of last access */
236 ulong_t pad2;
237 time_t st_mtime; /* Time of last data modification */
238 ulong_t pad3;
239 time_t st_ctime; /* Time of last file status change */
240 ulong_t pad4;
242 /* SAM-FS information. */
243 time_t attribute_time; /* Time attributes last changed */
244 ulong_t pad5;
245 time_t creation_time; /* Time inode created */
246 ulong_t pad6;
247 time_t residence_time; /* Time file changed residence */
248 ulong_t pad7;
249 #else /* __i386 */
250 ulong_t pad2;
251 time_t st_atime; /* Time of last access */
252 ulong_t pad3;
253 time_t st_mtime; /* Time of last data modification */
254 ulong_t pad4;
255 time_t st_ctime; /* Time of last file status change */
257 /* SAM-FS information. */
258 ulong_t pad5;
259 time_t attribute_time; /* Time attributes last changed */
260 ulong_t pad6;
261 time_t creation_time; /* Time inode created */
262 ulong_t pad7;
263 time_t residence_time; /* Time file changed residence */
264 #endif /* __i386 */
265 struct sam_copy_s copy[MAX_ARCHIVE];
266 uint_t old_attr; /* File attr, backwards compatible */
267 uchar_t cs_algo; /* Checksum algorithm indicator */
268 uchar_t flags; /* Flags: staging, stage err, etc. */
269 uchar_t stripe_width; /* Stripe Width set by setfa -s or -h */
270 uchar_t stripe_group; /* Stripe Group set by setfa -g or -o */
271 ulong_t gen; /* File generation number */
272 ulong_t partial_size; /* Partial size in kilobytes */
273 dev_t rdev; /* ID of device if S_IFBLK or S_IFCHR */
274 ulong_t pad8;
275 /* Block count in units of 512 byte blocks */
276 u_longlong_t st_blocks;
277 /* Segment size in megabytes (SS_SEGMENT_A) */
278 ulong_t segment_size;
279 /* Number of this segment */
280 /* 0 - SS_SEGMENT_F, 1 .. n - SS_SEGMENT_S */
281 ulong_t segment_number;
282 /* Number of segments to stage ahead */
283 uint_t stage_ahead;
284 /* admin ID; inherited from dir */
285 ulong_t admin_id;
286 /* Allocate ahead size set by setfa -A */
287 ulong_t allocahead;
288 ulong_t obj_depth; /* Object stripe depth in kilobytes */
289 /* 128 bit checksum */
290 u_longlong_t cs_val[2];
291 /* WORM retention period start and duration. */
292 #if defined(__i386)
293 time_t rperiod_start_time;
294 ulong_t pad10;
295 #else /* __i386 */
296 ulong_t pad10;
297 time_t rperiod_start_time;
298 #endif /* __i386 */
299 ulong_t rperiod_duration;
300 ulong_t projid;
301 u_longlong_t attr; /* File attributes */
304 #endif /* __sparcv9 || __amd64 || linux */
307 #define SAM_SECTION_SIZE(n) (sizeof (struct sam_section) * n)
309 struct sam_section { /* For each archive copy volume section */
310 /* VSN */
311 char vsn[32];
312 /* Section length of file on this volume */
313 u_longlong_t length;
314 /* Position of archive file for this section */
315 u_longlong_t position;
316 /* Location of copy section in archive file */
317 u_longlong_t offset;
321 * End: 32-bit align copyin() structs for amd64 only due to 32-bit x86 ABI
323 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
324 #pragma pack()
325 #endif
328 * POSIX symbols.
331 #define S_IRWXU 00700 /* read, write, execute: owner */
332 #define S_IRUSR 00400 /* read permission: owner */
333 #define S_IWUSR 00200 /* write permission: owner */
334 #define S_IXUSR 00100 /* execute permission: owner */
335 #define S_IRWXG 00070 /* read, write, execute: group */
336 #define S_IRGRP 00040 /* read permission: group */
337 #define S_IWGRP 00020 /* write permission: group */
338 #define S_IXGRP 00010 /* execute permission: group */
339 #define S_IRWXO 00007 /* read, write, execute: other */
340 #define S_IROTH 00004 /* read permission: other */
342 #define S_IWOTH 00002 /* write permission: other */
343 #define S_IXOTH 00001 /* execute permission: other */
345 #define S_ISBLK(mode) (((mode)&0xf000) == 0x6000)
346 #define S_ISCHR(mode) (((mode)&0xf000) == 0x2000)
347 #define S_ISDIR(mode) (((mode)&0xf000) == 0x4000)
348 #define S_ISFIFO(mode) (((mode)&0xf000) == 0x1000)
349 #define S_ISGID(mode) ((mode)&0x400) /* set group id on execution */
350 #define S_ISREG(mode) (((mode)&0xf000) == 0x8000)
351 #define S_ISUID(mode) ((mode)&0x800) /* set user id on execution */
352 #define S_ISLNK(mode) (((mode)&0xf000) == 0xa000)
353 #define S_ISSOCK(mode) (((mode)&0xf000) == 0xc000)
356 * SAMFS attributes mapped into sam_stat but not in inode (ino_status_t).
358 #define SS_SAMFS 0x00000800 /* SAM-FS file */
359 #define SS_ARCHIVE_R 0x00002000 /* Re-archive */
360 #define SS_ARCHIVED 0x00010000 /* File has at least one archive copy */
361 #define SS_DATA_V 0x00040000 /* File requires data verification */
362 #define SS_AIO 0x00080000 /* AIO Char Device file */
363 #define SS_ARCHIVE_A 0x08000000 /* Archive immediate */
366 * SAMFS attributes from the inode.
368 #define SS_REMEDIA 0x00000001 /* Removable media file */
369 #define SS_RELEASE_A 0x00000002 /* Release after archive */
370 #define SS_RELEASE_N 0x00000004 /* Release never (nodrop) */
371 #define SS_STAGE_N 0x00000008 /* Stage never (direct) */
372 #define SS_DAMAGED 0x00000010 /* File is damaged - */
373 /* not online and no copy */
374 #define SS_RELEASE_P 0x00000020 /* Release partial (bof_online) */
375 #define SS_ARCHIVE_N 0x00000040 /* Archive never (noarch) */
376 #define SS_STAGE_A 0x00000080 /* Stage associative (stageall) */
378 #define SS_CSVAL 0x00000100 /* Valid checksum exists in inode */
379 #define SS_CSUSE 0x00000200 /* Checksum will be used upon stage */
380 #define SS_CSGEN 0x00000400 /* Checksum will be generated upon - */
381 /* archive */
382 /* SS_SAMFS 0x00000800 used by sam_stat() - see above */
384 #define SS_ARCHDONE 0x00001000 /* File has all required - */
385 /* archiving done */
386 /* SS_ARCHIVE_R 0x00002000 used by sam_stat() - see above */
387 #define SS_PARTIAL 0x00004000 /* Partial extents are online */
388 #define SS_OFFLINE 0x00008000 /* File is offline */
390 /* SS_ARCHIVED 0x00010000 used by sam_stat() - see above */
391 #define SS_SEGMENT_A 0x00020000 /* Segment attribute */
392 /* SS_DATA_V 0x00040000 used by sam_stat() - see above */
393 /* SS_AIO 0x00080000 used by sam_stat() - see above */
395 #define SS_ARCHIVE_C 0x00100000 /* Archive concurrent */
396 #define SS_DIRECTIO 0x00200000 /* Directio */
397 #define SS_ARCHIVE_I 0x00400000 /* Archive inconsistent copies */
398 #define SS_WORM 0x00800000 /* Read only attribute (worm_attr) */
400 #define SS_READONLY 0x01000000 /* Read only file enabled (worm_set) */
401 #define SS_SEGMENT_S 0x02000000 /* This is a segment of a - */
402 /* segmented file */
403 #define SS_SEGMENT_F 0x04000000 /* Stage/archive file in segments */
404 /* SS_ARCHIVE_A 0x08000000 used by sam_stat() - see above */
406 #define SS_SETFA_S 0x10000000 /* Stripe Width set by setfa -s */
407 #define SS_SETFA_H 0x10000000 /* Stripe Width set by setfa -h */
408 #define SS_SETFA_G 0x20000000 /* Stripe Group set by setfa -g */
409 #define SS_SETFA_O 0x20000000 /* Stripe Group set by setfa -o */
410 #define SS_DFACL 0x40000000 /* Default access control list - */
411 /* present */
412 #define SS_ACL 0x80000000 /* Access control list present */
414 #define SS_OBJECT_FS 0x000100000000 /* Object file system "mb" */
416 #define SS_ISSAMFS(attr) (((attr)&SS_SAMFS) != 0)
417 #define SS_ISREMEDIA(attr) (((attr)&SS_REMEDIA) != 0)
418 #define SS_ISARCHIVED(attr) (((attr)&SS_ARCHIVED) != 0)
419 #define SS_ISARCHDONE(attr) (((attr)&SS_ARCHDONE) != 0)
420 #define SS_ISDAMAGED(attr) (((attr)&SS_DAMAGED) != 0)
421 #define SS_ISOFFLINE(attr) (((attr)&SS_OFFLINE) != 0)
422 #define SS_ISPARTIAL(attr) (((attr)&SS_PARTIAL) != 0)
423 #define SS_ISARCHIVE_C(attr) (((attr)&SS_ARCHIVE_C) != 0)
424 #define SS_ISARCHIVE_I(attr) (((attr)&SS_ARCHIVE_I) != 0)
425 #define SS_ISARCHIVE_N(attr) (((attr)&SS_ARCHIVE_N) != 0)
426 #define SS_ISARCHIVE_A(attr) (((attr)&SS_ARCHIVE_A) != 0)
427 #define SS_ISARCHIVE_R(attr) (((attr)&SS_ARCHIVE_R) != 0)
428 #define SS_ISRELEASE_A(attr) (((attr)&SS_RELEASE_A) != 0)
429 #define SS_ISRELEASE_N(attr) (((attr)&SS_RELEASE_N) != 0)
430 #define SS_ISRELEASE_P(attr) (((attr)&SS_RELEASE_P) != 0)
431 #define SS_ISSTAGE_A(attr) (((attr)&SS_STAGE_A) != 0)
432 #define SS_ISSTAGE_N(attr) (((attr)&SS_STAGE_N) != 0)
433 #define SS_ISSEGMENT_A(attr) (((attr)&SS_SEGMENT_A) != 0)
434 #define SS_ISSEGMENT_S(attr) (((attr)&SS_SEGMENT_S) != 0)
435 #define SS_ISSEGMENT_F(attr) (((attr)&SS_SEGMENT_F) != 0)
436 #define SS_ISCSGEN(attr) (((attr)&SS_CSGEN) != 0)
437 #define SS_ISCSUSE(attr) (((attr)&SS_CSUSE) != 0)
438 #define SS_ISCSVAL(attr) (((attr)&SS_CSVAL) != 0)
439 #define SS_ISDIRECTIO(attr) (((attr)&SS_DIRECTIO) != 0)
440 #define SS_ISWORM(attr) (((attr)&SS_WORM) != 0)
441 #define SS_ISREADONLY(attr) (((attr)&SS_READONLY) != 0)
442 #define SS_ISSETFA_G(attr) (((attr)&SS_SETFA_G) != 0)
443 #define SS_ISSETFA_S(attr) (((attr)&SS_SETFA_S) != 0)
444 #define SS_ISDFACL(attr) (((attr)&SS_DFACL) != 0)
445 #define SS_ISACL(attr) (((attr)&SS_ACL) != 0)
446 #define SS_ISDATAV(attr) (((attr)&SS_DATA_V) != 0)
447 #define SS_ISAIO(attr) (((attr)&SS_AIO) != 0)
448 #define SS_ISOBJECT_FS(attr) (((attr)&SS_OBJECT_FS) != 0)
449 #define SS_ISSETFA_O(attr) (((attr)&SS_SETFA_O) != 0)
450 #define SS_ISSETFA_H(attr) (((attr)&SS_SETFA_H) != 0)
453 * SAMFS flags.
456 #define SS_STAGING 0x01 /* Stage is pending on the file */
457 #define SS_STAGEFAIL 0x02 /* Error occurred on - */
458 /* last stage attempt */
460 #define SS_ISSTAGING(flags) (((flags)&SS_STAGING) != 0)
461 #define SS_ISSTAGEFAIL(flags) (((flags)&SS_STAGEFAIL) != 0)
464 * Copy flag masks.
466 #define CF_STALE 0x0001 /* This archive copy is stale */
467 #define CF_REARCH 0x0002 /* Copy is to be rearchived */
468 #define CF_ARCH_I 0x0004 /* Copy is to be archived immediately */
469 #define CF_VERIFIED 0x0008 /* Copy has been verified */
470 #define CF_DAMAGED 0x0010 /* This archive copy is damaged */
471 #define CF_UNARCHIVED 0x0020 /* This archive copy was unarchived */
472 #define CF_INCONSISTENT 0x0040 /* This archive copy is inconsistent */
473 #define CF_ARCHIVED 0x0080 /* This archive copy made */
474 #define CF_AR_FLAGS_MASK 0x00FF /* the flags in the stat struct from */
475 /* the AR_FLAGS in the inode */
476 #define CF_PAX_ARCH_FMT 0x8000 /* from SAR_hdr_off0 in the inode */
478 int sam_stat(const char *path, struct sam_stat *buf, size_t bufsize);
479 int sam_lstat(const char *path, struct sam_stat *buf, size_t bufsize);
480 int sam_vsn_stat(const char *path, int copy, struct sam_section *buf,
481 size_t bufsize);
482 int sam_segment_vsn_stat(const char *path, int copy, int segment_index,
483 struct sam_section *buf, size_t bufsize);
484 int sam_segment_stat(const char *path, struct sam_stat *buf,
485 size_t bufsize);
486 int sam_segment_lstat(const char *path, struct sam_stat *buf,
487 size_t bufsize);
488 int sam_restore_file(const char *path, struct sam_stat *buf,
489 size_t bufsize);
490 int sam_restore_copy(const char *path, int copy, struct sam_stat *buf,
491 size_t bufsize, struct sam_section *vbuf, size_t vbufsize);
494 * macro NUM_SEGS, takes in, fsbuff, a ptr to a sam_stat struct, returns the
495 * number of segments of the file associated with fsbuff.
498 #define NUM_SEGS(fsbuff) (int)(((fsbuff) == NULL || (fsbuff)->st_size <= 0 || \
499 (fsbuff)->segment_size <= 0 || \
500 !SS_ISSEGMENT_F((fsbuff)->attr)) ? 0 : \
501 ((fsbuff)->st_size + \
502 (offset_t)(fsbuff)->segment_size * \
503 (SAM_MIN_SEGMENT_SIZE) - 1LL) / \
504 ((offset_t)(fsbuff)->segment_size * \
505 (SAM_MIN_SEGMENT_SIZE)))
507 #ifdef __cplusplus
509 #endif
511 #endif /* SAM_STAT_H */