Linux Container Development
 help / color / mirror / Atom feed
From: sukadev-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org
To: serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org
Cc: Containers <containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>
Subject: [RFC][PATCH] Restore fd flags in restarted process
Date: Tue, 17 Jun 2008 14:29:02 -0700	[thread overview]
Message-ID: <20080617212902.GA11826@us.ibm.com> (raw)


From e33c0c11cc612896cb12ddad1925037e52e76eb3 Mon Sep 17 00:00:00 2001
From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Date: Tue, 17 Jun 2008 12:32:30 -0700
Subject: [PATCH] Restore fd flags in restarted process.

We currently get these flags using fcntl(F_GETFL) and save them while
checkpointing but we do not restore them when restarting the process.

Signed-off-by: Sukadev Bhattiprolu <sukadev-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 cr.c  |   10 +++++++++-
 sci.h |    7 ++++---
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/cr.c b/cr.c
index c52dd70..5163a3d 100644
--- a/cr.c
+++ b/cr.c
@@ -251,7 +251,7 @@ int getfdinfo(pinfo_t *pi)
 		if (len >= 0) pi->fi[n].name[len] = 0;
 		stat(dname, &st);
 		pi->fi[n].mode = st.st_mode;
-		pi->fi[n].flag = PT_FCNTL(syscallpid, pi->fi[n].fdnum, F_GETFL);
+		pi->fi[n].flag = PT_FCNTL(syscallpid, pi->fi[n].fdnum, F_GETFL, 0);
 		if (S_ISREG(st.st_mode))
 			pi->fi[n].offset = (off_t)PT_LSEEK(syscallpid, pi->fi[n].fdnum, 0, SEEK_CUR);
 		else if (S_ISFIFO(st.st_mode))
@@ -841,6 +841,14 @@ int restore_fd(int fd, pid_t pid)
 			}
 		}
 
+		/*
+		 * Restore any special flags this fd had
+		 */
+		ret = PT_FCNTL(pid, fdinfo->fdnum, F_SETFL, fdinfo->flag);
+		DEBUG("---- restore_fd() fd %d setfl flag 0x%x, ret %d\n",
+				fdinfo->fdnum, fdinfo->flag, ret);
+
+
 		free(fdinfo);
 	}
 	if (1) {
diff --git a/sci.h b/sci.h
index b0cac3c..0b32ae4 100644
--- a/sci.h
+++ b/sci.h
@@ -138,10 +138,11 @@ int call_func(pid_t pid, int scratch, int flag, int funcaddr, int argc, ...);
 			0, 0, off,		\
 			0, 0, w)
 
-#define PT_FCNTL(p, fd, cmd) \
-	ptrace_syscall(p, 0, 0, SYS_fcntl, 2,	\
+#define PT_FCNTL(p, fd, cmd, arg) \
+	ptrace_syscall(p, 0, 0, SYS_fcntl, 3,	\
 			0, 0, fd,		\
-			0, 0, cmd)
+			0, 0, cmd,		\
+			0, 0, arg)
 
 #define PT_CLOSE(p, fd)	\
 	ptrace_syscall(p, 0, 0, SYS_close, 1,	\
-- 
1.5.2.5

             reply	other threads:[~2008-06-17 21:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-17 21:29 sukadev-r/Jw6+rmf7HQT0dZR+AlfA [this message]
     [not found] ` <20080617212902.GA11826-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-06-17 22:31   ` [RFC][PATCH] Restore fd flags in restarted process Serge E. Hallyn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080617212902.GA11826@us.ibm.com \
    --to=sukadev-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox