Bug 142635

Summary: patch behavior differs depending on where /tmp is located
Product: [openSUSE] SUSE Linux 10.1 Reporter: Andreas Gruenbacher <agruen>
Component: BasesystemAssignee: Andreas Gruenbacher <agruen>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None    
Version: Alpha 4   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Andreas Gruenbacher 2006-01-11 16:55:33 UTC
Patch succeeds in patching a read-only file if /tmp is on the same file system as the patches file (case A), and fails if /tmp is on another file system (case B):

Case A:
rename("/tmp/poz7rGZg", "mm/filemap.c") = 0
stat("mm/filemap.c", {st_mode=S_IFREG|0644, st_size=65396, ...}) = 0
chmod("mm/filemap.c", 0100444)          = 0

Case B:
rename("/tmp/poIg66mc", "mm/filemap.c") = -1 EXDEV (Invalid cross-device link)
mkdir("mm", 0777)                       = -1 EEXIST (File exists)
open("/tmp/poIg66mc", O_RDONLY|O_LARGEFILE) = 4
open("mm/filemap.c", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0100644) = -1 EACCES (Permission denied)

It should exhibit the same behavior in both cases; this could be achieved by first unlinking the destination file in case B, either after seeing -EACCES, or before trying the open that currently fails.
Comment 1 Andreas Gruenbacher 2006-01-12 06:59:53 UTC
Found to be an obscure bug in my patch remember-backup-files.diff.