Restore fd flags in restarted process
RFC PATCH 1/1 Restore fd flags in restarted process
From e33c0c11cc612896cb12ddad1925037e52e76eb3 Mon Sep 17 00:00:00 2001
From: Sukadev Bhattiprolu <[email protected]>
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.
--- cr.c | 10 +++++++++- sci.h | 7 ++++--- 2 files changed, 13 insertions(+), 4 deletions(-)
cr.c +9 -1
@@ -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 ) {
sci.h +4 -3
@@ -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, \
Signature · 1 line
1.5.2.5
A message that is not in the archive (sent off-list or not yet received): 20080617212902.GA11826-r/[email protected]
Quoted 10 lines · Quoting sukadev-r/[email protected]…
Quoted 2 lines
From
e33c0c11cc612896cb12ddad1925037e52e76eb3Mon Sep 17 00:00:00 2001From: Sukadev Bhattiprolu <[email protected]>
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/[email protected]>
Thanks, will apply and test.
-serge
Quoted 54 lines
--- cr.c | 10 +++++++++- sci.h | 7 ++++--- 2 files changed, 13 insertions(+), 4 deletions(-)cr.c +9
-1@@ -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 ) {sci.h +4
-3@@ -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, \Signature · 1 line
1.5.2.5