[Cbe-oss-dev] [PATCH 7/9] Extract the file descriptor search logic
Michael Ellerman
michael at ellerman.id.au
Fri Aug 17 17:19:15 EST 2007
Extract the logic for searching through the file descriptors for spu contexts
into a separate routine, coredump_next_context(), so we can use it elsewhere
in future.
Signed-off-by: Michael Ellerman <michael at ellerman.id.au>
---
arch/powerpc/platforms/cell/spufs/coredump.c | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/platforms/cell/spufs/coredump.c b/arch/powerpc/platforms/cell/spufs/coredump.c
index 3385515..a1e8b0f 100644
--- a/arch/powerpc/platforms/cell/spufs/coredump.c
+++ b/arch/powerpc/platforms/cell/spufs/coredump.c
@@ -126,18 +126,17 @@ static int spufs_add_one_context(struct spu_context *ctx, int dfd)
* internal functionality to dump them without needing to actually
* open the files.
*/
-static int spufs_arch_notes_size(void)
+static struct spu_context *coredump_next_context(int *fd)
{
struct fdtable *fdt = files_fdtable(current->files);
struct file *file;
- struct spu_context *ctx;
- int size = 0, rc, fd;
+ struct spu_context *ctx = NULL;
- for (fd = 0; fd < fdt->max_fds; fd++) {
- if (!FD_ISSET(fd, fdt->open_fds))
+ for (; *fd < fdt->max_fds; (*fd)++) {
+ if (!FD_ISSET(*fd, fdt->open_fds))
continue;
- file = fcheck(fd);
+ file = fcheck(*fd);
if (!file || file->f_op != &spufs_context_fops)
continue;
@@ -146,6 +145,21 @@ static int spufs_arch_notes_size(void)
if (ctx->flags & SPU_CREATE_NOSCHED)
continue;
+ /* start searching the next fd next time we're called */
+ (*fd)++;
+ break;
+ }
+
+ return ctx;
+}
+
+static int spufs_arch_notes_size(void)
+{
+ struct spu_context *ctx;
+ int size = 0, rc, fd;
+
+ fd = 0;
+ while ((ctx = coredump_next_context(&fd)) != NULL) {
rc = spufs_add_one_context(ctx, fd);
if (rc < 0)
break;
--
1.5.1.3.g7a33b
More information about the cbe-oss-dev
mailing list