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
|
/* Copyright (C) 1992,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifndef _SYS_STAT_H
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
#endif
#ifndef _BITS_STAT_H
#define _BITS_STAT_H
/* Versions of the `struct stat' data structure. */
#define _STAT_VER_LINUX_OLD 1
#define _STAT_VER_KERNEL 1
#define _STAT_VER_SVR4 2
#define _STAT_VER_LINUX 3
#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
/* Versions of the `xmknod' interface. */
#define _MKNOD_VER_LINUX 1
#define _MKNOD_VER_SVR4 2
#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
/* Pull in whatever this particular arch's kernel thinks that struct stat
* should look like. It turns out that each arch has a different opinion
* on the subject, and different kernel revs use different names... */
#if defined(__alpha__)
struct stat {
unsigned int st_dev;
unsigned int st_ino;
unsigned int st_mode;
unsigned int st_nlink;
unsigned int st_uid;
unsigned int st_gid;
unsigned int st_rdev;
long st_size;
unsigned long st_atime;
unsigned long st_mtime;
unsigned long st_ctime;
unsigned int st_blksize;
int st_blocks;
unsigned int st_flags;
unsigned int st_gen;
};
/* End of __alpha__ */
#elif defined(__arm__)
struct stat {
unsigned short st_dev;
unsigned short __pad1;
unsigned long st_ino;
unsigned short st_mode;
unsigned short st_nlink;
unsigned short st_uid;
unsigned short st_gid;
unsigned short st_rdev;
unsigned short __pad2;
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
unsigned long st_atime;
unsigned long __unused1;
unsigned long st_mtime;
unsigned long __unused2;
unsigned long st_ctime;
unsigned long __unused3;
unsigned long __unused4;
unsigned long __unused5;
};
#ifdef __USE_LARGEFILE64
struct stat64 {
unsigned short st_dev;
unsigned char __pad0[10];
#define STAT64_HAS_BROKEN_ST_INO 1
unsigned long __st_ino;
unsigned int st_mode;
unsigned int st_nlink;
unsigned long st_uid;
unsigned long st_gid;
unsigned short st_rdev;
unsigned char __pad3[10];
long long st_size;
unsigned long st_blksize;
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
unsigned long __pad4; /* future possible st_blocks high bits */
unsigned long st_atime;
unsigned long __pad5;
unsigned long st_mtime;
unsigned long __pad6;
unsigned long st_ctime;
unsigned long __pad7; /* will be high 32 bits of ctime someday */
unsigned long long st_ino;
};
#endif
/* End of __arm__ */
#elif defined(__cris__)
struct stat {
unsigned short st_dev;
unsigned short __pad1;
unsigned long st_ino;
unsigned short st_mode;
unsigned short st_nlink;
unsigned short st_uid;
unsigned short st_gid;
unsigned short st_rdev;
unsigned short __pad2;
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
unsigned long st_atime;
unsigned long __unused1;
unsigned long st_mtime;
unsigned long __unused2;
unsigned long st_ctime;
unsigned long __unused3;
unsigned long __unused4;
unsigned long __unused5;
};
#ifdef __USE_LARGEFILE64
struct stat64 {
unsigned short st_dev;
unsigned char __pad0[10];
#define STAT64_HAS_BROKEN_ST_INO 1
unsigned long __st_ino;
unsigned int st_mode;
unsigned int st_nlink;
unsigned long st_uid;
unsigned long st_gid;
unsigned short st_rdev;
unsigned char __pad3[10];
long long st_size;
unsigned long st_blksize;
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
unsigned long __pad4; /* future possible st_blocks high bits */
unsigned long st_atime;
unsigned long __pad5;
unsigned long st_mtime;
unsigned long __pad6;
unsigned long st_ctime;
unsigned long __pad7; /* will be high 32 bits of ctime someday */
unsigned long long st_ino;
};
#endif
/* End of __cris__ */
#elif defined(__ia64__)
struct stat {
unsigned long st_dev;
unsigned long st_ino;
unsigned long st_nlink;
unsigned int st_mode;
unsigned int st_uid;
unsigned int st_gid;
unsigned int __pad0;
unsigned long st_rdev;
unsigned long st_size;
unsigned long st_atime;
unsigned long __reserved0; /* reserved for atime.nanoseconds */
unsigned long st_mtime;
unsigned long __reserved1; /* reserved for mtime.nanoseconds */
unsigned long st_ctime;
unsigned long __reserved2; /* reserved for ctime.nanoseconds */
unsigned long st_blksize;
long st_blocks;
unsigned long __unused[3];
};
/* End of __ia64__ */
#elif defined(__mc68000__)
struct stat {
unsigned short st_dev;
unsigned short __pad1;
unsigned long st_ino;
unsigned short st_mode;
unsigned short st_nlink;
unsigned short st_uid;
unsigned short st_gid;
unsigned short st_rdev;
unsigned short __pad2;
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
unsigned long st_atime;
unsigned long __unused1;
unsigned long st_mtime;
unsigned long __unused2;
unsigned long st_ctime;
unsigned long __unused3;
unsigned long __unused4;
unsigned long __unused5;
};
#ifdef __USE_LARGEFILE64
struct stat64 {
unsigned char __pad0[6];
unsigned short st_dev;
unsigned char __pad1[2];
#define STAT64_HAS_BROKEN_ST_INO 1
unsigned long __st_ino;
unsigned int st_mode;
unsigned int st_nlink;
unsigned long st_uid;
unsigned long st_gid;
unsigned char __pad2[6];
unsigned short st_rdev;
unsigned char __pad3[2];
long long st_size;
unsigned long st_blksize;
unsigned long __pad4; /* future possible st_blocks high bits */
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
unsigned long st_atime;
unsigned long __pad5;
unsigned long st_mtime;
unsigned long __pad6;
unsigned long st_ctime;
unsigned long __pad7; /* will be high 32 bits of ctime someday */
unsigned long long st_ino;
};
#endif
/* End of __mc68000__ */
#elif defined(__mips__)
#if __WORDSIZE == 64
struct stat {
unsigned long st_dev;
unsigned long st_pad0[3]; /* Reserved for st_dev expansion */
unsigned long long st_ino;
unsigned int st_mode;
int st_nlink;
int st_uid;
int st_gid;
unsigned long st_rdev;
unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */
long long st_size;
long st_atime;
unsigned long reserved0; /* Reserved for st_atime expansion */
long st_mtime;
unsigned long reserved1; /* Reserved for st_mtime expansion */
long st_ctime;
unsigned long reserved2; /* Reserved for st_ctime expansion */
unsigned long st_blksize;
unsigned long st_pad2;
long long st_blocks;
};
#else
struct stat {
unsigned int st_dev;
long st_pad1[3]; /* Reserved for network id */
unsigned long st_ino;
unsigned int st_mode;
int st_nlink;
int st_uid;
int st_gid;
unsigned int st_rdev;
long st_pad2[2];
long st_size;
long st_pad3;
long st_atime;
long reserved0;
long st_mtime;
long reserved1;
long st_ctime;
long reserved2;
long st_blksize;
long st_blocks;
long st_pad4[14];
};
#ifdef __USE_LARGEFILE64
struct stat64 {
unsigned long st_dev;
unsigned long st_pad0[3]; /* Reserved for st_dev expansion */
unsigned long long st_ino;
unsigned int st_mode;
int st_nlink;
int st_uid;
int st_gid;
unsigned long st_rdev;
unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */
long long st_size;
long st_atime;
unsigned long reserved0; /* Reserved for st_atime expansion */
long st_mtime;
unsigned long reserved1; /* Reserved for st_mtime expansion */
long st_ctime;
unsigned long reserved2; /* Reserved for st_ctime expansion */
unsigned long st_blksize;
unsigned long st_pad2;
long long st_blocks;
};
#endif
#endif
/* End of __mips__ */
#elif defined(__powerpc__)
#if __WORDSIZE == 64
struct stat {
unsigned long long st_dev; /* Device. */
unsigned long long st_ino; /* File serial number. */
unsigned int st_mode; /* File mode. */
unsigned int st_nlink; /* Link count. */
unsigned int st_uid; /* User ID of the file's owner. */
unsigned int st_gid; /* Group ID of the file's group. */
unsigned long long st_rdev; /* Device number, if device. */
unsigned short int __pad2;
long long st_size; /* Size of file, in bytes. */
long st_blksize; /* Optimal block size for I/O. */
long long st_blocks; /* Number 512-byte blocks allocated. */
long st_atime; /* Time of last access. */
unsigned long int __unused1;
long st_mtime; /* Time of last modification. */
unsigned long int __unused2;
long st_ctime; /* Time of last status change. */
unsigned long int __unused3;
unsigned long int __unused4;
unsigned long int __unused5;
};
#else
struct stat {
unsigned int st_dev;
unsigned int st_ino;
unsigned int st_mode;
unsigned short st_nlink;
unsigned int st_uid;
unsigned int st_gid;
unsigned int st_rdev;
unsigned long int st_size;
unsigned long st_blksize;
unsigned long st_blocks;
unsigned long st_atime;
unsigned long __unused1;
unsigned long st_mtime;
unsigned long __unused2;
unsigned long st_ctime;
unsigned long __unused3;
unsigned long __unused4;
unsigned long __unused5;
};
#ifdef __USE_LARGEFILE64
struct stat64 {
unsigned long long st_dev; /* Device. */
unsigned long long st_ino; /* File serial number. */
unsigned int st_mode; /* File mode. */
unsigned int st_nlink; /* Link count. */
unsigned int st_uid; /* User ID of the file's owner. */
unsigned int st_gid; /* Group ID of the file's group. */
unsigned long long st_rdev; /* Device number, if device. */
unsigned short int __pad2;
long long st_size; /* Size of file, in bytes. */
long st_blksize; /* Optimal block size for I/O. */
long long st_blocks; /* Number 512-byte blocks allocated. */
long st_atime; /* Time of last access. */
unsigned long int __unused1;
long st_mtime; /* Time of last modification. */
unsigned long int __unused2;
long st_ctime; /* Time of last status change. */
unsigned long int __unused3;
unsigned long int __unused4;
unsigned long int __unused5;
};
#endif
#endif
/* End of __powerpc__ */
#elif defined (__s390__)
struct stat {
unsigned short st_dev;
unsigned short __pad1;
unsigned long st_ino;
unsigned short st_mode;
unsigned short st_nlink;
unsigned short st_uid;
unsigned short st_gid;
unsigned short st_rdev;
unsigned short __pad2;
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
unsigned long st_atime;
unsigned long __unused1;
unsigned long st_mtime;
unsigned long __unused2;
unsigned long st_ctime;
unsigned long __unused3;
unsigned long __unused4;
unsigned long __unused5;
};
#ifdef __USE_LARGEFILE64
struct stat64 {
unsigned char __pad0[6];
unsigned short st_dev;
unsigned int __pad1;
#define STAT64_HAS_BROKEN_ST_INO 1
unsigned long __st_ino;
unsigned int st_mode;
unsigned int st_nlink;
unsigned long st_uid;
unsigned long st_gid;
unsigned char __pad2[6];
unsigned short st_rdev;
unsigned int __pad3;
long long st_size;
unsigned long st_blksize;
unsigned char __pad4[4];
unsigned long __pad5; /* future possible st_blocks high bits */
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
unsigned long st_atime;
unsigned long __pad6;
unsigned long st_mtime;
unsigned long __pad7;
unsigned long st_ctime;
unsigned long __pad8; /* will be high 32 bits of ctime someday */
unsigned long long st_ino;
};
#endif
/* End of __s390__ */
#elif defined(__sh3__) || defined(__SH4__)
#include <endian.h>
struct stat {
unsigned short st_dev;
unsigned short __pad1;
unsigned long st_ino;
unsigned short st_mode;
unsigned short st_nlink;
unsigned short st_uid;
unsigned short st_gid;
unsigned short st_rdev;
unsigned short __pad2;
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
unsigned long st_atime;
unsigned long __unused1;
unsigned long st_mtime;
unsigned long __unused2;
unsigned long st_ctime;
unsigned long __unused3;
unsigned long __unused4;
unsigned long __unused5;
};
#ifdef __USE_LARGEFILE64
struct stat64 {
#if defined(__BIG_ENDIAN__)
unsigned char __pad0b[6];
unsigned short st_dev;
#elif defined(__LITTLE_ENDIAN__)
unsigned short st_dev;
unsigned char __pad0b[6];
#else
#error Must know endian to build stat64 structure!
#endif
unsigned char __pad0[4];
unsigned long st_ino;
unsigned int st_mode;
unsigned int st_nlink;
unsigned long st_uid;
unsigned long st_gid;
#if defined(__BIG_ENDIAN__)
unsigned char __pad3b[6];
unsigned short st_rdev;
#else /* Must be little */
unsigned short st_rdev;
unsigned char __pad3b[6];
#endif
unsigned char __pad3[4];
long long st_size;
unsigned long st_blksize;
#if defined(__BIG_ENDIAN__)
unsigned long __pad4; /* Future possible st_blocks hi bits */
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
#else /* Must be little */
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
unsigned long __pad4; /* Future possible st_blocks hi bits */
#endif
unsigned long st_atime;
unsigned long __pad5;
unsigned long st_mtime;
unsigned long __pad6;
unsigned long st_ctime;
unsigned long __pad7; /* will be high 32 bits of ctime someday */
unsigned long __unused1;
unsigned long __unused2;
};
#endif
#elif defined (__sparc__)
#if __WORDSIZE == 64
struct stat {
unsigned char __pad0[6];
unsigned short st_dev;
unsigned long long st_ino;
unsigned int st_mode;
unsigned int st_nlink;
unsigned int st_uid;
unsigned int st_gid;
unsigned char __pad2[6];
unsigned short st_rdev;
unsigned char __pad3[8];
long long st_size;
unsigned int st_blksize;
unsigned char __pad4[8];
unsigned int st_blocks;
unsigned int st_atime;
unsigned int __unused1;
unsigned int st_mtime;
unsigned int __unused2;
unsigned int st_ctime;
unsigned int __unused3;
unsigned int __unused4;
unsigned int __unused5;
};
#else
struct stat {
unsigned short st_dev;
unsigned long st_ino;
unsigned short st_mode;
short st_nlink;
unsigned short st_uid;
unsigned short st_gid;
unsigned short st_rdev;
long st_size;
long st_atime;
unsigned long __unused1;
long st_mtime;
unsigned long __unused2;
long st_ctime;
unsigned long __unused3;
long st_blksize;
long st_blocks;
unsigned long __unused4[2];
};
#ifdef __USE_LARGEFILE64
struct stat64 {
unsigned char __pad0[6];
unsigned short st_dev;
unsigned long long st_ino;
unsigned int st_mode;
unsigned int st_nlink;
unsigned int st_uid;
unsigned int st_gid;
unsigned char __pad2[6];
unsigned short st_rdev;
unsigned char __pad3[8];
long long st_size;
unsigned int st_blksize;
unsigned char __pad4[8];
unsigned int st_blocks;
unsigned int st_atime;
unsigned int __unused1;
unsigned int st_mtime;
unsigned int __unused2;
unsigned int st_ctime;
unsigned int __unused3;
unsigned int __unused4;
unsigned int __unused5;
};
#endif
#endif
/* End if __sparc__ */
#elif defined(__x86_64__)
struct stat {
unsigned long st_dev;
unsigned long st_ino;
unsigned long st_nlink;
unsigned int st_mode;
unsigned int st_uid;
unsigned int st_gid;
unsigned int __pad0;
unsigned long st_rdev;
long st_size;
long st_blksize;
long st_blocks; /* Number 512-byte blocks allocated. */
unsigned long st_atime;
unsigned long __reserved0; /* reserved for atime.nanoseconds */
unsigned long st_mtime;
unsigned long __reserved1; /* reserved for atime.nanoseconds */
unsigned long st_ctime;
unsigned long __reserved2; /* reserved for atime.nanoseconds */
long __unused[3];
};
/* End if __x86_64__ */
//#elif defined(__i386__)
#else
#if ! defined(__i386__)
#warning please verify that struct stat for your architecture exactly matches struct stat for x86
#endif
struct stat {
unsigned short st_dev;
unsigned short __pad1;
unsigned long st_ino;
unsigned short st_mode;
unsigned short st_nlink;
unsigned short st_uid;
unsigned short st_gid;
unsigned short st_rdev;
unsigned short __pad2;
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
unsigned long st_atime;
unsigned long __unused1;
unsigned long st_mtime;
unsigned long __unused2;
unsigned long st_ctime;
unsigned long __unused3;
unsigned long __unused4;
unsigned long __unused5;
};
#ifdef __USE_LARGEFILE64
struct stat64 {
unsigned short st_dev;
unsigned char __pad0[10];
#define STAT64_HAS_BROKEN_ST_INO 1
unsigned long __st_ino;
unsigned int st_mode;
unsigned int st_nlink;
unsigned long st_uid;
unsigned long st_gid;
unsigned short st_rdev;
unsigned char __pad3[10];
long long st_size;
unsigned long st_blksize;
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
unsigned long __pad4; /* future possible st_blocks high bits */
unsigned long st_atime;
unsigned long __pad5;
unsigned long st_mtime;
unsigned long __pad6;
unsigned long st_ctime;
unsigned long __pad7; /* will be high 32 bits of ctime someday */
unsigned long long st_ino;
};
#endif
/* End of __i386__ */
#endif
#ifdef __USE_LARGEFILE64
# ifdef __USE_FILE_OFFSET64
# define stat stat64
# endif
#endif
/* Tell code we have these members. */
#define _STATBUF_ST_BLKSIZE
#define _STATBUF_ST_RDEV
/* Encoding of the file mode. */
#define __S_IFMT 0170000 /* These bits determine file type. */
/* File types. */
#define __S_IFDIR 0040000 /* Directory. */
#define __S_IFCHR 0020000 /* Character device. */
#define __S_IFBLK 0060000 /* Block device. */
#define __S_IFREG 0100000 /* Regular file. */
#define __S_IFIFO 0010000 /* FIFO. */
#define __S_IFLNK 0120000 /* Symbolic link. */
#define __S_IFSOCK 0140000 /* Socket. */
/* POSIX.1b objects. Note that these macros always evaluate to zero. But
they do it by enforcing the correct use of the macros. */
#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
/* Protection bits. */
#define __S_ISUID 04000 /* Set user ID on execution. */
#define __S_ISGID 02000 /* Set group ID on execution. */
#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
#define __S_IREAD 0400 /* Read by owner. */
#define __S_IWRITE 0200 /* Write by owner. */
#define __S_IEXEC 0100 /* Execute by owner. */
#endif /* _BITS_STAT_H */
|