files: No getpid in vain

Submitted by Pavel Emelianov on April 20, 2017, 11:14 a.m.

Details

Message ID 58F897FF.5070306@virtuozzo.com
State Accepted
Series "files: No getpid in vain"
Headers show

Commit Message

Pavel Emelianov April 20, 2017, 11:14 a.m.
Each opening of a file results in getpid() call which
is now a pure syscall :( For this particular case this
value is poitless, as log engine already prints pids.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/files.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/files.c b/criu/files.c
index 07cc9cc..01cd4c0 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -638,11 +638,10 @@  int restore_fown(int fd, FownEntry *fown)
 {
 	struct f_owner_ex owner;
 	uid_t uids[3];
-	pid_t pid = getpid();
 
 	if (fown->signum) {
 		if (fcntl(fd, F_SETSIG, fown->signum)) {
-			pr_perror("%d: Can't set signal", pid);
+			pr_perror("Can't set signal");
 			return -1;
 		}
 	}
@@ -652,12 +651,12 @@  int restore_fown(int fd, FownEntry *fown)
 		return 0;
 
 	if (getresuid(&uids[0], &uids[1], &uids[2])) {
-		pr_perror("%d: Can't get current UIDs", pid);
+		pr_perror("Can't get current UIDs");
 		return -1;
 	}
 
 	if (setresuid(fown->uid, fown->euid, uids[2])) {
-		pr_perror("%d: Can't set UIDs", pid);
+		pr_perror("Can't set UIDs");
 		return -1;
 	}
 
@@ -665,13 +664,12 @@  int restore_fown(int fd, FownEntry *fown)
 	owner.pid = fown->pid;
 
 	if (fcntl(fd, F_SETOWN_EX, &owner)) {
-		pr_perror("%d: Can't setup %d file owner pid",
-			  pid, fd);
+		pr_perror("Can't setup %d file owner pid", fd);
 		return -1;
 	}
 
 	if (setresuid(uids[0], uids[1], uids[2])) {
-		pr_perror("%d: Can't revert UIDs back", pid);
+		pr_perror("Can't revert UIDs back");
 		return -1;
 	}
 

Comments

Pavel Emelianov April 20, 2017, 1:51 p.m.
On 04/20/2017 04:27 PM, Patchwork wrote:
> == Series Details ==
> 
> Series: files: No getpid in vain
> URL   : https://patchwork.criu.org/series/1477/
> State : failure
> 
> == Logs ==
> 
> For more details see: https://travis-ci.org/criupatchwork/criu/builds/223919399
> .
> 

ENOSPC on Alpine
"IP tool failed on addr restore" on GCOV build %)
Everything else is OK
Andrey Vagin April 21, 2017, 11:26 p.m.
Accepted, thanks!

On Thu, Apr 20, 2017 at 02:14:07PM +0300, Pavel Emelyanov wrote:
> Each opening of a file results in getpid() call which
> is now a pure syscall :( For this particular case this
> value is poitless, as log engine already prints pids.
> 
> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
> ---
>  criu/files.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/criu/files.c b/criu/files.c
> index 07cc9cc..01cd4c0 100644
> --- a/criu/files.c
> +++ b/criu/files.c
> @@ -638,11 +638,10 @@ int restore_fown(int fd, FownEntry *fown)
>  {
>  	struct f_owner_ex owner;
>  	uid_t uids[3];
> -	pid_t pid = getpid();
>  
>  	if (fown->signum) {
>  		if (fcntl(fd, F_SETSIG, fown->signum)) {
> -			pr_perror("%d: Can't set signal", pid);
> +			pr_perror("Can't set signal");
>  			return -1;
>  		}
>  	}
> @@ -652,12 +651,12 @@ int restore_fown(int fd, FownEntry *fown)
>  		return 0;
>  
>  	if (getresuid(&uids[0], &uids[1], &uids[2])) {
> -		pr_perror("%d: Can't get current UIDs", pid);
> +		pr_perror("Can't get current UIDs");
>  		return -1;
>  	}
>  
>  	if (setresuid(fown->uid, fown->euid, uids[2])) {
> -		pr_perror("%d: Can't set UIDs", pid);
> +		pr_perror("Can't set UIDs");
>  		return -1;
>  	}
>  
> @@ -665,13 +664,12 @@ int restore_fown(int fd, FownEntry *fown)
>  	owner.pid = fown->pid;
>  
>  	if (fcntl(fd, F_SETOWN_EX, &owner)) {
> -		pr_perror("%d: Can't setup %d file owner pid",
> -			  pid, fd);
> +		pr_perror("Can't setup %d file owner pid", fd);
>  		return -1;
>  	}
>  
>  	if (setresuid(uids[0], uids[1], uids[2])) {
> -		pr_perror("%d: Can't revert UIDs back", pid);
> +		pr_perror("Can't revert UIDs back");
>  		return -1;
>  	}
>  
> -- 
> 2.5.5
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu