summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/pseudo/files/mayunlink.patch
blob: 9d54e40dd9bd8b2bf67b36c70002077713da2188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Some operations may call unlink() on an open fd, then call fchown/fchmod/fstat
on that fd. This would currently readd its entry to the database, which
is necessary to preserve its permissions information however since that 
file will be lost when it is closed, we don't want the DB entry to persist.
Marking it as may_unlink means the code will know its likely been deleted 
and ignore the entry later, giving improved behaviour that simple path
mismatch warnings. We can use an nlink of zero to detect this.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Upstream-Status: Pending

Index: git/pseudo.c
===================================================================
--- git.orig/pseudo.c
+++ git/pseudo.c
@@ -1100,6 +1100,21 @@ pseudo_op(pseudo_msg_t *msg, const char
 		break;
 	}
 
+	switch (msg->op) {
+	case OP_FCHOWN:		/* FALLTHROUGH */
+	case OP_FCHMOD:		/* FALLTHROUGH */
+	case OP_FSTAT:
+		if (!found_path && !found_ino && (msg->nlink == 0)) {
+			/* If nlink is 0 for an fchown/fchmod/fstat, we probably have an fd which is 
+			 * unlinked and we don't want to do inode/path matching against it. Marking it 
+ 			 * as may unlink gives the right hints in the database to ensure we
+			 * handle correctly whilst maintaining the permissions whilst the 
+			 * file exists for the fd.  */
+			pdb_may_unlink_file(msg, msg->client);
+		}
+		break;
+	}
+
 op_exit:
 	/* in the case of an exact match, we just used the pointer
 	 * rather than allocating space.