In run mode, if the destination directory does not exist, dss prints
"No such file or directory" and exits, without telling the user (a)
it was a failed chdir(2) call that caused the error, and (b) the name
of the directory. This patch adds an error message containing this
information.
Since there is only one caller of dss_chdir(), let's get rid
of this public function in file.c and call chdir() directly from
change_to_dest_dir() of dss.c.
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)
closedir(dir);
return ret;
}
-/**
- * Wrapper for chdir(2).
- *
- * \param path The specified directory.
- *
- * \return Standard.
- */
-int dss_chdir(const char *path)
-{
- if (chdir(path) >= 0)
- return 1;
- return -ERRNO_TO_DSS_ERROR(errno);
-}
/**
* Set a file descriptor to non-blocking mode.
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
-int dss_chdir(const char *path);
int for_each_subdir(int (*func)(const char *, void *), void *private_data);
__must_check int mark_fd_nonblocking(int fd);
/**