-
Notifications
You must be signed in to change notification settings - Fork 3
/
listing4.html
executable file
·1377 lines (1192 loc) · 66.9 KB
/
listing4.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<!-- BEGIN META TAG INFO -->
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="home" href="http://developer.apple.com/">
<link rel="find" href="http://developer.apple.com/search/">
<link rel="stylesheet" type="text/css" href="../../documentation/css/adcstyle.css" title="fonts">
<script language="JavaScript" src="../../documentation/js/adc.js" type="text/javascript"></script>
<!-- END META TAG INFO -->
<!-- BEGIN TITLE -->
<title>FSMegaInfo - /BSDAttrList.c</title>
<!-- END TITLE -->
<script language="JavaScript">
function JumpToNewPage() {
window.location=document.scpopupmenu.gotop.value;
return true;
}
</script>
</head>
<!-- BEGIN BODY OPEN -->
<body>
<!--END BODY OPEN -->
<!-- START CENTER OPEN -->
<center>
<!-- END CENTER OPEN -->
<!-- BEGIN LOGO AND SEARCH -->
<!--#include virtual="/includes/adcnavbar"-->
<!-- END LOGO AND SEARCH -->
<!-- START BREADCRUMB -->
<div id="breadcrumb">
<table width="680" border="0" cellpadding="0" cellspacing="0">
<tr>
<td scope="row"><img width="340" height="10" src="images/1dot.gif" alt=""></td>
<td><img width="340" height="10" src="images/1dot.gif" alt=""></td>
</tr>
<tr valign="middle">
<td align="left" colspan="2">
<a href="http://developer.apple.com/">ADC Home</a> > <a href="../../referencelibrary/index.html">Reference Library</a> > <a href="../../samplecode/index.html">Sample Code</a> > <a href="../../samplecode/Darwin/index.html">Darwin</a> > <a href="../../samplecode/Darwin/idxFileManagement-date.html">File Management</a> > <A HREF="javascript:location.replace('index.html');">FSMegaInfo</A> >
</td>
</tr>
<tr>
<td colspan="2" scope="row"><img width="680" height="35" src="images/1dot.gif" alt=""></td>
</tr>
</table>
</div>
<!-- END BREADCRUMB -->
<!-- START MAIN CONTENT -->
<!-- START TITLE GRAPHIC AND INTRO-->
<table width="680" border="0" cellpadding="0" cellspacing="0">
<tr align="left" valign="top">
<td><h1><div id="pagehead">FSMegaInfo</div></h1></td>
</tr>
</table>
<!-- END TITLE GRAPHIC AND INTRO -->
<!-- START WIDE COLUMN -->
<table width="680" border="0" cellpadding="0" cellspacing="0">
<tr align="left" valign="top">
<td id="scdetails">
<h2>/BSDAttrList.c</h2>
<form name="scpopupmenu" onSubmit="return false;" method=post>
<p><strong>View Source Code:</strong>
<select name="gotop" onChange="JumpToNewPage();" style="width:340px"><option selected value="ingnore">Select File</option>
<option value="listing1.html">/AliasManager.c</option>
<option value="listing2.html">/BSD.c</option>
<option value="listing3.html">/BSD.h</option>
<option value="listing4.html">/BSDAttrList.c</option>
<option value="listing5.html">/Command.c</option>
<option value="listing6.html">/Command.h</option>
<option value="listing7.html">/DiskArb.c</option>
<option value="listing8.html">/FieldPrinter.c</option>
<option value="listing9.html">/FieldPrinter.h</option>
<option value="listing10.html">/FileManager.c</option>
<option value="listing11.html">/FolderManager.c</option>
<option value="listing12.html">/FSMegaInfo.c</option>
<option value="listing13.html">/Read Me About FSMegaInfo.txt</option>
<option value="listing14.html">/Tests/ten-five-intel.txt</option>
<option value="listing15.html">/Tests/ten-five-one-ppc64.txt</option>
<option value="listing16.html">/Tests/ten-five-ppc.txt</option>
<option value="listing17.html">/Tests/ten-four-eleven-intel.txt</option>
<option value="listing18.html">/Tests/ten-four-eleven-ppc.txt</option></select>
</p>
</form>
<p><strong><a href="FSMegaInfo.zip">Download Sample</a></strong> (“FSMegaInfo.zip”, 522.7K)<BR>
<strong><a href="FSMegaInfo.dmg">Download Sample</a></strong> (“FSMegaInfo.dmg”, 920.2K)</p>
<!--
<p><strong><a href="#">Download Sample</a></strong> (“filename.sit”, 500K)</p>
-->
</td>
</tr>
<tr>
<td scope="row"><img width="680" height="10" src="images/1dot.gif" alt=""><br>
<img height="1" width="680" src="images/1dot_919699.gif" alt=""><br>
<img width="680" height="20" src="images/1dot.gif" alt=""></td>
</tr>
<tr>
<td scope="row">
<!--googleon: index -->
<pre class="sourcecodebox">/*
File: BSDAttrList.c
Contains: BSD attribute list command processing (getattrlist and so on).
Written by: DTS
Copyright: Copyright (c) 2008 Apple Inc. All Rights Reserved.
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or
redistribution of this Apple software constitutes acceptance of
these terms. If you do not agree with these terms, please do
not use, install, modify or redistribute this Apple software.
In consideration of your agreement to abide by the following
terms, and subject to these terms, Apple grants you a personal,
non-exclusive license, under Apple's copyrights in this
original Apple software (the "Apple Software"), to use,
reproduce, modify and redistribute the Apple Software, with or
without modifications, in source and/or binary forms; provided
that if you redistribute the Apple Software in its entirety and
without modifications, you must retain this notice and the
following text and disclaimers in all such redistributions of
the Apple Software. Neither the name, trademarks, service marks
or logos of Apple Inc. may be used to endorse or promote
products derived from the Apple Software without specific prior
written permission from Apple. Except as expressly stated in
this notice, no other rights or licenses, express or implied,
are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or
by other works in which the Apple Software may be incorporated.
The Apple Software is provided by Apple on an "AS IS" basis.
APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING
THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT,
INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY
OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include "BSD.h"
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/vnode.h>
#include <stdint.h>
#include <inttypes.h>
#include <unistd.h>
#include "FieldPrinter.h"
#include "Command.h"
/////////////////////////////////////////////////////////////////
#pragma mark * getattrlist
// Some useful getattrlist-related declarations.
typedef struct attrlist attrlist_t;
enum {
kAttrRefSize = sizeof(attrreference_t)
};
// FPFlagDesc versions of kCommonAttrDesc and kVolumeAttrDesc.
// See InitAllAttrFlags for a discussion of why these are
// necessary.
static FPFlagDesc * gCommonAttrFlags;
static FPFlagDesc * gVolumeAttrFlags;
static FPFlagDesc * gDirAttrFlags;
static FPFlagDesc * gFileAttrFlags;
static FPFlagDesc * gForkAttrFlags;
// AttrDesc describes an attribute, including info like its mask value, its identifier,
// its size, and a pointer to the routine to print it.
struct AttrDesc {
attrgroup_t attrMask;
const char * attrName;
size_t attrSize;
FPPrinter attrPrinter;
const void * attrInfo;
};
typedef struct AttrDesc AttrDesc;
static void StringAttrPrinter(
const char * fieldName,
size_t fieldSize,
const void * fieldPtr,
uint32_t indent,
size_t nameWidth,
uint32_t verbose,
const void * info
)
// Prints a string attribute, as referenced by an attrreference_t structure
// in the buffer returned by getattrlist. The encoding is assumed to be UTF-8.
//
// See definition of FPPrinter for a parameter description.
{
attrreference_t * attrRef;
#pragma unused(fieldSize)
#pragma unused(verbose)
#pragma unused(info)
assert( FPStandardPreCondition() );
assert(fieldSize == sizeof(attrreference_t));
attrRef = ( (attrreference_t *) fieldPtr );
fprintf(stdout, "%*s%-*s = '%.*s'\n", (int) indent, "", (int) nameWidth, fieldName, (int) attrRef->attr_length, ((char *) attrRef) + attrRef->attr_dataoffset);
}
static void FPFSObjID(
const char * fieldName,
size_t fieldSize,
const void * fieldPtr,
uint32_t indent,
size_t nameWidth,
uint32_t verbose,
const void * info
)
// Prints an fsobj_id_t field.
//
// See definition of FPPrinter for a parameter description.
{
const fsobj_id_t * fsobjPtr;
#pragma unused(fieldSize)
#pragma unused(verbose)
#pragma unused(info)
assert( FPStandardPreCondition() );
assert(fieldSize == sizeof(fsobj_id_t));
fsobjPtr = (const fsobj_id_t *) fieldPtr;
fprintf(stdout, "%*s%-*s = (objno = 0x%08" PRIx32 ", generation = 0x%08" PRIx32 ")\n", (int) indent, "", (int) nameWidth, fieldName, fsobjPtr->fid_objno, fsobjPtr->fid_generation);
}
static void FPFSID(
const char * fieldName,
size_t fieldSize,
const void * fieldPtr,
uint32_t indent,
size_t nameWidth,
uint32_t verbose,
const void * info
)
// Prints an fsid_t field.
//
// See definition of FPPrinter for a parameter description.
{
const fsid_t * fsidPtr;
#pragma unused(fieldSize)
#pragma unused(verbose)
#pragma unused(info)
assert( FPStandardPreCondition() );
assert(fieldSize == sizeof(fsid_t));
fsidPtr = (const fsid_t *) fieldPtr;
fprintf(stdout, "%*s%-*s = [0x%08" PRIx32 ", 0x%08" PRIx32 "]\n", (int) indent, "", (int) nameWidth, fieldName, fsidPtr->val[0], fsidPtr->val[1]);
}
// Flags describing volume format capabilities.
static const char kVolCapFlagSpacer[] = "VOL_CAP_FMT_PERSISTENTOBJECTIDS";
static const FPFlagDesc kVolCapFormatFlags[] = {
{ VOL_CAP_FMT_PERSISTENTOBJECTIDS, "VOL_CAP_FMT_PERSISTENTOBJECTIDS" },
{ VOL_CAP_FMT_SYMBOLICLINKS, "VOL_CAP_FMT_SYMBOLICLINKS" },
{ VOL_CAP_FMT_HARDLINKS, "VOL_CAP_FMT_HARDLINKS" },
{ VOL_CAP_FMT_JOURNAL, "VOL_CAP_FMT_JOURNAL" },
{ VOL_CAP_FMT_JOURNAL_ACTIVE, "VOL_CAP_FMT_JOURNAL_ACTIVE" },
{ VOL_CAP_FMT_NO_ROOT_TIMES, "VOL_CAP_FMT_NO_ROOT_TIMES" },
{ VOL_CAP_FMT_SPARSE_FILES, "VOL_CAP_FMT_SPARSE_FILES" },
{ VOL_CAP_FMT_ZERO_RUNS, "VOL_CAP_FMT_ZERO_RUNS" },
{ VOL_CAP_FMT_CASE_SENSITIVE, "VOL_CAP_FMT_CASE_SENSITIVE" },
{ VOL_CAP_FMT_CASE_PRESERVING, "VOL_CAP_FMT_CASE_PRESERVING" },
{ VOL_CAP_FMT_FAST_STATFS, "VOL_CAP_FMT_FAST_STATFS" },
{ VOL_CAP_FMT_2TB_FILESIZE, "VOL_CAP_FMT_2TB_FILESIZE" },
{ VOL_CAP_FMT_OPENDENYMODES, "VOL_CAP_FMT_OPENDENYMODES" },
{ VOL_CAP_FMT_HIDDEN_FILES, "VOL_CAP_FMT_HIDDEN_FILES" },
{ VOL_CAP_FMT_PATH_FROM_ID, "VOL_CAP_FMT_PATH_FROM_ID" },
{ 0, NULL }
};
// Flags describing volume API capabilities.
static const FPFlagDesc kVolCapInterfacesFlags[] = {
{ VOL_CAP_INT_SEARCHFS, "VOL_CAP_INT_SEARCHFS" },
{ VOL_CAP_INT_ATTRLIST, "VOL_CAP_INT_ATTRLIST" },
{ VOL_CAP_INT_NFSEXPORT, "VOL_CAP_INT_NFSEXPORT" },
{ VOL_CAP_INT_READDIRATTR, "VOL_CAP_INT_READDIRATTR" },
{ VOL_CAP_INT_EXCHANGEDATA, "VOL_CAP_INT_EXCHANGEDATA" },
{ VOL_CAP_INT_COPYFILE, "VOL_CAP_INT_COPYFILE" },
{ VOL_CAP_INT_ALLOCATE, "VOL_CAP_INT_ALLOCATE" },
{ VOL_CAP_INT_VOL_RENAME, "VOL_CAP_INT_VOL_RENAME" },
{ VOL_CAP_INT_ADVLOCK, "VOL_CAP_INT_ADVLOCK" },
{ VOL_CAP_INT_FLOCK, "VOL_CAP_INT_FLOCK" },
{ VOL_CAP_INT_EXTENDED_SECURITY, "VOL_CAP_INT_EXTENDED_SECURITY" },
{ VOL_CAP_INT_USERACCESS, "VOL_CAP_INT_USERACCESS" },
{ VOL_CAP_INT_MANLOCK, "VOL_CAP_INT_MANLOCK" },
{ VOL_CAP_INT_NAMEDSTREAMS, "VOL_CAP_INT_NAMEDSTREAMS" },
{ VOL_CAP_INT_EXTENDED_ATTR, "VOL_CAP_INT_EXTENDED_ATTR" },
{ 0, NULL }
};
static void PrintVolCap(const u_int32_t *capList, uint32_t indent, uint32_t verbose)
// Prints a vol_capabilities_set_t array which is made up of 5 u_int32_t
// elements). Only two of the elements are currently used
// (with indexes VOL_CAPABILITIES_FORMAT and VOL_CAPABILITIES_INTERFACES)
// and, for those, we print all the flags. The remainder are just printed
// in hex.
{
assert(capList != NULL);
fprintf(stdout, "%*sVOL_CAPABILITIES_FORMAT = 0x%08" PRIx32 "\n", (int) indent, "", capList[VOL_CAPABILITIES_FORMAT]);
if (verbose > 0) {
FPPrintFlags(capList[VOL_CAPABILITIES_FORMAT], kVolCapFormatFlags, strlen(kVolCapFlagSpacer), indent + kStdIndent);
}
fprintf(stdout, "%*sVOL_CAPABILITIES_INTERFACES = 0x%08" PRIx32 "\n", (int) indent, "", capList[VOL_CAPABILITIES_INTERFACES]);
if (verbose > 0) {
FPPrintFlags(capList[VOL_CAPABILITIES_INTERFACES], kVolCapInterfacesFlags, strlen(kVolCapFlagSpacer), indent + kStdIndent);
}
fprintf(stdout, "%*sVOL_CAPABILITIES_RESERVED1 = 0x%08" PRIx32 "\n", (int) indent, "", capList[VOL_CAPABILITIES_RESERVED1]);
fprintf(stdout, "%*sVOL_CAPABILITIES_RESERVED1 = 0x%08" PRIx32 "\n", (int) indent, "", capList[VOL_CAPABILITIES_RESERVED2]);
}
static void FPVolCap(
const char * fieldName,
size_t fieldSize,
const void * fieldPtr,
uint32_t indent,
size_t nameWidth,
uint32_t verbose,
const void * info
)
// Prints a vol_capabilities_attr_t field.
//
// See definition of FPPrinter for a parameter description.
{
const vol_capabilities_attr_t * volCap;
#pragma unused(fieldSize)
#pragma unused(nameWidth)
#pragma unused(info)
assert( FPStandardPreCondition() );
assert(fieldSize == sizeof(vol_capabilities_attr_t));
volCap = (const vol_capabilities_attr_t *) fieldPtr;
fprintf(stdout, "%*s%s\n", (int) indent, "", fieldName);
fprintf(stdout, "%*scapabilities\n", (int) (indent + kStdIndent), "");
PrintVolCap(volCap->capabilities, (int) (indent + 2 * kStdIndent), verbose);
if (verbose > 1) {
fprintf(stdout, "%*svalid\n", (int) (indent + kStdIndent), "");
PrintVolCap(volCap->valid, (int) (indent + 2 * kStdIndent), verbose);
}
}
static void PrintAttrSet(const attribute_set_t *attrSet, uint32_t indent, uint32_t verbose)
// Prints an attribute_set_t structure. If emulated is true,
// this just prints the first two elements because those are the
// only ones that we calculated as part of the emulation.
//
// indent and verbose are as per the comments for FPPrinter.
{
static const char kVolAttrFlagSpacer[] = "ATTR_VOL_ALLOCATIONCLUMP";
assert(attrSet != NULL);
// Using strlen(kVolAttrFlagSpacer) for the nameWidth ensures that all of
// the flags are printed with a consistent name width.
fprintf(stdout, "%*scommonattr = 0x%08" PRIx32 "\n", (int) indent, "", attrSet->commonattr);
if (verbose > 0) {
FPPrintFlags(attrSet->commonattr, gCommonAttrFlags, strlen(kVolAttrFlagSpacer), indent + kStdIndent);
}
fprintf(stdout, "%*svolattr = 0x%08" PRIx32 "\n", (int) indent, "", attrSet->volattr);
if (verbose > 0) {
FPPrintFlags(attrSet->volattr, gVolumeAttrFlags, strlen(kVolAttrFlagSpacer), indent + kStdIndent);
}
fprintf(stdout, "%*sdirattr = 0x%08" PRIx32 "\n", (int) indent, "", attrSet->dirattr);
if (verbose > 0) {
FPPrintFlags(attrSet->dirattr, gDirAttrFlags, strlen(kVolAttrFlagSpacer), indent + kStdIndent);
}
fprintf(stdout, "%*sfileattr = 0x%08" PRIx32 "\n", (int) indent, "", attrSet->fileattr);
if (verbose > 0) {
FPPrintFlags(attrSet->fileattr, gFileAttrFlags, strlen(kVolAttrFlagSpacer), indent + kStdIndent);
}
fprintf(stdout, "%*sforkattr = 0x%08" PRIx32 "\n", (int) indent, "", attrSet->forkattr);
if (verbose > 0) {
FPPrintFlags(attrSet->forkattr, gForkAttrFlags, strlen(kVolAttrFlagSpacer), indent + kStdIndent);
}
}
static void FPVolAttr(
const char * fieldName,
size_t fieldSize,
const void * fieldPtr,
uint32_t indent,
size_t nameWidth,
uint32_t verbose,
const void * info
)
// Prints a vol_attributes_attr_t field.
//
// See definition of FPPrinter for a parameter description.
{
const vol_attributes_attr_t * volAttr;
#pragma unused(fieldSize)
#pragma unused(nameWidth)
#pragma unused(info)
assert( FPStandardPreCondition() );
assert(fieldSize == sizeof(vol_attributes_attr_t));
volAttr = (const vol_attributes_attr_t *) fieldPtr;
fprintf(stdout, "%*s%s\n", (int) indent, "", fieldName);
fprintf(stdout, "%*svalidattr\n", (int) (indent + kStdIndent), "");
PrintAttrSet(&volAttr->validattr, indent + 2 * kStdIndent, ((verbose > 0) ? verbose - 1 : 0) );
fprintf(stdout, "%*snativeattr\n", (int) (indent + kStdIndent), "");
PrintAttrSet(&volAttr->nativeattr, indent + 2 * kStdIndent, ((verbose > 0) ? verbose - 1 : 0) );
}
static const FPFlagDesc kACLFlags[] = {
{ KAUTH_ACL_DEFER_INHERIT, "KAUTH_ACL_DEFER_INHERIT" },
{ KAUTH_ACL_NO_INHERIT, "KAUTH_ACL_NO_INHERIT" },
{ 0, NULL }
};
static const FPEnumDesc kACEKinds[] = {
{ KAUTH_ACE_PERMIT, "KAUTH_ACE_PERMIT" },
{ KAUTH_ACE_DENY, "KAUTH_ACE_DENY" },
{ KAUTH_ACE_AUDIT, "KAUTH_ACE_AUDIT" },
{ KAUTH_ACE_ALARM, "KAUTH_ACE_ALARM" },
{ 0, NULL }
};
static const char kACEFlagsRightsSpacer[] = "KAUTH_VNODE_WRITE_EXTATTRIBUTES";
static const FPFlagDesc kACEFlags[] = {
{ KAUTH_ACE_INHERITED, "KAUTH_ACE_INHERITED" },
{ KAUTH_ACE_FILE_INHERIT, "KAUTH_ACE_FILE_INHERIT" },
{ KAUTH_ACE_DIRECTORY_INHERIT, "KAUTH_ACE_DIRECTORY_INHERIT" },
{ KAUTH_ACE_LIMIT_INHERIT, "KAUTH_ACE_LIMIT_INHERIT" },
{ KAUTH_ACE_ONLY_INHERIT, "KAUTH_ACE_ONLY_INHERIT" },
{ KAUTH_ACE_SUCCESS, "KAUTH_ACE_SUCCESS" },
{ KAUTH_ACE_FAILURE, "KAUTH_ACE_FAILURE" },
{ 0, NULL }
};
static const FPFlagDesc kACERights[] = {
{ KAUTH_VNODE_LIST_DIRECTORY, "KAUTH_VNODE_LIST_DIRECTORY" },
{ KAUTH_VNODE_ADD_FILE, "KAUTH_VNODE_ADD_FILE" },
{ KAUTH_VNODE_SEARCH, "KAUTH_VNODE_SEARCH" },
{ KAUTH_VNODE_DELETE, "KAUTH_VNODE_DELETE" },
{ KAUTH_VNODE_ADD_SUBDIRECTORY, "KAUTH_VNODE_ADD_SUBDIRECTORY" },
{ KAUTH_VNODE_DELETE_CHILD, "KAUTH_VNODE_DELETE_CHILD" },
{ KAUTH_VNODE_READ_ATTRIBUTES, "KAUTH_VNODE_READ_ATTRIBUTES" },
{ KAUTH_VNODE_WRITE_ATTRIBUTES, "KAUTH_VNODE_WRITE_ATTRIBUTES" },
{ KAUTH_VNODE_READ_EXTATTRIBUTES, "KAUTH_VNODE_READ_EXTATTRIBUTES" },
{ KAUTH_VNODE_WRITE_EXTATTRIBUTES, "KAUTH_VNODE_WRITE_EXTATTRIBUTES" },
{ KAUTH_VNODE_READ_SECURITY, "KAUTH_VNODE_READ_SECURITY" },
{ KAUTH_VNODE_WRITE_SECURITY, "KAUTH_VNODE_WRITE_SECURITY" },
{ KAUTH_VNODE_TAKE_OWNERSHIP, "KAUTH_VNODE_TAKE_OWNERSHIP" },
{ KAUTH_VNODE_SYNCHRONIZE, "KAUTH_VNODE_SYNCHRONIZE" },
{ KAUTH_ACE_GENERIC_ALL, "KAUTH_ACE_GENERIC_ALL" },
{ KAUTH_ACE_GENERIC_EXECUTE, "KAUTH_ACE_GENERIC_EXECUTE" },
{ KAUTH_ACE_GENERIC_WRITE, "KAUTH_ACE_GENERIC_WRITE" },
{ KAUTH_ACE_GENERIC_READ, "KAUTH_ACE_GENERIC_READ" },
{ 0, NULL }
};
extern void FPKauthFileSec(
const char * fieldName,
size_t fieldSize,
const void * fieldPtr,
uint32_t indent,
size_t nameWidth,
uint32_t verbose,
const void * info
)
// Prints a kauth_filesec_t field. This routine is exported for the benefit
// of the File Manager module.
//
// See definition of FPPrinter for a parameter description.
{
#pragma unused(fieldSize)
#pragma unused(info)
kauth_filesec_t fileSec;
u_int32_t aceIndex;
u_int32_t aceKind;
static const char kFSecFieldNameSpacer[] = "fsec_magic";
static const char kACLFieldNameSpacer[] = "acl_entrycount";
static const char kACEFieldNameSpacer[] = "ace_applicable";
#pragma unused(fieldSize)
#pragma unused(info)
assert( FPStandardPreCondition() );
assert(fieldSize >= offsetof(struct kauth_filesec, fsec_acl));
assert(fieldSize <= KAUTH_FILESEC_SIZE(KAUTH_ACL_MAX_ENTRIES));
// Grab the attribute data and cast it to a kauth_filesec_t.
fileSec = (kauth_filesec_t) fieldPtr;
assert(fileSec->fsec_magic == KAUTH_FILESEC_MAGIC);
fprintf(stdout, "%*s%s:\n", (int) indent, "", fieldName);
// Originally I printed the ACL contents by calling acl_to_text, but I didn't like
// the output format so now I do it manually.
FPHex( "fsec_magic", sizeof(fileSec->fsec_magic), &fileSec->fsec_magic, indent + kStdIndent, strlen(kFSecFieldNameSpacer), verbose, NULL);
FPGUID("fsec_owner", sizeof(fileSec->fsec_owner), &fileSec->fsec_owner, indent + kStdIndent, strlen(kFSecFieldNameSpacer), verbose, NULL);
FPGUID("fsec_group", sizeof(fileSec->fsec_group), &fileSec->fsec_group, indent + kStdIndent, strlen(kFSecFieldNameSpacer), verbose, NULL);
fprintf(stdout, "%*s%-*s\n", (int) (indent + kStdIndent), "", (int) nameWidth, "fsec_acl:");
FPUDec("acl_entrycount", sizeof(fileSec->fsec_acl.acl_entrycount), &fileSec->fsec_acl.acl_entrycount, indent + 2 * kStdIndent, strlen(kACLFieldNameSpacer), verbose, NULL);
FPHex( "acl_flags", sizeof(fileSec->fsec_acl.acl_flags), &fileSec->fsec_acl.acl_flags, indent + 2 * kStdIndent, strlen(kACLFieldNameSpacer), verbose, NULL);
if (verbose > 0) {
FPPrintFlags(fileSec->fsec_acl.acl_flags, kACLFlags, 0, indent + 3 * kStdIndent);
}
if (fileSec->fsec_acl.acl_entrycount != KAUTH_FILESEC_NOACL) {
// The attribute must be big enough to contain the number of ACL entries.
assert(fieldSize >= KAUTH_FILESEC_SIZE(fileSec->fsec_acl.acl_entrycount));
for (aceIndex = 0; aceIndex < fileSec->fsec_acl.acl_entrycount; aceIndex++) {
kauth_ace_t thisACE;
thisACE = &fileSec->fsec_acl.acl_ace[aceIndex];
fprintf(stdout, "%*sacl_ace[%" PRIu32 "]\n", (int) (indent + 2 * kStdIndent), "", aceIndex);
FPGUID("ace_applicable", sizeof(thisACE->ace_applicable), &thisACE->ace_applicable, indent + 3 * kStdIndent, strlen(kACEFieldNameSpacer), verbose, NULL);
FPHex( "ace_flags", sizeof(thisACE->ace_flags), &thisACE->ace_flags, indent + 3 * kStdIndent, strlen(kACEFieldNameSpacer), verbose, NULL);
if (verbose > 0) {
aceKind = thisACE->ace_flags & KAUTH_ACE_KINDMASK;
FPEnum("kind", sizeof(aceKind), &aceKind, indent + 4 * kStdIndent, strlen(kACEFlagsRightsSpacer), verbose, &kACEKinds);
FPPrintFlags(thisACE->ace_flags & ~KAUTH_ACE_KINDMASK, kACEFlags, strlen(kACEFlagsRightsSpacer), indent + 4 * kStdIndent);
}
FPHex( "ace_rights", sizeof(thisACE->ace_rights), &thisACE->ace_rights, indent + 3 * kStdIndent, strlen(kACEFieldNameSpacer), verbose, NULL);
if (verbose > 0) {
FPPrintFlags(thisACE->ace_rights, kACERights, 0, indent + 4 * kStdIndent);
}
}
}
}
static void ACLAttrPrinter(
const char * fieldName,
size_t fieldSize,
const void * fieldPtr,
uint32_t indent,
size_t nameWidth,
uint32_t verbose,
const void * info
)
// Prints an ACL attribute, as referenced by an attrreference_t structure
// in the buffer returned by getattrlist.
//
// See definition of FPPrinter for a parameter description.
{
attrreference_t * attrRef;
#pragma unused(fieldSize)
#pragma unused(verbose)
#pragma unused(info)
assert( FPStandardPreCondition() );
assert(fieldSize == sizeof(attrreference_t));
attrRef = ( (attrreference_t *) fieldPtr );
if (attrRef->attr_length != 0) {
FPKauthFileSec(fieldName, attrRef->attr_length, ((char *) attrRef) + attrRef->attr_dataoffset, (int) indent, (int) nameWidth, verbose, NULL);
}
}
// An array of AttrDesc is used to hold information about a set of attributes
// as returned by getattrlist. The array is terminated by an entry with a NULL
// name.
static void PrintAttributes(
const AttrDesc attrs[],
attrgroup_t attrMask,
const char ** cursorPtr,
uint32_t indent,
size_t nameWidth,
uint32_t verbose,
FinderInfoFlavour finderFlavour
)
// Prints an attribute buffer as returned by getattrlist.
// attrs is a pointer to an array of AttrDesc that describe
// all of the supported attributes. attrMask is a bitmap
// describing which of those attributes are present in the buffer.
// cursorPtr is a pointer a cursor pointer, which in turn points
// to a buffer containing the attribute data. *cursorPtr points
// to the current place in the buffer. When the routine is done
// it updates *cursorPtr to point to just after the last attribute
// that it has printed. indent, nameWidth and verbose are as
// per the comments for FPPrinter. finderFlavour controls how
// Finder info should be printed; it's necessary because Finder
// info is object type dependent.
{
size_t attrIndex;
const char * cursor;
assert(attrs != NULL);
assert( cursorPtr != NULL);
assert(*cursorPtr != NULL);
cursor = *cursorPtr;
attrIndex = 0;
while (attrs[attrIndex].attrName != NULL) {
if (attrMask & attrs[attrIndex].attrMask) {
FPPrinter printer;
printer = attrs[attrIndex].attrPrinter;
if (printer == FPFinderInfoBE) {
printer(attrs[attrIndex].attrName, attrs[attrIndex].attrSize, cursor, indent, nameWidth, verbose, (const void *) (uintptr_t) finderFlavour);
} else {
printer(attrs[attrIndex].attrName, attrs[attrIndex].attrSize, cursor, indent, nameWidth, verbose, attrs[attrIndex].attrInfo);
}
cursor += attrs[attrIndex].attrSize;
}
attrIndex += 1;
}
*cursorPtr = cursor;
}
// The known constants for fsobj_type_t attributes.
static const FPEnumDesc kFSObjTypeEnums[] = {
{ VNON, "VNON" },
{ VREG, "VREG" },
{ VDIR, "VDIR" },
{ VBLK, "VBLK" },
{ VCHR, "VCHR" },
{ VLNK, "VLNK" },
{ VSOCK, "VSOCK" },
{ VFIFO, "VFIFO" },
{ VBAD, "VBAD" },
{ VSTR, "VSTR" },
{ VCPLX, "VCPLX" },
{ 0, NULL }
};
// The known constants for fsobj_tag_t attributes.
static const FPEnumDesc kFSObjTagEnums[] = {
{ VT_NON, "VT_NON" },
{ VT_UFS, "VT_UFS" },
{ VT_NFS, "VT_NFS" },
{ VT_MFS, "VT_MFS" },
{ VT_MSDOSFS, "VT_MSDOSFS" },
{ VT_LFS, "VT_LFS" },
{ VT_LOFS, "VT_LOFS" },
{ VT_FDESC, "VT_FDESC" },
{ VT_PORTAL, "VT_PORTAL" },
{ VT_NULL, "VT_NULL" },
{ VT_UMAP, "VT_UMAP" },
{ VT_KERNFS, "VT_KERNFS" },
{ VT_PROCFS, "VT_PROCFS" },
{ VT_AFS, "VT_AFS" },
{ VT_ISOFS, "VT_ISOFS" },
{ VT_UNION, "VT_UNION" },
{ VT_HFS, "VT_HFS" },
{ VT_ZFS, "VT_ZFS" }, // was VT_VOLFS prior to 10.5
{ VT_DEVFS, "VT_DEVFS" },
{ VT_WEBDAV, "VT_WEBDAV" },
{ VT_UDF, "VT_UDF" },
{ VT_AFP, "VT_AFP" },
{ VT_CDDA, "VT_CDDA" },
{ VT_CIFS, "VT_CIFS" },
{ VT_OTHER, "VT_OTHER" },
{ 0, NULL }
};
// Some well known values for the text_encoding_t type
// (equivalent to the Carbon TextEncoding type). Note that this
// doesn't cover all possible values, just those that you're
// likely to encounter in a file system.
const FPEnumDesc kTextEncodingEnums[] = {
{ kTextEncodingMacRoman, "kTextEncodingMacRoman" },
{ kTextEncodingMacJapanese, "kTextEncodingMacJapanese" },
{ kTextEncodingMacChineseTrad, "kTextEncodingMacChineseTrad" },
{ kTextEncodingMacKorean, "kTextEncodingMacKorean" },
{ kTextEncodingMacArabic, "kTextEncodingMacArabic" },
{ kTextEncodingMacHebrew, "kTextEncodingMacHebrew" },
{ kTextEncodingMacGreek, "kTextEncodingMacGreek" },
{ kTextEncodingMacCyrillic, "kTextEncodingMacCyrillic" },
{ kTextEncodingMacDevanagari, "kTextEncodingMacDevanagari" },
{ kTextEncodingMacGurmukhi, "kTextEncodingMacGurmukhi" },
{ kTextEncodingMacGujarati, "kTextEncodingMacGujarati" },
{ kTextEncodingMacOriya, "kTextEncodingMacOriya" },
{ kTextEncodingMacBengali, "kTextEncodingMacBengali" },
{ kTextEncodingMacTamil, "kTextEncodingMacTamil" },
{ kTextEncodingMacTelugu, "kTextEncodingMacTelugu" },
{ kTextEncodingMacKannada, "kTextEncodingMacKannada" },
{ kTextEncodingMacMalayalam, "kTextEncodingMacMalayalam" },
{ kTextEncodingMacSinhalese, "kTextEncodingMacSinhalese" },
{ kTextEncodingMacBurmese, "kTextEncodingMacBurmese" },
{ kTextEncodingMacKhmer, "kTextEncodingMacKhmer" },
{ kTextEncodingMacThai, "kTextEncodingMacThai" },
{ kTextEncodingMacLaotian, "kTextEncodingMacLaotian" },
{ kTextEncodingMacGeorgian, "kTextEncodingMacGeorgian" },
{ kTextEncodingMacArmenian, "kTextEncodingMacArmenian" },
{ kTextEncodingMacChineseSimp, "kTextEncodingMacChineseSimp" },
{ kTextEncodingMacTibetan, "kTextEncodingMacTibetan" },
{ kTextEncodingMacMongolian, "kTextEncodingMacMongolian" },
{ kTextEncodingMacEthiopic, "kTextEncodingMacEthiopic" },
{ kTextEncodingMacCentralEurRoman, "kTextEncodingMacCentralEurRoman" },
{ kTextEncodingMacVietnamese, "kTextEncodingMacVietnamese" },
{ kTextEncodingMacExtArabic, "kTextEncodingMacExtArabic" },
{ kTextEncodingMacSymbol, "kTextEncodingMacSymbol" },
{ kTextEncodingMacDingbats, "kTextEncodingMacDingbats" },
{ kTextEncodingMacTurkish, "kTextEncodingMacTurkish" },
{ kTextEncodingMacCroatian, "kTextEncodingMacCroatian" },
{ kTextEncodingMacIcelandic, "kTextEncodingMacIcelandic" },
{ kTextEncodingMacRomanian, "kTextEncodingMacRomanian" },
{ kTextEncodingMacCeltic, "kTextEncodingMacCeltic" },
{ kTextEncodingMacGaelic, "kTextEncodingMacGaelic" },
{ kTextEncodingMacKeyboardGlyphs, "kTextEncodingMacKeyboardGlyphs" },
{ kTextEncodingMacRSymbol, "kTextEncodingMacRSymbol" },
{ kTextEncodingMacUninterp, "kTextEncodingMacUninterp" },
{ kTextEncodingMacUnicode, "kTextEncodingMacUnicode" },
{ kTextEncodingMacFarsi, "kTextEncodingMacFarsi" },
{ kTextEncodingMacUkrainian, "kTextEncodingMacUkrainian" },
{ kTextEncodingMacInuit, "kTextEncodingMacInuit" },
{ kTextEncodingMacVT100, "kTextEncodingMacVT100" },
{ 0, NULL },
};
// Flags for the ATTR_CMN_USERACCESS attribute.
static const FPFlagDesc kUserAccessFlags[] = {
{ R_OK, "R_OK" },
{ W_OK, "W_OK" },
{ X_OK, "X_OK" },
{ 0, NULL }
};
// Flags for the ATTR_VOL_ENCODINGSUSED attribute.
// Note the weird values for the last two entries.
static const FPFlagDesc kEncodingsUsedFlags[] = {
{ 1LL << kTextEncodingMacRoman, "kTextEncodingMacRoman" },
{ 1LL << kTextEncodingMacRoman, "kTextEncodingMacRoman" },
{ 1LL << kTextEncodingMacJapanese, "kTextEncodingMacJapanese" },
{ 1LL << kTextEncodingMacChineseTrad, "kTextEncodingMacChineseTrad" },
{ 1LL << kTextEncodingMacKorean, "kTextEncodingMacKorean" },
{ 1LL << kTextEncodingMacArabic, "kTextEncodingMacArabic" },
{ 1LL << kTextEncodingMacHebrew, "kTextEncodingMacHebrew" },
{ 1LL << kTextEncodingMacGreek, "kTextEncodingMacGreek" },
{ 1LL << kTextEncodingMacCyrillic, "kTextEncodingMacCyrillic" },
{ 1LL << kTextEncodingMacRSymbol, "kTextEncodingMacRSymbol" },
{ 1LL << kTextEncodingMacDevanagari, "kTextEncodingMacDevanagari" },
{ 1LL << kTextEncodingMacGurmukhi, "kTextEncodingMacGurmukhi" },
{ 1LL << kTextEncodingMacGujarati, "kTextEncodingMacGujarati" },
{ 1LL << kTextEncodingMacOriya, "kTextEncodingMacOriya" },
{ 1LL << kTextEncodingMacBengali, "kTextEncodingMacBengali" },
{ 1LL << kTextEncodingMacTamil, "kTextEncodingMacTamil" },
{ 1LL << kTextEncodingMacTelugu, "kTextEncodingMacTelugu" },
{ 1LL << kTextEncodingMacKannada, "kTextEncodingMacKannada" },
{ 1LL << kTextEncodingMacMalayalam, "kTextEncodingMacMalayalam" },
{ 1LL << kTextEncodingMacSinhalese, "kTextEncodingMacSinhalese" },
{ 1LL << kTextEncodingMacBurmese, "kTextEncodingMacBurmese" },
{ 1LL << kTextEncodingMacKhmer, "kTextEncodingMacKhmer" },
{ 1LL << kTextEncodingMacThai, "kTextEncodingMacThai" },
{ 1LL << kTextEncodingMacLaotian, "kTextEncodingMacLaotian" },
{ 1LL << kTextEncodingMacGeorgian, "kTextEncodingMacGeorgian" },
{ 1LL << kTextEncodingMacArmenian, "kTextEncodingMacArmenian" },
{ 1LL << kTextEncodingMacChineseSimp, "kTextEncodingMacChineseSimp" },
{ 1LL << kTextEncodingMacTibetan, "kTextEncodingMacTibetan" },
{ 1LL << kTextEncodingMacMongolian, "kTextEncodingMacMongolian" },
{ 1LL << kTextEncodingMacEthiopic, "kTextEncodingMacEthiopic" },
{ 1LL << kTextEncodingMacCentralEurRoman, "kTextEncodingMacCentralEurRoman" },
{ 1LL << kTextEncodingMacVietnamese, "kTextEncodingMacVietnamese" },
{ 1LL << kTextEncodingMacExtArabic, "kTextEncodingMacExtArabic" },
{ 1LL << kTextEncodingMacUninterp, "kTextEncodingMacUninterp" },
{ 1LL << kTextEncodingMacSymbol, "kTextEncodingMacSymbol" },
{ 1LL << kTextEncodingMacDingbats, "kTextEncodingMacDingbats" },
{ 1LL << kTextEncodingMacTurkish, "kTextEncodingMacTurkish" },
{ 1LL << kTextEncodingMacCroatian, "kTextEncodingMacCroatian" },
{ 1LL << kTextEncodingMacIcelandic, "kTextEncodingMacIcelandic" },
{ 1LL << kTextEncodingMacRomanian, "kTextEncodingMacRomanian" },
{ 1LL << kTextEncodingMacCeltic, "kTextEncodingMacCeltic" },
{ 1LL << kTextEncodingMacGaelic, "kTextEncodingMacGaelic" },
{ 1LL << kTextEncodingMacKeyboardGlyphs, "kTextEncodingMacKeyboardGlyphs" },
{ 1LL << 49, "kTextEncodingMacFarsi" }, // note the special case
{ 1LL << 48, "kTextEncodingMacUkrainian" }, // note the special case
{ 0, NULL }
};
// Common attributes, that is, those that are valid for all file system objects.
static const AttrDesc kCommonAttrDesc[] = {
{ATTR_CMN_NAME, "ATTR_CMN_NAME", kAttrRefSize, StringAttrPrinter, NULL},
{ATTR_CMN_DEVID, "ATTR_CMN_DEVID", sizeof(dev_t), FPDevT, NULL},
{ATTR_CMN_FSID, "ATTR_CMN_FSID", sizeof(fsid_t), FPFSID, NULL},
{ATTR_CMN_OBJTYPE, "ATTR_CMN_OBJTYPE", sizeof(fsobj_type_t), FPEnum, kFSObjTypeEnums},
{ATTR_CMN_OBJTAG, "ATTR_CMN_OBJTAG", sizeof(fsobj_tag_t), FPEnum, kFSObjTagEnums},
{ATTR_CMN_OBJID, "ATTR_CMN_OBJID", sizeof(fsobj_id_t), FPFSObjID, NULL},
{ATTR_CMN_OBJPERMANENTID, "ATTR_CMN_OBJPERMANENTID", sizeof(fsobj_id_t), FPFSObjID, NULL},
{ATTR_CMN_PAROBJID, "ATTR_CMN_PAROBJID", sizeof(fsobj_id_t), FPFSObjID, NULL},
{ATTR_CMN_SCRIPT, "ATTR_CMN_SCRIPT", sizeof(text_encoding_t), FPEnum, kTextEncodingEnums},
{ATTR_CMN_CRTIME, "ATTR_CMN_CRTIME", sizeof(struct timespec), FPTimeSpec, NULL},
{ATTR_CMN_MODTIME, "ATTR_CMN_MODTIME", sizeof(struct timespec), FPTimeSpec, NULL},
{ATTR_CMN_CHGTIME, "ATTR_CMN_CHGTIME", sizeof(struct timespec), FPTimeSpec, NULL},
{ATTR_CMN_ACCTIME, "ATTR_CMN_ACCTIME", sizeof(struct timespec), FPTimeSpec, NULL},
{ATTR_CMN_BKUPTIME, "ATTR_CMN_BKUPTIME", sizeof(struct timespec), FPTimeSpec, NULL},
{ATTR_CMN_FNDRINFO, "ATTR_CMN_FNDRINFO", 32, FPFinderInfoBE, NULL},
{ATTR_CMN_OWNERID, "ATTR_CMN_OWNERID", sizeof(uid_t), FPUID, NULL},
{ATTR_CMN_GRPID, "ATTR_CMN_GRPID", sizeof(gid_t), FPGID, NULL},
{ATTR_CMN_ACCESSMASK, "ATTR_CMN_ACCESSMASK", sizeof(uint32_t), FPModeT, NULL},
{ATTR_CMN_NAMEDATTRCOUNT, "ATTR_CMN_NAMEDATTRCOUNT", sizeof(uint32_t), FPUDec, NULL},
{ATTR_CMN_NAMEDATTRLIST, "ATTR_CMN_NAMEDATTRLIST", kAttrRefSize, FPNull, NULL},
{ATTR_CMN_FLAGS, "ATTR_CMN_FLAGS", sizeof(uint32_t), FPFlags, kChFlagsFlags},
{ATTR_CMN_USERACCESS, "ATTR_CMN_USERACCESS", sizeof(uint32_t), FPFlags, kUserAccessFlags},
{ATTR_CMN_EXTENDED_SECURITY,"ATTR_CMN_EXTENDED_SECURITY", kAttrRefSize, ACLAttrPrinter, NULL},
{ATTR_CMN_UUID, "ATTR_CMN_UUID", sizeof(guid_t), FPGUID, NULL},
{ATTR_CMN_GRPUUID, "ATTR_CMN_GRPUUID", sizeof(guid_t), FPGUID, NULL},
{ATTR_CMN_FILEID, "ATTR_CMN_FILEID", sizeof(uint64_t), FPUDec, NULL},
{ATTR_CMN_PARENTID, "ATTR_CMN_PARENTID", sizeof(uint64_t), FPUDec, NULL},
{0, NULL, 0, NULL, NULL}
};
// Volume attributes, valid only for volumes.
static const AttrDesc kVolumeAttrDesc[] = {
{ATTR_VOL_INFO, "ATTR_VOL_INFO", 0, FPNull, NULL},
{ATTR_VOL_FSTYPE, "ATTR_VOL_FSTYPE", sizeof(uint32_t), FPEnum, kFSTypeEnums},
{ATTR_VOL_SIGNATURE, "ATTR_VOL_SIGNATURE", sizeof(uint32_t), FPSignature, (const void *) (uintptr_t) kFPValueHostEndian},
{ATTR_VOL_SIZE, "ATTR_VOL_SIZE", sizeof(off_t), FPSize, NULL},
{ATTR_VOL_SPACEFREE, "ATTR_VOL_SPACEFREE", sizeof(off_t), FPSize, NULL},
{ATTR_VOL_SPACEAVAIL, "ATTR_VOL_SPACEAVAIL", sizeof(off_t), FPSize, NULL},
{ATTR_VOL_MINALLOCATION, "ATTR_VOL_MINALLOCATION", sizeof(off_t), FPSize, NULL},
{ATTR_VOL_ALLOCATIONCLUMP, "ATTR_VOL_ALLOCATIONCLUMP", sizeof(off_t), FPSize, NULL},
{ATTR_VOL_IOBLOCKSIZE, "ATTR_VOL_IOBLOCKSIZE", sizeof(uint32_t), FPSize, NULL},
{ATTR_VOL_OBJCOUNT, "ATTR_VOL_OBJCOUNT", sizeof(uint32_t), FPUDec, NULL},
{ATTR_VOL_FILECOUNT, "ATTR_VOL_FILECOUNT", sizeof(uint32_t), FPUDec, NULL},
{ATTR_VOL_DIRCOUNT, "ATTR_VOL_DIRCOUNT", sizeof(uint32_t), FPUDec, NULL},
{ATTR_VOL_MAXOBJCOUNT, "ATTR_VOL_MAXOBJCOUNT", sizeof(uint32_t), FPUDec, NULL},
{ATTR_VOL_MOUNTPOINT, "ATTR_VOL_MOUNTPOINT", kAttrRefSize, StringAttrPrinter, NULL},
{ATTR_VOL_NAME, "ATTR_VOL_NAME", kAttrRefSize, StringAttrPrinter, NULL},
{ATTR_VOL_MOUNTFLAGS, "ATTR_VOL_MOUNTFLAGS", sizeof(uint32_t), FPFlags, kMountFlags},
{ATTR_VOL_MOUNTEDDEVICE, "ATTR_VOL_MOUNTEDDEVICE", kAttrRefSize, StringAttrPrinter, NULL},
{ATTR_VOL_ENCODINGSUSED, "ATTR_VOL_ENCODINGSUSED", sizeof(unsigned long long), FPVerboseFlags, kEncodingsUsedFlags},
{ATTR_VOL_CAPABILITIES, "ATTR_VOL_CAPABILITIES", sizeof(vol_capabilities_attr_t),FPVolCap, NULL},
{ATTR_VOL_ATTRIBUTES, "ATTR_VOL_ATTRIBUTES", sizeof(vol_attributes_attr_t), FPVolAttr, NULL},
{0, NULL, 0, NULL, NULL}
};
// Directory attributes, valid only for directories.
static const FPFlagDesc kMountStatusFlags[] = {
{DIR_MNTSTATUS_MNTPOINT, "DIR_MNTSTATUS_MNTPOINT"},
{0, NULL}
};
static const AttrDesc kDirAttrDesc[] = {
{ATTR_DIR_LINKCOUNT, "ATTR_DIR_LINKCOUNT", sizeof(uint32_t), FPUDec, NULL},
{ATTR_DIR_ENTRYCOUNT, "ATTR_DIR_ENTRYCOUNT", sizeof(uint32_t), FPUDec, NULL},
{ATTR_DIR_MOUNTSTATUS, "ATTR_DIR_MOUNTSTATUS", sizeof(uint32_t), FPFlags, kMountStatusFlags},
{0, NULL, 0, NULL, NULL}
};
// File attributes, valid only for files.
static const AttrDesc kFileAttrDesc[] = {
{ATTR_FILE_LINKCOUNT, "ATTR_FILE_LINKCOUNT", sizeof(uint32_t), FPUDec, NULL},
{ATTR_FILE_TOTALSIZE, "ATTR_FILE_TOTALSIZE", sizeof(off_t), FPSize, NULL},
{ATTR_FILE_ALLOCSIZE, "ATTR_FILE_ALLOCSIZE", sizeof(off_t), FPSize, NULL},
{ATTR_FILE_IOBLOCKSIZE, "ATTR_FILE_IOBLOCKSIZE", sizeof(uint32_t), FPSize, NULL},
{ATTR_FILE_CLUMPSIZE, "ATTR_FILE_CLUMPSIZE", sizeof(uint32_t), FPSize, NULL},
{ATTR_FILE_DEVTYPE, "ATTR_FILE_DEVTYPE", sizeof(uint32_t), FPDevT, NULL}, // *** why does ATTR_FILE_DEVTYPE come back 0 on Tiger
{ATTR_FILE_FILETYPE, "ATTR_FILE_FILETYPE", sizeof(uint32_t), FPUDec, NULL},
{ATTR_FILE_FORKCOUNT, "ATTR_FILE_FORKCOUNT", sizeof(uint32_t), FPUDec, NULL},
{ATTR_FILE_FORKLIST, "ATTR_FILE_FORKLIST", kAttrRefSize, FPNull, NULL},
{ATTR_FILE_DATALENGTH, "ATTR_FILE_DATALENGTH", sizeof(off_t), FPSize, NULL},
{ATTR_FILE_DATAALLOCSIZE, "ATTR_FILE_DATAALLOCSIZE", sizeof(off_t), FPSize, NULL},
{ATTR_FILE_DATAEXTENTS, "ATTR_FILE_DATAEXTENTS", sizeof(extentrecord), FPHex, NULL},
{ATTR_FILE_RSRCLENGTH, "ATTR_FILE_RSRCLENGTH", sizeof(off_t), FPSize, NULL},
{ATTR_FILE_RSRCALLOCSIZE, "ATTR_FILE_RSRCALLOCSIZE", sizeof(off_t), FPSize, NULL},
{ATTR_FILE_RSRCEXTENTS, "ATTR_FILE_RSRCEXTENTS", sizeof(extentrecord), FPHex, NULL},
{0, NULL, 0, NULL, NULL}
};
// Fork attributes, valid only for forks. The whole concept of
// fork attributes is kinda bogus, but we report them anyway.
static const AttrDesc kForkAttrDesc[] = {
{ATTR_FORK_TOTALSIZE, "ATTR_FORK_TOTALSIZE", sizeof(off_t), FPUDec, NULL},
{ATTR_FORK_ALLOCSIZE, "ATTR_FORK_ALLOCSIZE", sizeof(off_t), FPUDec, NULL},
{0, NULL, 0, NULL, NULL}
};
static void InitAttrFlag(const AttrDesc attrs[], FPFlagDesc ** flagsPtr)
// Given an AttrDesc array, create the corresponding FPFlagDesc array.
// See InitAllAttrFlags for a discussion of why this is necessary.
{
size_t attrCount;
size_t attrIndex;
FPFlagDesc * flags;
assert( attrs != NULL);
assert( flagsPtr != NULL);
// Count the attributes. Make sure to include the trailing null entry
// in that count.
attrCount = 0;
while (attrs[attrCount].attrName != NULL) {
attrCount += 1;
}
attrCount += 1;
// Allocate space for the flags.
flags = (FPFlagDesc *) (malloc(attrCount * sizeof(FPFlagDesc)));
assert(flags != NULL);
// Create a flag for each attribute.
for (attrIndex = 0; attrIndex < attrCount; attrIndex++) {
flags[attrIndex].flagMask = attrs[attrIndex].attrMask;
flags[attrIndex].flagName = attrs[attrIndex].attrName;
}
*flagsPtr = flags;
}
static void InitAllAttrFlags(void)
// We need to have both an AttrDesc array (for printing the attributes in
// a buffer) and a FPFlagDesc array (parsing our command line arguments).
// Declaring these independently would be a maintenance nightmare, so we
// derive the less generic one (FPFlagDesc) from the more generic one
// (AttrDesc).
{
if (gCommonAttrFlags == NULL) {
InitAttrFlag(kCommonAttrDesc, &gCommonAttrFlags);
InitAttrFlag(kVolumeAttrDesc, &gVolumeAttrFlags);
InitAttrFlag(kDirAttrDesc, &gDirAttrFlags);
InitAttrFlag(kFileAttrDesc, &gFileAttrFlags);
InitAttrFlag(kForkAttrDesc, &gForkAttrFlags);
}
}
static void CalculateAttrInfo(
const AttrDesc attrs[],
attrgroup_t attrMask,
size_t * attrSizePtr,
size_t * nameWidthPtr,
attrgroup_t * supportedAttrPtr
)
// Calculates three pieces of useful information for an attribute set.
//
// o The size of the attributes.
//
// o The maximum width of the name of the attributes.
//
// o The attributes that we know about.
//
// You can ask for any combination of this information by setting the
// appropriate parameters to a non-NULL value.
//
// IMPORTANT:
// If you ask for a size (attrSizePtr), this routine increments the
// existing value of *attrSizePtr by the size. You must initialise
// the variable pointed to by attrSizePtr to an appropriate value.
//
// IMPORTANT:
// If you ask for the maximum name length (nameWidthPtr), you must in