static int change_to_dest_dir(void)
{
+ int ret;
const char *dd = OPT_STRING_VAL(DSS, DEST_DIR);
+
DSS_INFO_LOG(("changing cwd to %s\n", dd));
- return dss_chdir(dd);
+ if (chdir(dd) >= 0)
+ return 1;
+ ret = -ERRNO_TO_DSS_ERROR(errno);
+ DSS_ERROR_LOG(("could not change cwd to %s\n", dd));
+ return ret;
}
static int check_config(const struct lls_command *cmd)
static int com_run(void)
{
int ret, fd = -1;
+ char *config_file;
+ pid_t pid;
if (OPT_GIVEN(DSS, DRY_RUN)) {
DSS_ERROR_LOG(("dry run not supported by this command\n"));
return -E_SYNTAX;
}
+ config_file = get_config_file_name();
+ ret = get_dss_pid(config_file, &pid);
+ free(config_file);
+ if (ret >= 0) {
+ DSS_ERROR_LOG(("pid %d\n", (int)pid));
+ return -E_ALREADY_RUNNING;
+ }
if (OPT_GIVEN(RUN, DAEMON)) {
fd = daemon_init();
daemonized = true;