* system service
*/
#define ARG_LABELNAME "-label" /* custom label name */
+#define ARG_PROGNAME "-progname" /* custom program name */
#define ARG_CONFIG "-config" /* name of the file with the resource
* configuration
*/
static char *req_trg_label = NULL;
static char *req_path = NULL;
static char *req_path_self = SELF_REQ_PATH;
+static char *req_progname = NULL;
static char *req_args = "";
static int req_major = 0;
static int devman_id = 0;
fprintf(stderr, "Warning, %s\n", problem);
fprintf(stderr, "Usage:\n");
fprintf(stderr,
- " %s [%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s] (up|run|edit|update) <binary|%s> [%s <args>] [%s <special>] [%s <major_nr>] [%s <dev_id>] [%s <ticks>] [%s <path>] [%s <name>] [%s <path>] [%s <state value|eval_expression>] [%s <time>] [%s <bytes>] [%s <bytes>] [%s <name>] [(%s|%s <src_label1,src_type1:src_label2,:,src_type3:...>)*] [%s <count>] [%s <restarts>]\n",
+ " %s [%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s] (up|run|edit|update) <binary|%s> [%s <args>] [%s <special>] [%s <major_nr>] [%s <dev_id>] [%s <ticks>] [%s <path>] [%s <name>] [%s <name>] [%s <path>] [%s <state value|eval_expression>] [%s <time>] [%s <bytes>] [%s <bytes>] [%s <name>] [(%s|%s <src_label1,src_type1:src_label2,:,src_type3:...>)*] [%s <count>] [%s <restarts>]\n",
app_name, OPT_COPY, OPT_REUSE, OPT_NOBLOCK, OPT_REPLICA, OPT_NO_BIN_EXP,
OPT_BATCH, OPT_ASR_LU, OPT_PREPARE_ONLY_LU, OPT_FORCE_SELF_LU,
OPT_FORCE_INIT_CRASH, OPT_FORCE_INIT_FAIL, OPT_FORCE_INIT_TIMEOUT,
OPT_FORCE_INIT_DEFCB, OPT_NOMMAP_LU, OPT_DETACH,
OPT_NORESTART, OPT_FORCE_INIT_ST, SELF_BINARY,
ARG_ARGS, ARG_DEV, ARG_MAJOR, ARG_DEVMANID, ARG_PERIOD,
- ARG_SCRIPT, ARG_LABELNAME, ARG_CONFIG, ARG_LU_STATE, ARG_LU_MAXTIME,
+ ARG_SCRIPT, ARG_LABELNAME, ARG_PROGNAME, ARG_CONFIG, ARG_LU_STATE, ARG_LU_MAXTIME,
ARG_HEAP_PREALLOC, ARG_MAP_PREALLOC, ARG_TRG_LABELNAME, ARG_LU_IPC_BL, ARG_LU_IPC_WL,
ARG_ASR_COUNT, ARG_RESTARTS);
fprintf(stderr, " %s down <label>\n", app_name);
else if (strcmp(argv[i], ARG_TRG_LABELNAME)==0) {
req_trg_label = argv[i+1];
}
+ else if (strcmp(argv[i], ARG_PROGNAME)==0) {
+ req_progname = argv[i+1];
+ }
else if (strcmp(argv[i], ARG_CONFIG)==0) {
req_config = argv[i+1];
custom_config_file = 1;
case RS_UP:
case RS_EDIT:
/* Build space-separated command string to be passed to RS server. */
- progname = strrchr(req_path, '/');
- assert(progname); /* an absolute path was required */
- progname++; /* skip last slash */
+ if (req_progname != NULL) {
+ progname = req_progname;
+ } else {
+ progname = strrchr(req_path, '/');
+ assert(progname); /* an absolute path was required */
+ progname++; /* skip last slash */
+ }
strcpy(command, req_path);
command[strlen(req_path)] = ' ';
strcpy(command+strlen(req_path)+1, req_args);
/* Set specifics */
config.rs_start.rss_cmd= command;
config.rs_start.rss_cmdlen= strlen(command);
+ config.rs_start.rss_progname= progname;
+ config.rs_start.rss_prognamelen= strlen(progname);
config.rs_start.rss_major= req_major;
config.rs_start.rss_period= req_period;
config.rs_start.rss_script= req_script;
struct rss_label rss_control[RS_NR_CONTROL];
struct rs_state_data rss_state_data;
int devman_id;
+ char *rss_progname;
+ size_t rss_prognamelen;
/*
* SMP specific data
*
{ NULL }
};
-int srv_execve(int proc_e, char *exec, size_t exec_len, char **argv,
- char **envp)
+int srv_execve(int proc_e, char *exec, size_t exec_len, char *progname,
+ char **argv, char **envp)
{
size_t frame_size = 0; /* Size of the new initial stack. */
int argc = 0; /* Argument count. */
struct ps_strings *psp;
int vsp = 0; /* (virtual) Stack pointer in new address space. */
- char *progname;
int r;
minix_stack_params(argv[0], argv, envp, &frame_size, &overflow,
minix_stack_fill(argv[0], argc, argv, envc, envp, frame_size, frame,
&vsp, &psp);
- (progname=strrchr(argv[0], '/')) ? progname++ : (progname=argv[0]);
-
r = do_exec(proc_e, exec, exec_len, progname, frame, frame_size,
vsp + ((char *)psp - frame));
*/
rpub->dev_nr = boot_image_dev->dev_nr; /* major device number */
- /* Build command settings. This will also set the process name. */
+ /* Build command settings. Also set the process name. */
strlcpy(rp->r_cmd, ip->proc_name, sizeof(rp->r_cmd));
rp->r_script[0]= '\0';
build_cmd_dep(rp);
+ strlcpy(rpub->proc_name, ip->proc_name, sizeof(rpub->proc_name));
+
/* Initialize vm call mask bitmap. */
calls = SRV_OR_USR(rp, SRV_VC, USR_VC) == ALL_C ? all_c : no_c;
fill_call_mask(calls, NR_VM_CALLS, rpub->vm_call_mask, VM_RQ_BASE, TRUE);
assert(arg_count < ARGV_ELEMENTS);
rp->r_argv[arg_count] = NULL; /* end with NULL pointer */
rp->r_argc = arg_count;
-
- /* Build process name. */
- cmd_ptr = strrchr(rp->r_argv[0], '/');
- if (cmd_ptr)
- cmd_ptr++;
- else
- cmd_ptr= rp->r_argv[0];
- len= strlen(cmd_ptr);
- if (len > RS_MAX_LABEL_LEN-1)
- len= RS_MAX_LABEL_LEN-1; /* truncate name */
- memcpy(rpub->proc_name, cmd_ptr, len);
- rpub->proc_name[len]= '\0';
}
/*===========================================================================*
}
if(rs_verbose)
printf("RS: execing child with srv_execve()...\n");
- s = srv_execve(child_proc_nr_e, rp->r_exec, rp->r_exec_len, rp->r_argv,
- environ);
+ s = srv_execve(child_proc_nr_e, rp->r_exec, rp->r_exec_len, rpub->proc_name,
+ rp->r_argv, environ);
vm_memctl(RS_PROC_NR, VM_RS_MEM_PIN, 0, 0);
if (s != OK) {
printf("RS: srv_execve failed: %d\n", s);
rp->r_cmd[rs_start->rss_cmdlen] = '\0'; /* ensure it is terminated */
if (rp->r_cmd[0] != '/') return(EINVAL); /* insist on absolute path */
- /* Build cmd dependencies: argv and program name. */
+ /* Build cmd dependencies (argv). */
build_cmd_dep(rp);
+ /* Copy in the program name. */
+ if (rs_start->rss_prognamelen > sizeof(rpub->proc_name)-1) return(E2BIG);
+ s=sys_datacopy(source, (vir_bytes) rs_start->rss_progname,
+ SELF, (vir_bytes) rpub->proc_name, rs_start->rss_prognamelen);
+ if (s != OK) return(s);
+ rpub->proc_name[rs_start->rss_prognamelen] = '\0';
+
/* Update label if not already set. */
if(!strcmp(rpub->label, "")) {
if(rs_start->rss_label.l_len > 0) {
struct rprocupd;
/* exec.c */
-int srv_execve(int proc_e, char *exec, size_t exec_len, char *argv[],
- char **env);
+int srv_execve(int proc_e, char *exec, size_t exec_len, char *progname,
+ char *argv[], char **env);
/* main.c */
int main(void);
put_flags(proc, "rss_flags", rss_flags, COUNT(rss_flags),
"0x%x", buf.rss_flags);
put_buf(proc, "rss_cmd", 0, (vir_bytes)buf.rss_cmd, buf.rss_cmdlen);
+ put_buf(proc, "rss_progname", 0, (vir_bytes)buf.rss_progname,
+ buf.rss_prognamelen);
put_buf(proc, "rss_label", 0, (vir_bytes)buf.rss_label.l_addr,
buf.rss_label.l_len);
if (verbose > 0 || buf.rss_major != 0)