/* This function iterates over all open file descriptors and sees if they are a directory in spufs. In that case we use spufs internal functionality to dump them without needing to actually open the files.  */
static struct spu_context* coredump_next_context(int *fd)
/* This function iterates over all open file descriptors and sees if they are a directory in spufs. In that case we use spufs internal functionality to dump them without needing to actually open the files.  */
static struct spu_context* coredump_next_context(int *fd)
{
	struct fdtable *fdt = files_fdtable(current->files);
	struct file *file;
	struct spu_context *ctx = NULL;
	for (; *fd < fdt->max_fds; (*fd)++) {
		if (!FD_ISSET(*fd, fdt->open_fds))
			continue;
		file = fcheck(*fd);
		if (!file || file->f_op != &spufs_context_fops)
			continue;
		ctx = SPUFS_I(file->f_dentry->d_inode)->i_ctx;
		if (ctx->flags & SPU_CREATE_NOSCHED)
			continue;
		break;
	}
	return ctx;
}