Exemplo n.º 1
0
int getdents64(int fd, struct dirent64 *external, unsigned int count)
{
        check_init("getdents64");
	if (smbw_fd(fd)) {
                int i;
                struct SMBW_dirent *internal;
                int ret;
                int n;
                
                /*
                 * LIMITATION: If they pass a count which is not a multiple of
                 * the size of struct dirent, they will not get a partial
                 * structure; we ignore the excess count.
                 */
                n = (count / sizeof(struct dirent64));
                
                internal = malloc(sizeof(struct SMBW_dirent) * n);
                if (internal == NULL) {
                        errno = ENOMEM;
                        return -1;
                }
		ret = smbw_getdents(fd, internal, count);
                if (ret <= 0)
                        return ret;
                
                ret = sizeof(struct dirent) * count;
                
                for (i = 0; count; i++, count--)
                        dirent64_convert(&internal[i], &external[i]);
                
                return ret;
	}
        
        return (* smbw_libc.getdents64)(fd, external, count);
}
Exemplo n.º 2
0
int getdents(int fd, void *dirp, unsigned int count)
{
    if (smbw_fd(fd)) {
        return smbw_getdents(fd, dirp, count);
    }

    return real_getdents(fd, dirp, count);
}
Exemplo n.º 3
0
static int getdentsx(int fd, struct dirent *external, unsigned int count, int (* f)(int, struct dirent *, unsigned int))
{
	if (smbw_fd(fd)) {
                int i;
                int internal_count;
                struct SMBW_dirent *internal;
                int ret;
                int n;
                
                /*
                 * LIMITATION: If they pass a count which is not a multiple of
                 * the size of struct dirent, they will not get a partial
                 * structure; we ignore the excess count.
                 */
                n = (count / sizeof(struct dirent));
                
                internal_count = sizeof(struct SMBW_dirent) * n;
                internal = malloc(internal_count);
                if (internal == NULL) {
                        errno = ENOMEM;
                        return -1;
                }
		ret = smbw_getdents(fd, internal, internal_count);
                if (ret <= 0)
                        return ret;
                
                ret = sizeof(struct dirent) * n;
                
                for (i = 0; i < n; i++)
                        dirent_convert(&internal[i], &external[i]);
                
                return ret;
	}
        
        return (* f)(fd, external, count);
}