1 /*
2   Copyright Ⓒ 2009  Regis Duchesne
3 
4     This program is free software: you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation, either version 3 of the License, or
7     (at your option) any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 
14 */
15 
16 #ifdef __APPLE__
17 /*
18    This file is for symbols which have the "$INODE64" version, i.e. symbols
19    which use a 64-bit ino_t.
20 
21    In this file, 'struct stat' is an alias for 'struct stat64'.
22 */
23 #define _DARWIN_USE_64_BIT_INODE
24 
25 #include "config.h"
26 #include "communicate.h"
27 
28 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
29 
30 #include <stdio.h>
31 #include <spawn.h>
32 #ifdef HAVE_SYS_ACL_H
33 #include <sys/acl.h>
34 #endif /* HAVE_SYS_ACL_H */
35 #if HAVE_FTS_H
36 #include <fts.h>
37 #endif /* HAVE_FTS_H */
38 
39 #include "wrapped.h"
40 #include "wraptmpf.h"
41 #include "wrapdef.h"
42 
43 #ifdef LIBFAKEROOT_DEBUGGING
44 extern int fakeroot_debug;
45 
46 #endif /* LIBFAKEROOT_DEBUGGING */
lstat$INODE64(const char * file_name,struct stat * st)47 int lstat$INODE64(const char *file_name,
48           struct stat *st){
49 
50   int r;
51 
52 #ifdef LIBFAKEROOT_DEBUGGING
53   if (fakeroot_debug) {
54     fprintf(stderr, "lstat$INODE64 file_name %s\n", file_name);
55   }
56 #endif /* LIBFAKEROOT_DEBUGGING */
57   r=next_lstat$INODE64(file_name, st);
58 
59   if(r)
60     return -1;
61 
62   send_get_stat64((struct stat64 *)st);
63   return 0;
64 }
65 
66 
stat$INODE64(const char * file_name,struct stat * st)67 int stat$INODE64(const char *file_name,
68          struct stat *st){
69   int r;
70 
71 #ifdef LIBFAKEROOT_DEBUGGING
72   if (fakeroot_debug) {
73     fprintf(stderr, "stat$INODE64 file_name %s\n", file_name);
74   }
75 #endif /* LIBFAKEROOT_DEBUGGING */
76   r=next_stat$INODE64(file_name,st);
77   if(r)
78     return -1;
79   send_get_stat64((struct stat64 *)st);
80   return 0;
81 }
82 
83 
fstat$INODE64(int fd,struct stat * st)84 int fstat$INODE64(int fd,
85           struct stat *st){
86   int r;
87 
88 #ifdef LIBFAKEROOT_DEBUGGING
89   if (fakeroot_debug) {
90     fprintf(stderr, "fstat$INODE64 fd %d\n", fd);
91   }
92 #endif /* LIBFAKEROOT_DEBUGGING */
93   r=next_fstat$INODE64(fd, st);
94   if(r)
95     return -1;
96   send_get_stat64((struct stat64 *)st);
97 
98   return 0;
99 }
100 
101 #ifdef HAVE_FTS_READ
fts_read$INODE64(FTS * ftsp)102 FTSENT *fts_read$INODE64(FTS *ftsp) {
103   FTSENT *r;
104 
105 #ifdef LIBFAKEROOT_DEBUGGING
106   if (fakeroot_debug) {
107     fprintf(stderr, "fts_read$INODE64\n");
108   }
109 #endif /* LIBFAKEROOT_DEBUGGING */
110   r=next_fts_read$INODE64(ftsp);
111 #ifdef __APPLE__
112   if (r && ((ftsp->fts_options & FTS_NOSTAT)
113             || r->fts_info == FTS_NS || r->fts_info == FTS_NSOK))
114     r->fts_statp = NULL;  /* Otherwise fts_statp may be a random pointer */
115 #endif
116   if(r && r->fts_statp) {  /* Should we bother checking fts_info here? */
117     send_get_stat64((struct stat64 *)r->fts_statp);
118   }
119 
120   return r;
121 }
122 
fts_children$INODE64(FTS * ftsp,int options)123 FTSENT *fts_children$INODE64(FTS *ftsp,
124                      int options) {
125   FTSENT *first;
126   FTSENT *r;
127 
128 #ifdef LIBFAKEROOT_DEBUGGING
129   if (fakeroot_debug) {
130     fprintf(stderr, "fts_children$INODE64\n");
131   }
132 #endif /* LIBFAKEROOT_DEBUGGING */
133   first=next_fts_children$INODE64(ftsp, options);
134   for(r = first; r; r = r->fts_link) {
135     if(r->fts_statp) {  /* Should we bother checking fts_info here? */
136       send_get_stat64((struct stat64 *)r->fts_statp);
137     }
138   }
139 
140   return first;
141 }
142 #endif /* MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 */
143 #endif /* HAVE_FTS_READ */
144 #endif /* ifdef __APPLE__ */
145