[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4947FBC8.2000601@google.com>
Date: Tue, 16 Dec 2008 11:04:40 -0800
From: Mike Waychison <mikew@...gle.com>
To: Oren Laadan <orenl@...columbia.edu>
CC: jeremy@...p.org, arnd@...db.de, linux-api@...r.kernel.org,
containers@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org,
Dave Hansen <dave@...ux.vnet.ibm.com>, linux-mm@...ck.org,
Linux Torvalds <torvalds@...l.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
"H. Peter Anvin" <hpa@...or.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...e.hu>
Subject: Re: [RFC v11][PATCH 03/13] General infrastructure for checkpoint
restart
Oren Laadan wrote:
> +/*
> + * Helpers to write(read) from(to) kernel space to(from) the checkpoint
> + * image file descriptor (similar to how a core-dump is performed).
> + *
> + * cr_kwrite() - write a kernel-space buffer to the checkpoint image
> + * cr_kread() - read from the checkpoint image to a kernel-space buffer
> + */
> +
> +int cr_kwrite(struct cr_ctx *ctx, void *addr, int count)
> +{
> + struct file *file = ctx->file;
> + mm_segment_t fs;
> + ssize_t nwrite;
> + int nleft;
> +
> + fs = get_fs();
> + set_fs(KERNEL_DS);
> + for (nleft = count; nleft; nleft -= nwrite) {
> + nwrite = file->f_op->write(file, addr, nleft, &file->f_pos);
> + if (nwrite < 0) {
> + if (nwrite == -EAGAIN)
> + nwrite = 0;
> + else
set_fs(fs) here
> + return nwrite;
> + }
> + addr += nwrite;
> + }
> + set_fs(fs);
> + ctx->total += count;
> + return 0;
> +}
> +
> +int cr_kread(struct cr_ctx *ctx, void *addr, int count)
> +{
> + struct file *file = ctx->file;
> + mm_segment_t fs;
> + ssize_t nread;
> + int nleft;
> +
> + fs = get_fs();
> + set_fs(KERNEL_DS);
> + for (nleft = count; nleft; nleft -= nread) {
> + nread = file->f_op->read(file, addr, nleft, &file->f_pos);
> + if (nread <= 0) {
> + if (nread == -EAGAIN) {
> + nread = 0;
> + continue;
> + } else if (nread == 0)
> + nread = -EPIPE; /* unexecpted EOF */
set_fs(fs) here as well
> + return nread;
> + }
> + addr += nread;
> + }
> + set_fs(fs);
> + ctx->total += count;
> + return 0;
> +}
> +
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists