section_string, page_name, NULL);
return ret;
}
+
+LTTNG_HIDDEN
+int utils_change_working_dir(const char *path)
+{
+ int ret;
+
+ assert(path);
+
+ ret = chdir(path);
+ if (ret) {
+ PERROR("Failed to change working directory: %s", path);
+ goto end;
+ }
+
+ /* Check for write access */
+ if (access(path, W_OK)) {
+ if (errno == EACCES) {
+ /*
+ * Do not treat this as an error since the permission
+ * might change in the lifetime of the process
+ */
+ DBG("Working directory is not writable: %s", path);
+ } else {
+ PERROR("access");
+ }
+ }
+
+end:
+ return ret;
+}