[Devel] Re: [RFC v2][PATCH 9/9] File descriprtors (restore)

Oren Laadan orenl at cs.columbia.edu
Wed Aug 20 22:26:33 PDT 2008


>
> Restore open file descriptors: for each FD read 'struct cr_hdr_fd_ent'
> and lookup tag in the hash table; if not found (first occurence), read
> in 'struct cr_hdr_fd_data', create a new FD and register in the hash.
> Otherwise attach the file pointer from the hash as an FD.
>
> This patch only handles basic FDs - regular files, directories and also
> symbolic links.
>
> Signed-off-by: Oren Laadan <orenl at cs.columbia.edu>
> ---
>  checkpoint/Makefile     |    2 +-
>  checkpoint/checkpoint.c |    3 +
>  checkpoint/ckpt.h       |    6 +-
>  checkpoint/restart.c    |    3 +
>  checkpoint/rstr_file.c  |  202 +++++++++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 213 insertions(+), 3 deletions(-)
>  create mode 100644 checkpoint/rstr_file.c
>

To restore the open files, cr_read_files() first closes all the
existing FDs of the current process. This breaks the assumption
underlying the use of fget_light/fput_light in sys_restart(), so
use fget/fput instead.


diff --git a/checkpoint/sys.c b/checkpoint/sys.c
index 7b2670a..ec1609b 100644
--- a/checkpoint/sys.c
+++ b/checkpoint/sys.c
@@ -210,10 +210,9 @@ asmlinkage long sys_restart(int crid, int fd, unsigned long flags)
  {
  	struct cr_ctx *ctx;
  	struct file *file;
-	int fput_needed;
  	int ret;

-	file = fget_light(fd, &fput_needed);
+	file = fget(fd);
  	if (!file)
  		return -EBADF;

@@ -223,14 +222,14 @@ asmlinkage long sys_restart(int crid, int fd, unsigned long flags)

  	ctx = cr_ctx_alloc(crid, file, flags | CR_CTX_RSTR);
  	if (!ctx) {
-		fput_light(file, fput_needed);
+		fput(file);
  		return -ENOMEM;
  	}

  	ret = do_restart(ctx);

  	cr_ctx_free(ctx);
-	fput_light(file, fput_needed);
+	fput(file);

  	return ret;
  }
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list