4 #define D_NAME_LEN_MAX 256
9 unsigned short d_reclen;
14 print_old_dirent(struct tcb *tcp, long addr)
17 typedef struct kernel_dirent old_dirent_t;
22 unsigned short d_reclen;
28 if (umove_or_printaddr(tcp, addr, &d))
31 tprintf("{d_ino=%lu, d_off=%lu, d_reclen=%u, d_name=",
32 (unsigned long) d.d_ino, (unsigned long) d.d_off, d.d_reclen);
33 if (d.d_reclen > D_NAME_LEN_MAX)
34 d.d_reclen = D_NAME_LEN_MAX;
35 printpathn(tcp, addr + offsetof(old_dirent_t, d_name), d.d_reclen);
42 printfd(tcp, tcp->u_arg[0]);
46 printaddr(tcp->u_arg[1]);
48 print_old_dirent(tcp, tcp->u_arg[1]);
49 /* Not much point in printing this out, it is always 1. */
50 if (tcp->u_arg[2] != 1)
51 tprintf(", %lu", tcp->u_arg[2]);
56 #include "xlat/direnttypes.h"
60 unsigned int i, len, dents = 0;
64 printfd(tcp, tcp->u_arg[0]);
68 if (syserror(tcp) || !verbose(tcp)) {
69 printaddr(tcp->u_arg[1]);
70 tprintf(", %lu", tcp->u_arg[2]);
74 /* Beware of insanely large or too small values in tcp->u_rval */
75 if (tcp->u_rval > 1024*1024)
77 else if (tcp->u_rval < (int) sizeof(struct kernel_dirent))
84 if (!buf || umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
85 printaddr(tcp->u_arg[1]);
86 tprintf(", %lu", tcp->u_arg[2]);
96 for (i = 0; len && i <= len - sizeof(struct kernel_dirent); ) {
97 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
100 int oob = d->d_reclen < sizeof(struct kernel_dirent) ||
101 i + d->d_reclen - 1 >= len;
102 int d_name_len = oob ? len - i : d->d_reclen;
103 d_name_len -= offsetof(struct kernel_dirent, d_name) + 1;
104 if (d_name_len > D_NAME_LEN_MAX)
105 d_name_len = D_NAME_LEN_MAX;
107 tprintf("%s{d_ino=%lu, d_off=%lu, d_reclen=%u, d_name=",
108 i ? " " : "", d->d_ino, d->d_off, d->d_reclen);
110 if (print_quoted_string(d->d_name, d_name_len,
111 QUOTE_0_TERMINATED) > 0) {
115 tprints(", d_type=");
119 printxval(direnttypes, buf[i + d->d_reclen - 1], "DT_???");
123 if (d->d_reclen < sizeof(struct kernel_dirent)) {
124 tprints("/* d_reclen < sizeof(struct kernel_dirent) */");
132 tprintf("/* %u entries */", dents);
133 tprintf(", %lu", tcp->u_arg[2]);
140 /* the minimum size of a valid dirent64 structure */
141 const unsigned int d_name_offset = offsetof(struct dirent64, d_name);
143 unsigned int i, len, dents = 0;
147 printfd(tcp, tcp->u_arg[0]);
151 if (syserror(tcp) || !verbose(tcp)) {
152 printaddr(tcp->u_arg[1]);
153 tprintf(", %lu", tcp->u_arg[2]);
157 /* Beware of insanely large or too small tcp->u_rval */
158 if (tcp->u_rval > 1024*1024)
160 else if (tcp->u_rval < (int) d_name_offset)
167 if (!buf || umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
168 printaddr(tcp->u_arg[1]);
169 tprintf(", %lu", tcp->u_arg[2]);
179 for (i = 0; len && i <= len - d_name_offset; ) {
180 struct dirent64 *d = (struct dirent64 *) &buf[i];
183 if (d->d_reclen >= d_name_offset
184 && i + d->d_reclen <= len) {
185 d_name_len = d->d_reclen - d_name_offset;
187 d_name_len = len - i - d_name_offset;
189 if (d_name_len > D_NAME_LEN_MAX)
190 d_name_len = D_NAME_LEN_MAX;
192 tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64
193 ", d_reclen=%u, d_type=",
198 printxval(direnttypes, d->d_type, "DT_???");
200 tprints(", d_name=");
201 if (print_quoted_string(d->d_name, d_name_len,
202 QUOTE_0_TERMINATED) > 0) {
208 if (d->d_reclen < d_name_offset) {
209 tprints("/* d_reclen < offsetof(struct dirent64, d_name) */");
218 tprintf("/* %u entries */", dents);
219 tprintf(", %lu", tcp->u_arg[2]);