Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142216019
D48990.id150966.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D48990.id150966.diff
View Options
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -3843,6 +3843,17 @@
vn_close(vp, FWRITE, td->td_ucred, td);
}
+static void
+get_corefile_name(char *name, int indexpos, int indexlen, int index)
+{
+ char ch;
+
+ ch = name[indexpos + indexlen];
+ snprintf(name + indexpos, indexlen + 1, "%.*u", indexlen,
+ index);
+ name[indexpos + indexlen] = ch;
+}
+
/*
* If the core format has a %I in it, then we need to check
* for existing corefiles before defining a name.
@@ -3857,8 +3868,7 @@
struct vnode *oldvp, *nextvp, *vp;
struct vattr vattr;
struct nameidata nd;
- int error, i, flags, oflags, cmode;
- char ch;
+ int error, i, flags, oflags, cmode, chosen = -1;
struct timespec lasttime;
nextvp = oldvp = NULL;
@@ -3869,10 +3879,7 @@
for (i = 0; i < ncores; i++) {
flags = O_CREAT | FWRITE | O_NOFOLLOW;
- ch = name[indexpos + indexlen];
- (void)snprintf(name + indexpos, indexlen + 1, "%.*u", indexlen,
- i);
- name[indexpos + indexlen] = ch;
+ get_corefile_name(name, indexpos, indexlen, i);
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name);
error = vn_open_cred(&nd, &flags, cmode, oflags, td->td_ucred,
@@ -3883,6 +3890,7 @@
vp = nd.ni_vp;
NDFREE_PNBUF(&nd);
if ((flags & O_CREAT) == O_CREAT) {
+ chosen = i;
nextvp = vp;
break;
}
@@ -3902,11 +3910,16 @@
oldvp = vp;
VOP_UNLOCK(oldvp);
lasttime = vattr.va_mtime;
+ chosen = i;
} else {
vnode_close_locked(td, vp);
}
}
+ if (chosen != -1) {
+ get_corefile_name(name, indexpos, indexlen, chosen);
+ }
+
if (oldvp != NULL) {
if (nextvp == NULL) {
if ((td->td_proc->p_flag & P_SUGID) != 0) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 18, 9:05 AM (18 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27707492
Default Alt Text
D48990.id150966.diff (1 KB)
Attached To
Mode
D48990: fix devctl core file name
Attached
Detach File
Event Timeline
Log In to Comment