All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] Restore fd flags in restarted process
@ 2008-06-17 21:29 sukadev-r/Jw6+rmf7HQT0dZR+AlfA
       [not found] ` <20080617212902.GA11826-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: sukadev-r/Jw6+rmf7HQT0dZR+AlfA @ 2008-06-17 21:29 UTC (permalink / raw)
  To: serue-r/Jw6+rmf7HQT0dZR+AlfA; +Cc: Containers


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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-06-17 22:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-17 21:29 [RFC][PATCH] Restore fd flags in restarted process sukadev-r/Jw6+rmf7HQT0dZR+AlfA
     [not found] ` <20080617212902.GA11826-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-06-17 22:31   ` Serge E. Hallyn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.