Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157342060
D16118.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D16118.diff
View Options
Index: head/sys/kern/kern_sig.c
===================================================================
--- head/sys/kern/kern_sig.c
+++ head/sys/kern/kern_sig.c
@@ -3214,11 +3214,7 @@
sigparent(p, reason, status);
}
-/*
- * We only have 1 character for the core count in the format
- * string, so the range will be 0-9
- */
-#define MAX_NUM_CORE_FILES 10
+#define MAX_NUM_CORE_FILES 100000
#ifndef NUM_CORE_FILES
#define NUM_CORE_FILES 5
#endif
@@ -3311,18 +3307,19 @@
/*
* If the core format has a %I in it, then we need to check
* for existing corefiles before defining a name.
- * To do this we iterate over 0..num_cores to find a
+ * To do this we iterate over 0..ncores to find a
* non-existing core file name to use. If all core files are
* already used we choose the oldest one.
*/
static int
corefile_open_last(struct thread *td, char *name, int indexpos,
- struct vnode **vpp)
+ int indexlen, int ncores, struct vnode **vpp)
{
struct vnode *oldvp, *nextvp, *vp;
struct vattr vattr;
struct nameidata nd;
int error, i, flags, oflags, cmode;
+ char ch;
struct timespec lasttime;
nextvp = oldvp = NULL;
@@ -3330,10 +3327,14 @@
oflags = VN_OPEN_NOAUDIT | VN_OPEN_NAMECACHE |
(capmode_coredump ? VN_OPEN_NOCAPCHECK : 0);
- for (i = 0; i < num_cores; i++) {
+ for (i = 0; i < ncores; i++) {
flags = O_CREAT | FWRITE | O_NOFOLLOW;
- name[indexpos] = '0' + i;
+ ch = name[indexpos + indexlen];
+ (void)snprintf(name + indexpos, indexlen + 1, "%.*u", indexlen,
+ i);
+ name[indexpos + indexlen] = ch;
+
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, td);
error = vn_open_cred(&nd, &flags, cmode, oflags, td->td_ucred,
NULL);
@@ -3402,12 +3403,14 @@
struct nameidata nd;
const char *format;
char *hostname, *name;
- int cmode, error, flags, i, indexpos, oflags;
+ int cmode, error, flags, i, indexpos, indexlen, oflags, ncores;
hostname = NULL;
format = corefilename;
name = malloc(MAXPATHLEN, M_TEMP, M_WAITOK | M_ZERO);
+ indexlen = 0;
indexpos = -1;
+ ncores = num_cores;
(void)sbuf_new(&sb, name, MAXPATHLEN, SBUF_FIXEDLEN);
sx_slock(&corefilename_lock);
for (i = 0; format[i] != '\0'; i++) {
@@ -3428,8 +3431,14 @@
sbuf_printf(&sb, "%s", hostname);
break;
case 'I': /* autoincrementing index */
- sbuf_printf(&sb, "0");
- indexpos = sbuf_len(&sb) - 1;
+ if (indexpos != -1) {
+ sbuf_printf(&sb, "%%I");
+ break;
+ }
+
+ indexpos = sbuf_len(&sb);
+ sbuf_printf(&sb, "%u", ncores - 1);
+ indexlen = sbuf_len(&sb) - indexpos;
break;
case 'N': /* process name */
sbuf_printf(&sb, "%s", comm);
@@ -3469,7 +3478,8 @@
sbuf_delete(&sb);
if (indexpos != -1) {
- error = corefile_open_last(td, name, indexpos, vpp);
+ error = corefile_open_last(td, name, indexpos, indexlen, ncores,
+ vpp);
if (error != 0) {
log(LOG_ERR,
"pid %d (%s), uid (%u): Path `%s' failed "
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, May 21, 11:41 AM (4 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33389488
Default Alt Text
D16118.diff (2 KB)
Attached To
Mode
D16118: Extend amount of possible coredumps.
Attached
Detach File
Event Timeline
Log In to Comment