-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathmygpfs.h
3298 lines (3014 loc) · 132 KB
/
mygpfs.h
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
/* */
/* Copyright (C) 2001 International Business Machines */
/* All rights reserved. */
/* */
/* This file is part of the GPFS user library. */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* 1. Redistributions of source code must retain the above copyright notice, */
/* this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* 3. The name of the author may not be used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES */
/* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. */
/* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, */
/* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; */
/* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, */
/* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR */
/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF */
/* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* */
/* %Z%%M% %I% %W% %G% %U% */
/*
* Library calls for GPFS interfaces
*/
#ifndef H_GPFS
#define H_GPFS
#include <stddef.h>
/* Define GPFS_64BIT_INODES to map the default interface definitions
to 64-bit interfaces. Without this define, the 32-bit interface
is the default. Both interfaces are always present, but the
define sets the default. The actual mapping can be found near the
end of this header. */
/* #define GPFS_64BIT_INODES 1 */
#ifdef __cplusplus
extern "C" {
#endif
#if defined(WIN32) && (defined(GPFSDLL) || defined(GWIN))
/* The following errno values either are missing from Windows errno.h or
have a conflicting value. Other errno values (e.g. EPERM) are okay. */
#define GPFS_EALREADY 37 /* Operation already in progress */
#define GPFS_EOPNOTSUPP 45 /* Operation not supported */
#define GPFS_EDQUOT 69 /* Disk quota exceeded */
#define GPFS_ESTALE 9 /* No filesystem (mapped to EBADF) */
#define GPFS_EFORMAT 19 /* Unformatted media (mapped to ENODEV) */
/* specify the library calling convention */
#define GPFS_API __stdcall
/* On Windows, this is a HANDLE as returned by CreateFile() */
typedef void* gpfs_file_t;
#else /* not WIN32 */
#define GPFS_API
/* On UNIX (and Windows SUA) systems, this is a file descriptor as
returned by open() */
typedef int gpfs_file_t;
#endif
typedef unsigned int gpfs_uid_t;
typedef long long gpfs_off64_t;
typedef unsigned long long gpfs_uid64_t;
typedef struct gpfs_timestruc
{
unsigned int tv_sec;
unsigned int tv_nsec;
} gpfs_timestruc_t;
typedef struct gpfs_timestruc64
{
long long tv_sec;
unsigned int tv_nsec;
} gpfs_timestruc64_t;
#define GPFS_SLITE_SIZE_BIT 0x00000001
#define GPFS_SLITE_BLKSIZE_BIT 0x00000002
#define GPFS_SLITE_BLOCKS_BIT 0x00000004
#define GPFS_SLITE_ATIME_BIT 0x00000010
#define GPFS_SLITE_MTIME_BIT 0x00000020
#define GPFS_SLITE_CTIME_BIT 0x00000040
#define GPFS_SLITE_EXACT_BITS 0x00000077
/* Returns "1" if the attribute is requested to be accurate.
(On output, indicates the value returned in statbufP is accurate). */
#define GPFS_SLITE(m) (0 == (m))
#define GPFS_SLITE_SIZET(m) (0 != ((m) & GPFS_SLITE_SIZE_BIT))
#define GPFS_SLITE_BLKSIZE(m) (0 != ((m) & GPFS_SLITE_BLKSIZE_BIT))
#define GPFS_SLITE_BLOCKS(m) (0 != ((m) & GPFS_SLITE_BLOCKS_BIT))
#define GPFS_SLITE_ATIME(m) (0 != ((m) & GPFS_SLITE_ATIME_BIT))
#define GPFS_SLITE_MTIME(m) (0 != ((m) & GPFS_SLITE_MTIME_BIT))
#define GPFS_SLITE_CTIME(m) (0 != ((m) & GPFS_SLITE_CTIME_BIT))
#define GPFS_SLITE_EXACT(m) (GPFS_SLITE_EXACT_BITS == (m))
/* Sets the litemask bit indicating that the attribute should be accurate */
#define GPFS_S_SLITE(m) (m) = 0
#define GPFS_S_SLITE_SIZET(m) (m) |= GPFS_SLITE_SIZE_BIT
#define GPFS_S_SLITE_BLKSIZE(m) (m) |= GPFS_SLITE_BLKSIZE_BIT
#define GPFS_S_SLITE_BLOCKS(m) (m) |= GPFS_SLITE_BLOCKS_BIT
#define GPFS_S_SLITE_ATIME(m) (m) |= GPFS_SLITE_ATIME_BIT
#define GPFS_S_SLITE_MTIME(m) (m) |= GPFS_SLITE_MTIME_BIT
#define GPFS_S_SLITE_CTIME(m) (m) |= GPFS_SLITE_CTIME_BIT
#define GPFS_S_SLITE_EXACT(m) (m) |= GPFS_SLITE_EXACT_BITS
#define GPFS_STATLITE 0
#define GPFS_NOFOLLOW 1
/* Mapping of buffer for gpfs_getacl, gpfs_putacl. */
typedef struct gpfs_opaque_acl
{
int acl_buffer_len; /* INPUT: Total size of buffer (including this field).
OUTPUT: Actual size of the ACL information. */
unsigned short acl_version; /* INPUT: Set to zero.
OUTPUT: Current version of the returned ACL. */
unsigned char acl_type; /* INPUT: Type of ACL: access (1) or default (2). */
char acl_var_data[1]; /* OUTPUT: Remainder of the ACL information. */
} gpfs_opaque_acl_t;
/* ACL types (acl_type field in gpfs_opaque_acl_t or gpfs_acl_t) */
#define GPFS_ACL_TYPE_ACCESS 1
#define GPFS_ACL_TYPE_DEFAULT 2
#define GPFS_ACL_TYPE_NFS4 3
/* gpfs_getacl, gpfs_putacl flag indicating structures instead of the
opaque style data normally used. */
#define GPFS_GETACL_STRUCT 0x00000020
#define GPFS_PUTACL_STRUCT 0x00000020
/* gpfs_getacl, gpfs_putacl flag indicating smbd is the caller */
#define GPFS_ACL_SAMBA 0x00000040
/* Defined values for gpfs_aclVersion_t */
#define GPFS_ACL_VERSION_POSIX 1
#define GPFS_ACL_VERSION_NFS4 4
/* Values for gpfs_aclLevel_t */
#define GPFS_ACL_LEVEL_BASE 0 /* compatible with all acl_version values */
#define GPFS_ACL_LEVEL_V4FLAGS 1 /* requires GPFS_ACL_VERSION_NFS4 */
/* Values for gpfs_aceType_t (ACL_VERSION_POSIX) */
#define GPFS_ACL_USER_OBJ 1
#define GPFS_ACL_GROUP_OBJ 2
#define GPFS_ACL_OTHER 3
#define GPFS_ACL_MASK 4
#define GPFS_ACL_USER 5
#define GPFS_ACL_GROUP 6
/* Values for gpfs_acePerm_t (ACL_VERSION_POSIX) */
#define ACL_PERM_EXECUTE 001
#define ACL_PERM_WRITE 002
#define ACL_PERM_READ 004
#define ACL_PERM_CONTROL 010
/* Values for gpfs_aceType_t (ACL_VERSION_NFS4) */
#define ACE4_TYPE_ALLOW 0
#define ACE4_TYPE_DENY 1
#define ACE4_TYPE_AUDIT 2
#define ACE4_TYPE_ALARM 3
/* Values for gpfs_aceFlags_t (ACL_VERSION_NFS4) */
#define ACE4_FLAG_FILE_INHERIT 0x00000001
#define ACE4_FLAG_DIR_INHERIT 0x00000002
#define ACE4_FLAG_NO_PROPAGATE 0x00000004
#define ACE4_FLAG_INHERIT_ONLY 0x00000008
#define ACE4_FLAG_SUCCESSFUL 0x00000010
#define ACE4_FLAG_FAILED 0x00000020
#define ACE4_FLAG_GROUP_ID 0x00000040
#define ACE4_FLAG_INHERITED 0x00000080
/* GPFS-defined flags. Placed in a seperate ACL field to avoid
ever running into newly defined NFSv4 flags. */
#define ACE4_IFLAG_SPECIAL_ID 0x80000000
/* Values for gpfs_aceMask_t (ACL_VERSION_NFS4) */
#define ACE4_MASK_READ 0x00000001
#define ACE4_MASK_LIST_DIR 0x00000001
#define ACE4_MASK_WRITE 0x00000002
#define ACE4_MASK_ADD_FILE 0x00000002
#define ACE4_MASK_APPEND 0x00000004
#define ACE4_MASK_ADD_SUBDIR 0x00000004
#define ACE4_MASK_READ_NAMED 0x00000008
#define ACE4_MASK_WRITE_NAMED 0x00000010
#define ACE4_MASK_EXECUTE 0x00000020
/* The rfc doesn't provide a mask equivalent to "search" ("x" on a
* directory in posix), but it also doesn't say that its EXECUTE
* is to have this dual use (even though it does so for other dual
* use permissions such as read/list. Going to make the assumption
* here that the EXECUTE bit has this dual meaning... otherwise
* we're left with no control over search.
*/
#define ACE4_MASK_SEARCH 0x00000020
#define ACE4_MASK_DELETE_CHILD 0x00000040
#define ACE4_MASK_READ_ATTR 0x00000080
#define ACE4_MASK_WRITE_ATTR 0x00000100
#define ACE4_MASK_DELETE 0x00010000
#define ACE4_MASK_READ_ACL 0x00020000
#define ACE4_MASK_WRITE_ACL 0x00040000
#define ACE4_MASK_WRITE_OWNER 0x00080000
#define ACE4_MASK_SYNCHRONIZE 0x00100000
#define ACE4_MASK_ALL 0x001f01ff
/* Values for gpfs_uid_t (ACL_VERSION_NFS4) */
#define ACE4_SPECIAL_OWNER 1
#define ACE4_SPECIAL_GROUP 2
#define ACE4_SPECIAL_EVERYONE 3
/* per-ACL flags imported from a Windows security descriptor object */
#define ACL4_FLAG_OWNER_DEFAULTED 0x00000100
#define ACL4_FLAG_GROUP_DEFAULTED 0x00000200
#define ACL4_FLAG_DACL_PRESENT 0x00000400
#define ACL4_FLAG_DACL_DEFAULTED 0x00000800
#define ACL4_FLAG_SACL_PRESENT 0x00001000
#define ACL4_FLAG_SACL_DEFAULTED 0x00002000
#define ACL4_FLAG_DACL_UNTRUSTED 0x00004000
#define ACL4_FLAG_SERVER_SECURITY 0x00008000
#define ACL4_FLAG_DACL_AUTO_INHERIT_REQ 0x00010000
#define ACL4_FLAG_SACL_AUTO_INHERIT_REQ 0x00020000
#define ACL4_FLAG_DACL_AUTO_INHERITED 0x00040000
#define ACL4_FLAG_SACL_AUTO_INHERITED 0x00080000
#define ACL4_FLAG_DACL_PROTECTED 0x00100000
#define ACL4_FLAG_SACL_PROTECTED 0x00200000
#define ACL4_FLAG_RM_CONTROL_VALID 0x00400000
#define ACL4_FLAG_NULL_DACL 0x00800000
#define ACL4_FLAG_NULL_SACL 0x01000000
#define ACL4_FLAG_VALID_FLAGS 0x01ffff00
/* Externalized ACL defintions */
typedef unsigned int gpfs_aclType_t;
typedef unsigned int gpfs_aclLen_t;
typedef unsigned int gpfs_aclLevel_t;
typedef unsigned int gpfs_aclVersion_t;
typedef unsigned int gpfs_aclCount_t;
typedef unsigned int gpfs_aclFlag_t;
typedef unsigned int gpfs_aceType_t;
typedef unsigned int gpfs_aceFlags_t;
typedef unsigned int gpfs_acePerm_t;
typedef unsigned int gpfs_aceMask_t;
/* A POSIX ACL Entry */
typedef struct gpfs_ace_v1
{
gpfs_aceType_t ace_type; /* POSIX ACE type */
gpfs_uid_t ace_who; /* uid/gid */
gpfs_acePerm_t ace_perm; /* POSIX permissions */
} gpfs_ace_v1_t;
/* A NFSv4 ACL Entry */
typedef struct gpfs_ace_v4
{
gpfs_aceType_t aceType; /* Allow or Deny */
gpfs_aceFlags_t aceFlags; /* Inherit specifications, etc. */
gpfs_aceFlags_t aceIFlags; /* GPFS Internal flags */
gpfs_aceMask_t aceMask; /* NFSv4 mask specification */
gpfs_uid_t aceWho; /* User/Group identification */
} gpfs_ace_v4_t;
/* when GPFS_ACL_VERSION_NFS4, and GPFS_ACL_LEVEL_V4FLAGS */
typedef struct v4Level1_ext /* ACL extension */
{
gpfs_aclFlag_t acl_flags; /* per-ACL flags */
gpfs_ace_v4_t ace_v4[1];
} v4Level1_t;
/* The GPFS ACL */
typedef struct gpfs_acl
{
gpfs_aclLen_t acl_len; /* Total length of this ACL in bytes */
gpfs_aclLevel_t acl_level; /* Reserved (must be zero) */
gpfs_aclVersion_t acl_version; /* POSIX or NFS4 ACL */
gpfs_aclType_t acl_type; /* Access, Default, or NFS4 */
gpfs_aclCount_t acl_nace; /* Number of Entries that follow */
union
{
gpfs_ace_v1_t ace_v1[1]; /* when GPFS_ACL_VERSION_POSIX */
gpfs_ace_v4_t ace_v4[1]; /* when GPFS_ACL_VERSION_NFS4 */
v4Level1_t v4Level1; /* when GPFS_ACL_LEVEL_V4FLAGS */
};
} gpfs_acl_t;
/* NAME: gpfs_getacl()
*
* FUNCTION: Retrieves the ACL information for a file.
*
* The aclP parameter must point to a buffer mapped by either:
* - gpfs_opaque_acl_t (when flags are zero). In this case,
* the opaque data that is intended to be used by a backup
* program (restoreed by passing this data back on a subsequent
* call to gpfs_putacl).
* - gpfs_acl_t (when GPFS_GETACL_STRUCT is specified). In this
* case, the data can be interpreted by the calling application
* (and may be modified and applied to the file by passing it
* to gpfs_putacl...along with the GPFS_PUTACL_STRUCT flag).
*
* On input, the first four bytes of the buffer must contain its
* total size.
*
* Returns: 0 Successful
* -1 Failure
*
* Errno: ENOSYS function not available
* ENOSPC buffer too small to return the entire ACL.
* Needed size is returned in the first four
* bytes of the buffer pointed to by aclP.
* EINVAL Invalid arguments
* ENOTDIR Not on directory
* ENOMEM Out of memory
*/
int GPFS_API
gpfs_getacl(const char *pathname,
int flags,
void *acl);
/* NAME: gpfs_putacl()
*
* FUNCTION: Sets the ACL information for a file.
* The buffer passed in should contain the ACL data
* that was obtained by a previous call to gpfs_getacl.
*
* Returns: 0 Successful
* -1 Failure
*
* Errno: ENOSYS function not available
* EINVAL Invalid arguments
* ENOTDIR Not on directory
* ENOMEM Out of memory
*/
int GPFS_API
gpfs_putacl(const char *pathname,
int flags,
void *acl);
/* NAME: gpfs_prealloc()
* FUNCTION: Preallocate disk storage for the file handle that has
* already been opened for writing, starting at the specified
* starting offset and covering at least the number of bytes
* requested. Allocations are rounded to block boundaries
* (block size can be found using fstat() in st_blksize.)
* Any existing data already in the file will not be modified.
* Any read of the preallocated blocks will return zeros.
*
* Returns: 0 Successful
* -1 Failure
*
* Errno: ENOSYS No prealloc service available
* EBADF Bad file desc
* EINVAL Not a GPFS file
* EINVAL Not a regular file
* EINVAL StartOffset or BytesToPrealloc < 0
* EACCES File not opened for writing
* EDQUOT Quota exceeded
* ENOSPC Not enough space on disk
* EPERM File is in a snapshot
*/
int GPFS_API
gpfs_prealloc(gpfs_file_t fileDesc,
gpfs_off64_t startOffset,
gpfs_off64_t bytesToPrealloc);
typedef struct gpfs_winattr
{
gpfs_timestruc_t creationTime;
unsigned int winAttrs; /* values as defined below */
} gpfs_winattr_t;
/* winAttrs values */
#define GPFS_WINATTR_ARCHIVE 0x0001
#define GPFS_WINATTR_COMPRESSED 0x0002
#define GPFS_WINATTR_DEVICE 0x0004
#define GPFS_WINATTR_DIRECTORY 0x0008
#define GPFS_WINATTR_ENCRYPTED 0x0010
#define GPFS_WINATTR_HIDDEN 0x0020
#define GPFS_WINATTR_NORMAL 0x0040
#define GPFS_WINATTR_NOT_CONTENT_INDEXED 0x0080
#define GPFS_WINATTR_OFFLINE 0x0100
#define GPFS_WINATTR_READONLY 0x0200
#define GPFS_WINATTR_REPARSE_POINT 0x0400
#define GPFS_WINATTR_SPARSE_FILE 0x0800
#define GPFS_WINATTR_SYSTEM 0x1000
#define GPFS_WINATTR_TEMPORARY 0x2000
#define GPFS_WINATTR_HAS_STREAMS 0x4000
/* NAME: gpfs_get_winattrs()
* gpfs_get_winattrs_path()
*
* FUNCTION: Returns gpfs_winattr_t attributes
*
* Returns: 0 Success
* -1 Failure
*
* Errno: ENOENT file not found
* EBADF Bad file handle, not a GPFS file
* ENOMEM Memory allocation failed
* EACCESS Permission denied
* EFAULT Bad address provided
* EINVAL Not a regular file
* ENOSYS function not available
*/
int GPFS_API
gpfs_get_winattrs(gpfs_file_t fileDesc, gpfs_winattr_t *attrP);
int GPFS_API
gpfs_get_winattrs_path(const char *pathname, gpfs_winattr_t *attrP);
/* NAME: gpfs_set_winattrs()
* gpfs_set_winattrs_path()
*
* FUNCTION: Sets gpfs_winattr_t attributes (as specified by
* the flags).
*
* Returns: 0 Success
* -1 Failure
*
* Errno: ENOENT file not found
* EBADF Bad file handle, not a GPFS file
* ENOMEM Memory allocation failed
* EACCESS Permission denied
* EFAULT Bad address provided
* EINVAL Not a regular file
* ENOSYS function not available
*/
int GPFS_API
gpfs_set_winattrs(gpfs_file_t fileDesc, int flags, gpfs_winattr_t *attrP);
int GPFS_API
gpfs_set_winattrs_path(const char *pathname, int flags, gpfs_winattr_t *attrP);
/* gpfs_set_winattr flag values */
#define GPFS_WINATTR_SET_CREATION_TIME 0x08
#define GPFS_WINATTR_SET_ATTRS 0x10
/*
* NAME: gpfs_set_times(), gpfs_set_times_path()
*
* FUNCTION: Sets sets file access time, modefied time, change time,
* and/or creation time (as specified by the flags).
*
* Input: flagsfileDesc : file descriptor of the object to set
* pathname : path to a file or directory
* flag : define time value to set
* GPFS_SET_ATIME - set access time
* GPFS_SET_MTIME - set mod. time
* GPFS_SET_CTIME - set change time
* GPFS_SET_CREATION_TIME - set creation time
* times : array to times
*
* Returns: 0 Successful
* -1 Failure
*
* Errno: ENOSYS function not available
* EBADF Not a GPFS File
* EINVAL invalid argument
* EACCES Permission denied
* EROFS Filesystem is read only
* ENOENT No such file or directory
*/
typedef gpfs_timestruc_t gpfs_times_vector_t[4];
int GPFS_API
gpfs_set_times(gpfs_file_t fileDesc, int flags, gpfs_times_vector_t times);
int GPFS_API
gpfs_set_times_path(char *pathname, int flags, gpfs_times_vector_t times);
/* gpfs_set_times flag values */
#define GPFS_SET_ATIME 0x01
#define GPFS_SET_MTIME 0x02
#define GPFS_SET_CTIME 0x04
#define GPFS_SET_CREATION_TIME 0x08
/* NAME: gpfs_set_share()
*
* FUNCTION: Acquire shares
*
* Input: fileDesc : file descriptor
* allow : share type being requested
* GPFS_SHARE_NONE, GPFS_SHARE_READ,
* GPFS_SHARE_WRITE, GPFS_SHARE_BOTH
* deny : share type to deny to others
* GPFS_DENY_NONE, GPFS_DENY_READ,
* GPFS_DENY_WRITE, GPFS_DENY_BOTH
*
* Returns: 0 Success
* -1 Failure
*
* Errno: EBADF Bad file handle
* EINVAL Bad argument given
* EFAULT Bad address provided
* ENOMEM Memory allocation failed
* EACCES share mode not available
* ENOSYS function not available
*/
/* allow/deny specifications */
#define GPFS_SHARE_NONE 0
#define GPFS_SHARE_READ 1
#define GPFS_SHARE_WRITE 2
#define GPFS_SHARE_BOTH 3
#define GPFS_SHARE_ALL 3
#define GPFS_DENY_NONE 0
#define GPFS_DENY_READ 1
#define GPFS_DENY_WRITE 2
#define GPFS_DENY_BOTH 3
#define GPFS_DENY_DELETE 4
#define GPFS_DENY_ALL 7
int GPFS_API
gpfs_set_share(gpfs_file_t fileDesc,
unsigned int share,
unsigned int deny);
/* NAME: gpfs_set_lease()
*
* FUNCTION: Acquire leases for Samba
*
* Input: fileDesc : file descriptor
* leaseType : lease type being requested
* GPFS_LEASE_NONE GPFS_LEASE_READ,
* GPFS_LEASE_WRITE
*
* Returns: 0 Success
* -1 Failure
*
* Errno: EBADF Bad file handle
* EINVAL Bad argument given
* EFAULT Bad address provided
* ENOMEM Memory allocation failed
* EAGAIN lease not available
* EACCES permission denied
* EOPNOTSUPP unsupported leaseType
* ESTALE unmounted filesystem
* ENOSYS function not available
*/
/* leaseType specifications */
#define GPFS_LEASE_NONE 0
#define GPFS_LEASE_READ 1
#define GPFS_LEASE_WRITE 2
int GPFS_API
gpfs_set_lease(gpfs_file_t fileDesc,
unsigned int leaseType);
/* NAME: gpfs_get_lease()
*
* FUNCTION: Returns the type of lease currently held
*
* Returns: GPFS_LEASE_READ
* GPFS_LEASE_WRITE
* GPFS_LEASE_NONE
*
* Returns: 0 Success
* -1 Failure
*
* Errno: EINVAL
*/
int GPFS_API
gpfs_get_lease(gpfs_file_t fileDesc);
/* NAME: gpfs_get_realfilename(), gpfs_get_realfilename_path()
*
* FUNCTION: Interface to get real name of a file.
*
* INPUT: File descriptor, pathname, buffer, bufferlength
* OUTPUT: Real file name stored in filesystem
*
* Returns: 0 Success
* -1 Failure
*
* Errno: EBADF Bad file handle
* EINVAL Not a regular file
* EFAULT Bad address provided
* ENOSPC buffer too small to return the real file name.
* Needed size is returned in buflen parameter.
* ENOENT File does not exist
* ENOMEM Memory allocation failed
* EACCESS Permission denied
* ENOSYS function not available
*/
int GPFS_API
gpfs_get_realfilename(gpfs_file_t fileDesc,
char *fileNameP,
int *buflen);
int GPFS_API
gpfs_get_realfilename_path(const char *pathname,
char *fileNameP,
int *buflen);
/* NAME: gpfs_ftruncate()
*
* FUNCTION: Interface to truncate a file.
*
* INPUT: File descriptor
* length
* Returns: 0 Successful
* -1 Failure
*
* Errno: ENOSYS function not available
* EBADF Bad file handle
* EBADF Not a GPFS file
* EINVAL Not a regular file
* ENOENT File does not exist
* ENOMEM Memory allocation failed
* EINVAL length < 0
* EACCESS Permission denied
*/
int GPFS_API
gpfs_ftruncate(gpfs_file_t fileDesc, gpfs_off64_t length);
#define GPFS_WIN_CIFS_REGISTERED 0x02000000
typedef struct cifsThreadData_t
{
unsigned int dataLength; /* Total buffer length */
unsigned int share; /* gpfs_set_share declaration */
unsigned int deny; /* gpfs_set_share specification */
unsigned int lease; /* gpfs_set_lease lease type */
unsigned int secInfoFlags; /* Future use. Must be zero */
gpfs_uid_t sdUID; /* Owning user */
gpfs_uid_t sdGID; /* Owning group */
int shareLocked_fd; /* file descriptor with share locks */
unsigned int aclLength ; /* Length of the following ACL */
gpfs_acl_t acl; /* The initial ACL for create/mkdir */
} cifsThreadData_t;
/* NAME: gpfs_register_cifs_export()
*
* FUNCTION: Register a CIFS export process.
*
* INPUT: implicit use of the process ids
*
* Returns: 0 Successful
* ENOSYS function not available
* EACCES cannot establish credentials
* ENOMEM temporary shortage of memory
* EINVAL prior process/thread registrations exist
* EBADF unable to allocate a file descriptor
*/
int GPFS_API
gpfs_register_cifs_export(void);
/* NAME: gpfs_unregister_cifs_export()
*
* FUNCTION: remove a registration for a CIFS export
*
* INPUT: implicit use of the process ids
*
* Returns: 0 Successful
* ENOSYS function not available
* EACCES cannot establish credentials
* ENOMEM temporary shortage of memory
*/
int GPFS_API
gpfs_unregister_cifs_export(void);
/* NAME: gpfs_register_cifs_buffer()
*
* FUNCTION: Register a CIFS thread/buffer combination
*
* INPUT: implicit use of the process and thread ids
* Address of a cifsThreadData_t structure that will include
* a GPFS ACL (GPFS_ACL_VERSION_NFS4/GPFS_ACL_LEVEL_V4FLAGS)
* that can be applied at file/dir creation.
*
* Returns: 0 Successful
* ENOSYS function not available
* EACCES cannot establish credentials
* ENOMEM unable to allocate required memory
* EINVAL no associated process registrion exists
* bad dataLength in buffer.
*/
int GPFS_API
gpfs_register_cifs_buffer(cifsThreadData_t *bufP);
/* NAME: gpfs_unregister_cifs_buffer()
*
* FUNCTION: remove a CIFS thread/buffer registration
*
* INPUT: implicit use of the process and thread ids
*
* Returns: 0 Successful
* ENOSYS function not available
* EACCES cannot establish credentials
* ENOMEM unable to allocate required memory
* EINVAL no associated process registrion exists
*/
int GPFS_API
gpfs_unregister_cifs_buffer(void);
/* NAME: gpfs_lib_init()
*
* FUNCTION: Open GPFS main module device file
*
* INPUT: Flags
* Returns: 0 Successful
* -1 Failure
*
* Errno: ENOSYS Function not available
*/
int GPFS_API
gpfs_lib_init(int flags);
/* NAME: gpfs_lib_term()
*
* FUNCTION: Close GPFS main module device file
*
* INPUT: Flags
* Returns: 0 Successful
* -1 Failure
*
* Errno: ENOSYS Function not available
*/
int GPFS_API
gpfs_lib_term(int flags);
/* Define maximum length of the name for a GPFS named object, such
as a snapshot, storage pool or fileset. The name is a null-terminated
character string, which is not include in the max length */
#define GPFS_MAXNAMLEN 255
/* Define maximum length of the path to a GPFS named object
such as a snapshot or fileset. If the absolute path name exceeds
this limit, then use a relative path name. The path is a null-terminated
character string, which is not included in the max length */
#define GPFS_MAXPATHLEN 1023
/* ASCII code for "GPFS" in the struct statfs f_type field */
#define GPFS_SUPER_MAGIC 0x47504653
/* GPFS inode attributes
gpfs_uid_t - defined above
gpfs_uid64_t - defined above
gpfs_off64_t - defined above */
typedef unsigned int gpfs_mode_t;
typedef unsigned int gpfs_gid_t;
typedef unsigned long long gpfs_gid64_t;
typedef unsigned int gpfs_ino_t;
typedef unsigned long long gpfs_ino64_t;
typedef unsigned int gpfs_gen_t;
typedef unsigned long long gpfs_gen64_t;
typedef unsigned int gpfs_dev_t;
typedef unsigned int gpfs_mask_t;
typedef unsigned int gpfs_pool_t;
typedef unsigned int gpfs_snapid_t;
typedef unsigned long long gpfs_snapid64_t;
typedef unsigned long long gpfs_fsid64_t[2];
typedef short gpfs_nlink_t;
typedef long long gpfs_nlink64_t;
#if defined(WIN32) || defined(_MS_SUA_)
typedef struct gpfs_stat64
{
gpfs_dev_t st_dev; /* id of device containing file */
gpfs_ino64_t st_ino; /* file inode number */
gpfs_mode_t st_mode; /* access mode */
gpfs_nlink64_t st_nlink; /* number of links */
unsigned int st_flags; /* flag word */
gpfs_uid64_t st_uid; /* owner uid */
gpfs_gid64_t st_gid; /* owner gid */
gpfs_dev_t st_rdev; /* device id (if special file) */
gpfs_off64_t st_size; /* file size in bytes */
gpfs_timestruc64_t st_atime; /* time of last access */
gpfs_timestruc64_t st_mtime; /* time of last data modification */
gpfs_timestruc64_t st_ctime; /* time of last status change */
int st_blksize; /* preferred block size for io */
gpfs_off64_t st_blocks; /* 512 byte blocks of disk held by file */
long long st_fsid; /* file system id */
unsigned int st_type; /* file type */
gpfs_gen64_t st_gen; /* inode generation number */
gpfs_timestruc64_t st_createtime; /* time of creation */
unsigned int st_attrs; /* Windows flags */
} gpfs_stat64_t;
#else
typedef struct stat64 gpfs_stat64_t;
#endif
#if defined(WIN32) || defined(_MS_SUA_)
typedef struct gpfs_statfs64
{
gpfs_off64_t f_blocks; /* total data blocks in file system */
gpfs_off64_t f_bfree; /* free block in fs */
gpfs_off64_t f_bavail; /* free blocks avail to non-superuser */
int f_bsize; /* optimal file system block size */
gpfs_ino64_t f_files; /* total file nodes in file system */
gpfs_ino64_t f_ffree; /* free file nodes in fs */
gpfs_fsid64_t f_fsid; /* file system id */
int f_fsize; /* fundamental file system block size */
int f_sector_size; /* logical disk sector size */
char f_fname[32]; /* file system name (usually mount pt.) */
char f_fpack[32]; /* file system pack name */
int f_name_max; /* maximum component name length for posix */
} gpfs_statfs64_t;
#else
typedef struct statfs64 gpfs_statfs64_t;
#endif
/* Declarations for backwards compatibility. */
typedef gpfs_stat64_t stat64_t;
typedef gpfs_statfs64_t statfs64_t;
/* Define a version number for the directory entry data to allow
future changes in this structure. Careful callers should also use
the d_reclen field for the size of the structure rather than sizeof,
to allow some degree of forward compatibility */
#define GPFS_D_VERSION 1
typedef struct gpfs_direntx
{
int d_version; /* this struct's version */
unsigned short d_reclen; /* actual size of this struct including
null terminated variable length d_name */
unsigned short d_type; /* Types are defined below */
gpfs_ino_t d_ino; /* File inode number */
gpfs_gen_t d_gen; /* Generation number for the inode */
char d_name[256]; /* null terminated variable length name */
} gpfs_direntx_t;
#define GPFS_D64_VERSION 2
typedef struct gpfs_direntx64
{
int d_version; /* this struct's version */
unsigned short d_reclen; /* actual size of this struct including
null terminated variable length d_name */
unsigned short d_type; /* Types are defined below */
gpfs_ino64_t d_ino; /* File inode number */
gpfs_gen64_t d_gen; /* Generation number for the inode */
unsigned int d_flags; /* Flags are defined below */
char d_name[1028]; /* null terminated variable length name */
/* (1020+null+7 byte pad to double word) */
/* to handle up to 255 UTF-8 chars */
} gpfs_direntx64_t;
/* File types for d_type field in gpfs_direntx_t */
#define GPFS_DE_OTHER 0
#define GPFS_DE_DIR 4
#define GPFS_DE_REG 8
#define GPFS_DE_LNK 10
#define GPFS_DE_DEL 16
/* Define flags for gpfs_direntx64_t */
#define GPFS_DEFLAG_NONE 0x0000 /* Default value, no flags set */
#define GPFS_DEFLAG_JUNCTION 0x0001 /* DirEnt is a fileset junction */
#define GPFS_DEFLAG_IJUNCTION 0x0002 /* DirEnt is a inode space junction */
#define GPFS_DEFLAG_ORPHAN 0x0004 /* DirEnt is an orphan (pcache) */
/* Define a version number for the iattr data to allow future changes
in this structure. Careful callers should also use the ia_reclen field
for the size of the structure rather than sizeof, to allow some degree
of forward compatibility */
#define GPFS_IA_VERSION 1
#define GPFS_IA64_VERSION 3 /* ver 3 adds ia_repl_xxxx bytes instead of ia_pad2 */
#define GPFS_IA64_RESERVED 4
#define GPFS_IA64_UNUSED 10
typedef struct gpfs_iattr
{
int ia_version; /* this struct version */
int ia_reclen; /* sizeof this structure */
int ia_checksum; /* validity check on iattr struct */
gpfs_mode_t ia_mode; /* access mode */
gpfs_uid_t ia_uid; /* owner uid */
gpfs_gid_t ia_gid; /* owner gid */
gpfs_ino_t ia_inode; /* file inode number */
gpfs_gen_t ia_gen; /* inode generation number */
gpfs_nlink_t ia_nlink; /* number of links */
short ia_flags; /* Flags (defined below) */
int ia_blocksize; /* preferred block size for io */
gpfs_mask_t ia_mask; /* Initial attribute mask (not used) */
unsigned int ia_pad1; /* reserved space */
gpfs_off64_t ia_size; /* file size in bytes */
gpfs_off64_t ia_blocks; /* 512 byte blocks of disk held by file */
gpfs_timestruc_t ia_atime; /* time of last access */
gpfs_timestruc_t ia_mtime; /* time of last data modification */
gpfs_timestruc_t ia_ctime; /* time of last status change */
gpfs_dev_t ia_rdev; /* id of device */
unsigned int ia_xperm; /* extended attributes (defined below) */
unsigned int ia_modsnapid; /* snapshot id of last modification */
unsigned int ia_filesetid; /* fileset ID */
unsigned int ia_datapoolid; /* storage pool ID for data */
unsigned int ia_pad2; /* reserved space */
} gpfs_iattr_t;
typedef struct gpfs_iattr64
{
int ia_version; /* this struct version */
int ia_reclen; /* sizeof this structure */
int ia_checksum; /* validity check on iattr struct */
gpfs_mode_t ia_mode; /* access mode */
gpfs_uid64_t ia_uid; /* owner uid */
gpfs_gid64_t ia_gid; /* owner gid */
gpfs_ino64_t ia_inode; /* file inode number */
gpfs_gen64_t ia_gen; /* inode generation number */
gpfs_nlink64_t ia_nlink; /* number of links */
gpfs_off64_t ia_size; /* file size in bytes */
gpfs_off64_t ia_blocks; /* 512 byte blocks of disk held by file */
gpfs_timestruc64_t ia_atime; /* time of last access */
unsigned int ia_winflags; /* window's flags (defined below) */
unsigned int ia_pad1; /* reserved space */
gpfs_timestruc64_t ia_mtime; /* time of last data modification */
unsigned int ia_flags; /* flags (defined below) */
/* next four bytes were ia_pad2 */
unsigned char ia_repl_data; /* data replication factor */
unsigned char ia_repl_data_max; /* data replication max factor */
unsigned char ia_repl_meta; /* meta data replication factor */
unsigned char ia_repl_meta_max; /* meta data replication max factor */
gpfs_timestruc64_t ia_ctime; /* time of last status change */
int ia_blocksize; /* preferred block size for io */
unsigned int ia_pad3; /* reserved space */
gpfs_timestruc64_t ia_createtime; /* creation time */
gpfs_mask_t ia_mask; /* initial attribute mask (not used) */
int ia_pad4; /* reserved space */
unsigned int ia_reserved[GPFS_IA64_RESERVED]; /* reserved space */
unsigned int ia_xperm; /* extended attributes (defined below) */
gpfs_dev_t ia_dev; /* id of device containing file */
gpfs_dev_t ia_rdev; /* device id (if special file) */
unsigned int ia_pcacheflags; /* pcache inode bits */
gpfs_snapid64_t ia_modsnapid; /* snapshot id of last modification */
unsigned int ia_filesetid; /* fileset ID */
unsigned int ia_datapoolid; /* storage pool ID for data */
gpfs_ino64_t ia_inode_space_mask; /* inode space mask of this file system */
/* This value is saved in the iattr structure
during backup and used during restore */
unsigned int ia_unused[GPFS_IA64_UNUSED]; /* reserved space */
} gpfs_iattr64_t;
/* Define flags for inode attributes */
#define GPFS_IAFLAG_SNAPDIR 0x0001 /* (obsolete) */
#define GPFS_IAFLAG_USRQUOTA 0x0002 /* inode is a user quota file */
#define GPFS_IAFLAG_GRPQUOTA 0x0004 /* inode is a group quota file */
#define GPFS_IAFLAG_ERROR 0x0008 /* error reading inode */
/* Define flags for inode replication attributes */
#define GPFS_IAFLAG_FILESET_ROOT 0x0010 /* root dir of a fileset */
#define GPFS_IAFLAG_NO_SNAP_RESTORE 0x0020 /* don't restore from snapshots */
#define GPFS_IAFLAG_FILESETQUOTA 0x0040 /* inode is a fileset quota file */
#define GPFS_IAFLAG_COMANAGED 0x0080 /* file data is co-managed */
#define GPFS_IAFLAG_ILLPLACED 0x0100 /* may not be properly placed */
#define GPFS_IAFLAG_REPLMETA 0x0200 /* metadata replication set */
#define GPFS_IAFLAG_REPLDATA 0x0400 /* data replication set */
#define GPFS_IAFLAG_EXPOSED 0x0800 /* may have data on suspended disks */
#define GPFS_IAFLAG_ILLREPLICATED 0x1000 /* may not be properly replicated */
#define GPFS_IAFLAG_UNBALANCED 0x2000 /* may not be properly balanced */
#define GPFS_IAFLAG_DATAUPDATEMISS 0x4000 /* has stale data blocks on
unavailable disk */
#define GPFS_IAFLAG_METAUPDATEMISS 0x8000 /* has stale metadata on
unavailable disk */
#define GPFS_IAFLAG_IMMUTABLE 0x00010000 /* Immutability */
#define GPFS_IAFLAG_INDEFRETENT 0x00020000 /* Indefinite retention */
#define GPFS_IAFLAG_SECUREDELETE 0x00040000 /* Secure deletion */
#define GPFS_IAFLAG_TRUNCMANAGED 0x00080000 /* dmapi truncate event enabled */
#define GPFS_IAFLAG_READMANAGED 0x00100000 /* dmapi read event enabled */
#define GPFS_IAFLAG_WRITEMANAGED 0x00200000 /* dmapi write event enabled */
#define GPFS_IAFLAG_APPENDONLY 0x00400000 /* AppendOnly only */
#define GPFS_IAFLAG_DELETED 0x00800000 /* inode has been deleted */
/* Define flags for window's attributes */
#define GPFS_IWINFLAG_ARCHIVE 0x0001 /* Archive */
#define GPFS_IWINFLAG_HIDDEN 0x0002 /* Hidden */
#define GPFS_IWINFLAG_NOTINDEXED 0x0004 /* Not content indexed */
#define GPFS_IWINFLAG_OFFLINE 0x0008 /* Off-line */
#define GPFS_IWINFLAG_READONLY 0x0010 /* Read-only */