Link Here
|
1 |
From 6aaeefab2490d56743ec49d0e20d3fd6ff45fb55 Mon Sep 17 00:00:00 2001 |
2 |
From: Roman Bogorodskiy <bogorodskiy@gmail.com> |
3 |
Date: Sat, 9 Sep 2017 18:27:15 +0400 |
4 |
Subject: [PATCH v2] ino64 support |
5 |
|
6 |
--- |
7 |
coregrind/m_syswrap/priv_syswrap-freebsd.h | 4 ++ |
8 |
coregrind/m_syswrap/syswrap-freebsd.c | 65 ++++++++++++++++++++++ |
9 |
include/vki/vki-freebsd.h | 54 ++++++++++++++++++ |
10 |
include/vki/vki-scnums-freebsd.h | 4 ++ |
11 |
4 files changed, 127 insertions(+) |
12 |
|
13 |
diff --git a/coregrind/m_syswrap/priv_syswrap-freebsd.h b/coregrind/m_syswrap/priv_syswrap-freebsd.h |
14 |
index 63d122f..715ad48 100644 |
15 |
--- a/coregrind/m_syswrap/priv_syswrap-freebsd.h |
16 |
+++ b/coregrind/m_syswrap/priv_syswrap-freebsd.h |
17 |
@@ -97,10 +97,12 @@ DECL_TEMPLATE(freebsd, sys_setegid); |
18 |
DECL_TEMPLATE(freebsd, sys_seteuid); |
19 |
DECL_TEMPLATE(freebsd, sys_stat); |
20 |
DECL_TEMPLATE(freebsd, sys_fstat); |
21 |
+DECL_TEMPLATE(freebsd, sys_fstat64); |
22 |
DECL_TEMPLATE(freebsd, sys_lstat); |
23 |
DECL_TEMPLATE(freebsd, sys_pathconf); |
24 |
DECL_TEMPLATE(freebsd, sys_fpathconf); |
25 |
DECL_TEMPLATE(freebsd, sys_getdirentries); |
26 |
+DECL_TEMPLATE(freebsd, sys_getdirentries64); |
27 |
DECL_TEMPLATE(freebsd, sys_mmap); |
28 |
DECL_TEMPLATE(freebsd, sys___syscall); |
29 |
DECL_TEMPLATE(freebsd, sys_lseek); |
30 |
@@ -208,6 +210,7 @@ DECL_TEMPLATE(freebsd, sys_kevent); |
31 |
DECL_TEMPLATE(freebsd, sys_sendfile); |
32 |
DECL_TEMPLATE(freebsd, sys_statfs6); |
33 |
DECL_TEMPLATE(freebsd, sys_fstatfs6); |
34 |
+DECL_TEMPLATE(freebsd, sys_fstatfs64); |
35 |
DECL_TEMPLATE(freebsd, sys_fhstatfs6); |
36 |
DECL_TEMPLATE(freebsd, sys_thr_exit); |
37 |
DECL_TEMPLATE(freebsd, sys_thr_self); |
38 |
@@ -251,6 +254,7 @@ DECL_TEMPLATE(freebsd, sys_fchmodat); |
39 |
DECL_TEMPLATE(freebsd, sys_fchownat); |
40 |
DECL_TEMPLATE(freebsd, sys_fexecve); |
41 |
DECL_TEMPLATE(freebsd, sys_fstatat); |
42 |
+DECL_TEMPLATE(freebsd, sys_fstatat64); |
43 |
DECL_TEMPLATE(freebsd, sys_futimesat); |
44 |
DECL_TEMPLATE(freebsd, sys_linkat); |
45 |
DECL_TEMPLATE(freebsd, sys_mkdirat); |
46 |
diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c |
47 |
index bf6b1f1..978e98e 100644 |
48 |
--- a/coregrind/m_syswrap/syswrap-freebsd.c |
49 |
+++ b/coregrind/m_syswrap/syswrap-freebsd.c |
50 |
@@ -885,6 +885,18 @@ POST(sys_fstat) |
51 |
POST_MEM_WRITE( ARG2, sizeof(struct vki_stat) ); |
52 |
} |
53 |
|
54 |
+PRE(sys_fstat64) |
55 |
+{ |
56 |
+ PRINT("sys_fstat64 ( %ld, %#lx )", ARG1, ARG2); |
57 |
+ PRE_REG_READ2(long, "fstat", unsigned long, fd, struct stat64 *, buf); |
58 |
+ PRE_MEM_WRITE( "fstat(buf)", ARG2, sizeof(struct vki_stat64) ); |
59 |
+} |
60 |
+ |
61 |
+POST(sys_fstat64) |
62 |
+{ |
63 |
+ POST_MEM_WRITE( ARG2, sizeof(struct vki_stat64) ); |
64 |
+} |
65 |
+ |
66 |
PRE(sys_pathconf) |
67 |
{ |
68 |
PRINT("sys_pathconf ( %#lx(%s), %ld )",ARG1,(char *)ARG1,ARG2); |
69 |
@@ -1029,6 +1041,26 @@ POST(sys_getdirentries) |
70 |
} |
71 |
} |
72 |
|
73 |
+PRE(sys_getdirentries64) |
74 |
+{ |
75 |
+ *flags |= SfMayBlock; |
76 |
+ PRINT("sys_getdents ( %ld, %#lx, %ld )", ARG1,ARG2,ARG3); |
77 |
+ PRE_REG_READ3(vki_ssize_t, "getdirentries", |
78 |
+ unsigned int, fd, struct dirent *, dirp, |
79 |
+ vki_size_t, count); |
80 |
+ PRE_MEM_WRITE( "getdirentries(dirp)", ARG2, ARG3 ); |
81 |
+} |
82 |
+ |
83 |
+POST(sys_getdirentries64) |
84 |
+{ |
85 |
+ vg_assert(SUCCESS); |
86 |
+ if (RES > 0) { |
87 |
+ POST_MEM_WRITE( ARG2, RES ); |
88 |
+ if ( ARG4 != 0 ) |
89 |
+ POST_MEM_WRITE( ARG4, sizeof (vki_off_t)); |
90 |
+ } |
91 |
+} |
92 |
+ |
93 |
PRE(sys_seteuid) |
94 |
{ |
95 |
PRINT("sys_seteuid ( %ld )", ARG1); |
96 |
@@ -1251,6 +1283,19 @@ POST(sys_fstatfs6) |
97 |
POST_MEM_WRITE( ARG2, sizeof(struct vki_statfs6) ); |
98 |
} |
99 |
|
100 |
+PRE(sys_fstatfs64) |
101 |
+{ |
102 |
+ PRINT("sys_fstatfs64 ( %ld, %#lx )", ARG1, ARG2); |
103 |
+ PRE_REG_READ2(long, "fstatfs6", |
104 |
+ unsigned int, fd, struct statfs *, buf); |
105 |
+ PRE_MEM_WRITE( "fstatfs6(buf)", ARG2, sizeof(struct vki_statfs64) ); |
106 |
+} |
107 |
+ |
108 |
+POST(sys_fstatfs64) |
109 |
+{ |
110 |
+ POST_MEM_WRITE( ARG2, sizeof(struct vki_statfs64) ); |
111 |
+} |
112 |
+ |
113 |
PRE(sys_statfs6) |
114 |
{ |
115 |
PRINT("sys_statfs6 ( %#lx(%s), %#lx )",ARG1,(char *)ARG1,ARG2); |
116 |
@@ -3132,6 +3177,20 @@ POST(sys_fstatat) |
117 |
POST_MEM_WRITE( ARG3, sizeof(struct vki_stat) ); |
118 |
} |
119 |
|
120 |
+PRE(sys_fstatat64) |
121 |
+{ |
122 |
+ PRINT("sys_fstatat ( %ld, %#lx(%s), %#lx )", ARG1,ARG2,(char*)ARG2,ARG3); |
123 |
+ PRE_REG_READ3(long, "fstatat", |
124 |
+ int, dfd, char *, file_name, struct stat *, buf); |
125 |
+ PRE_MEM_RASCIIZ( "fstatat(file_name)", ARG2 ); |
126 |
+ PRE_MEM_WRITE( "fstatat(buf)", ARG3, sizeof(struct vki_stat) ); |
127 |
+} |
128 |
+ |
129 |
+POST(sys_fstatat64) |
130 |
+{ |
131 |
+ POST_MEM_WRITE( ARG3, sizeof(struct vki_stat) ); |
132 |
+} |
133 |
+ |
134 |
PRE(sys_unlinkat) |
135 |
{ |
136 |
*flags |= SfMayBlock; |
137 |
@@ -4427,6 +4486,12 @@ const SyscallTableEntry ML_(syscall_table)[] = { |
138 |
BSDXY(__NR_accept4, sys_accept4), //541 |
139 |
BSDXY(__NR_pipe2, sys_pipe2), // 542 |
140 |
|
141 |
+ // ino64 |
142 |
+ BSDXY(__NR_fstat64, sys_fstat64), // 551 |
143 |
+ BSDXY(__NR_fstatat64, sys_fstatat64), // 552 |
144 |
+ BSDXY(__NR_getdirentries64, sys_getdirentries64), // 554 |
145 |
+ GENXY(__NR_fstatfs64, sys_fstatfs), // 556 |
146 |
+ |
147 |
BSDX_(__NR_fake_sigreturn, sys_fake_sigreturn), // 1000, fake sigreturn |
148 |
|
149 |
}; |
150 |
diff --git a/include/vki/vki-freebsd.h b/include/vki/vki-freebsd.h |
151 |
index aee453e..318a207 100644 |
152 |
--- a/include/vki/vki-freebsd.h |
153 |
+++ b/include/vki/vki-freebsd.h |
154 |
@@ -367,6 +367,36 @@ struct vki_stat { |
155 |
unsigned int :(8 / 2) * (16 - (int)sizeof(struct vki_timespec)); |
156 |
}; |
157 |
|
158 |
+struct vki_stat64 { |
159 |
+ vki_uint64_t st_dev; |
160 |
+ vki_uint64_t st_ino; |
161 |
+ vki_uint64_t st_nlink; |
162 |
+ vki_mode_t st_mode; |
163 |
+ vki_int16_t st_padding0; |
164 |
+ vki_uid_t st_uid; |
165 |
+ vki_gid_t st_gid; |
166 |
+ vki_int32_t st_padding1; |
167 |
+ vki_uint64_t st_rdev; |
168 |
+#if 0 |
169 |
+ struct vki_timespec st_atimespec; |
170 |
+ struct vki_timespec st_mtimespec; |
171 |
+ struct vki_timespec st_ctimespec; |
172 |
+#else |
173 |
+ vki_time_t st_atime; |
174 |
+ long st_atime_nsec; |
175 |
+ vki_time_t st_mtime; |
176 |
+ long st_mtime_nsec; |
177 |
+ vki_time_t st_ctime; |
178 |
+ long st_ctime_nsec; |
179 |
+#endif |
180 |
+ struct vki_timespec st_birthtim; |
181 |
+ vki_off_t st_size; |
182 |
+ vki_blkcnt_t st_blocks; |
183 |
+ vki_blksize_t st_blksize; |
184 |
+ vki_fflags_t st_flags; |
185 |
+ vki_uint64_t st_gen; |
186 |
+ vki_int64_t st_spare[10]; |
187 |
+}; |
188 |
|
189 |
//---------------------------------------------------------------------- |
190 |
// From linux-2.6.8.1/include/linux/sched.h |
191 |
@@ -941,6 +971,30 @@ struct vki_statfs { |
192 |
char f_mntonname[VKI_MNAMELEN]; |
193 |
}; |
194 |
|
195 |
+struct vki_statfs64 { |
196 |
+ vki_uint32_t f_version; |
197 |
+ vki_uint32_t f_type; |
198 |
+ vki_uint64_t f_flags; |
199 |
+ vki_uint64_t f_bsize; |
200 |
+ vki_uint64_t f_iosize; |
201 |
+ vki_uint64_t f_blocks; |
202 |
+ vki_uint64_t f_bfree; |
203 |
+ vki_int64_t f_bavail; |
204 |
+ vki_uint64_t f_files; |
205 |
+ vki_int64_t f_ffree; |
206 |
+ vki_uint64_t f_syncwrites; |
207 |
+ vki_uint64_t f_asyncwrites; |
208 |
+ vki_uint64_t f_syncreads; |
209 |
+ vki_uint64_t f_asyncreads; |
210 |
+ vki_uint64_t f_spare[10]; |
211 |
+ vki_uint32_t f_namemax; |
212 |
+ vki_uid_t f_owner; |
213 |
+ vki_fsid_t f_fsid; |
214 |
+ char f_charspare[80]; |
215 |
+ char f_fstypename[VKI_MFSNAMELEN]; |
216 |
+ char f_mntfromnname[VKI_MNAMELEN]; |
217 |
+ char f_mntonname[VKI_MNAMELEN]; |
218 |
+}; |
219 |
#define MAXFIDSZ 16 |
220 |
|
221 |
struct vki_fid { |
222 |
diff --git a/include/vki/vki-scnums-freebsd.h b/include/vki/vki-scnums-freebsd.h |
223 |
index 605a42f..ffa241d 100644 |
224 |
--- a/include/vki/vki-scnums-freebsd.h |
225 |
+++ b/include/vki/vki-scnums-freebsd.h |
226 |
@@ -412,6 +412,10 @@ |
227 |
#define __NR_shmctl 512 |
228 |
#define __NR_accept4 541 |
229 |
#define __NR_pipe2 542 |
230 |
+#define __NR_fstat64 551 |
231 |
+#define __NR_fstatat64 552 |
232 |
+#define __NR_getdirentries64 554 |
233 |
+#define __NR_fstatfs64 556 |
234 |
|
235 |
#define __NR_fake_sigreturn 1000 |
236 |
|
237 |
-- |
238 |
2.14.1 |
239 |
|