summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2013-05-23 12:56:26 -0700
committerAaron Plattner <aplattner@nvidia.com>2013-05-23 12:56:26 -0700
commit80e2b650b3280067c4435e401bfbeede5ff305fc (patch)
tree62e0fe7d927988629d7014d2139ab9b42685d686
parentefcc17c893c82380f0af98767f1cd2c7a39d8f6a (diff)
319.23319.23
-rw-r--r--common-utils/common-utils.c6
-rw-r--r--files.c81
-rw-r--r--files.h2
-rw-r--r--misc.c71
-rw-r--r--version.mk2
5 files changed, 112 insertions, 50 deletions
diff --git a/common-utils/common-utils.c b/common-utils/common-utils.c
index 7b18294..9b734f3 100644
--- a/common-utils/common-utils.c
+++ b/common-utils/common-utils.c
@@ -725,7 +725,7 @@ char *nv_trim_space(char *string) {
char *ret, *end;
for (ret = string; *ret && isspace(*ret); ret++);
- for (end = ret + strlen(ret); end >= ret && isspace(*end); end--) {
+ for (end = ret + strlen(ret) - 1; end >= ret && isspace(*end); end--) {
*end = '\0';
}
@@ -745,13 +745,13 @@ static char *trim_char(char *string, char trim, int *count) {
return NULL;
}
- len = strlen(string);
-
if (string[0] == trim) {
string++;
replaced++;
}
+ len = strlen(string);
+
if (string[len - 1] == trim) {
string[len - 1] = '\0';
replaced++;
diff --git a/files.c b/files.c
index 58ef3d2..692096f 100644
--- a/files.c
+++ b/files.c
@@ -395,15 +395,7 @@ void select_tls_class(Options *op, Package *p)
for (i = 0; i < p->num_entries; i++) {
if ((p->entries[i].tls_class == FILE_TLS_CLASS_NEW) &&
(p->entries[i].compat_arch == FILE_COMPAT_ARCH_NATIVE)) {
- /*
- * XXX don't try to free the destination string for
- * these invalidated TLS libraries; this prevents
- * a crash on some Slackware 10.0 installations that
- * I've been unable to reproduce/root cause.
- */
- /* nvfree(p->entries[i].dst); */
- p->entries[i].type = FILE_TYPE_NONE;
- p->entries[i].dst = NULL;
+ invalidate_package_entry(&(p->entries[i]));
}
}
} else {
@@ -440,15 +432,7 @@ void select_tls_class(Options *op, Package *p)
for (i = 0; i < p->num_entries; i++) {
if ((p->entries[i].tls_class == FILE_TLS_CLASS_NEW) &&
(p->entries[i].compat_arch == FILE_COMPAT_ARCH_COMPAT32)) {
- /*
- * XXX don't try to free the destination string for
- * these invalidated TLS libraries; this prevents
- * a crash on some Slackware 10.0 installations that
- * I've been unable to reproduce/root cause.
- */
- /* nvfree(p->entries[i].dst); */
- p->entries[i].type = FILE_TYPE_NONE;
- p->entries[i].dst = NULL;
+ invalidate_package_entry(&(p->entries[i]));
}
}
} else {
@@ -1029,15 +1013,14 @@ void remove_non_kernel_module_files_from_package(Options *op, Package *p)
if ((p->entries[i].type != FILE_TYPE_KERNEL_MODULE) &&
(p->entries[i].type != FILE_TYPE_KERNEL_MODULE_CMD) &&
(p->entries[i].type != FILE_TYPE_KERNEL_MODULE_SRC)) {
- p->entries[i].type = FILE_TYPE_NONE;
+ invalidate_package_entry(&(p->entries[i]));
}
}
}
/*
- * Clear the file type for each package entry that is not type
- * FILE_TYPE_OPENGL_FILE.
+ * Clear the file type for each package entry that is an OpenGL File
*/
void remove_opengl_files_from_package(Options *op, Package *p)
{
@@ -1045,7 +1028,7 @@ void remove_opengl_files_from_package(Options *op, Package *p)
for (i = 0; i < p->num_entries; i++) {
if (p->entries[i].caps.is_opengl) {
- p->entries[i].type = FILE_TYPE_NONE;
+ invalidate_package_entry(&(p->entries[i]));
}
}
}
@@ -1290,6 +1273,38 @@ char *get_symlink_target(Options *op, const char *filename)
/*
+ * get_resolved_symlink_target() - same as get_symlink_target, except that
+ * relative links get resolved to an absolute path.
+ */
+char * get_resolved_symlink_target(Options *op, const char *filename)
+{
+ char *target = get_symlink_target(op, filename);
+ if (target[0] != '/') {
+ /* target is relative; canonicalize */
+ char *filename_copy, *target_dir, *full_target_path;
+
+ /* dirname(3) may modify the string passed into it; make a copy */
+ filename_copy = nvstrdup(filename);
+ target_dir = dirname(filename_copy);
+
+ full_target_path = nvstrcat(target_dir, "/", target, NULL);
+
+ nvfree(filename_copy);
+ nvfree(target);
+
+ target = nvalloc(PATH_MAX);
+ target = realpath(full_target_path, target);
+
+ nvfree(full_target_path);
+ }
+
+ return target;
+
+} /* get_resolved_symlink_target() */
+
+
+
+/*
* install_file() - install srcfile as dstfile; this is done by
* extracting the directory portion of dstfile, and then calling
* copy_file().
@@ -1935,8 +1950,7 @@ void process_libGL_la_files(Options *op, Package *p)
/* invalidate the template file */
- p->entries[i].type = FILE_TYPE_NONE;
- p->entries[i].dst = NULL;
+ invalidate_package_entry(&(p->entries[i]));
tmpfile = process_template_file(op, &p->entries[i], tokens,
replacements);
@@ -2002,8 +2016,7 @@ void process_dot_desktop_files(Options *op, Package *p)
/* invalidate the template file */
- p->entries[i].type = FILE_TYPE_NONE;
- p->entries[i].dst = NULL;
+ invalidate_package_entry(&(p->entries[i]));
nvfree(replacements[1]);
@@ -2533,3 +2546,19 @@ int secure_delete(Options *op, const char *file)
return FALSE;
}
} /* secure_delete() */
+
+
+/* invalidate_package_entry() - clear a package entry */
+
+void invalidate_package_entry(PackageEntry *entry)
+{
+ entry->type = FILE_TYPE_NONE;
+ /*
+ * XXX don't try to free the destination string for
+ * these invalidated package entries; this prevents
+ * a crash on some Slackware 10.0 installations that
+ * we've been unable to reproduce/root cause.
+ */
+ entry->dst = NULL;
+ memset(&(entry->caps), 0, sizeof(entry->caps));
+}
diff --git a/files.h b/files.h
index a7f0d16..7f1cef4 100644
--- a/files.h
+++ b/files.h
@@ -43,6 +43,7 @@ int confirm_path(Options *op, const char *path);
int mkdir_with_log(Options *op, const char *path, const mode_t mode, int log);
int mkdir_recursive(Options *op, const char *path, const mode_t mode);
char *get_symlink_target(Options *op, const char *filename);
+char *get_resolved_symlink_target(Options *op, const char *filename);
int install_file(Options *op, const char *srcfile,
const char *dstfile, mode_t mode);
int install_symlink(Options *op, const char *linkname, const char *dstfile);
@@ -64,5 +65,6 @@ void get_default_prefixes_and_paths(Options *op);
char *nv_strreplace(char *src, char *orig, char *replace);
char *get_filename(Options *op, const char *def, const char *fmt, ...) NV_ATTRIBUTE_PRINTF(3, 4);
int secure_delete(Options *op, const char *file);
+void invalidate_package_entry(PackageEntry *entry);
#endif /* __NVIDIA_INSTALLER_FILES_H__ */
diff --git a/misc.c b/misc.c
index 31474ff..f0ce9bf 100644
--- a/misc.c
+++ b/misc.c
@@ -627,36 +627,63 @@ int find_module_utils(Options *op)
int check_proc_modprobe_path(Options *op)
{
FILE *fp;
- char *buf = NULL;
+ char *proc_modprobe = NULL, *found_modprobe;
+ struct stat st;
+ int ret, success = FALSE;
+
+ found_modprobe = op->utils[MODPROBE];
fp = fopen(PROC_MODPROBE_PATH_FILE, "r");
if (fp) {
- buf = fget_next_line(fp, NULL);
+ proc_modprobe = fget_next_line(fp, NULL);
fclose(fp);
}
- if (buf && strcmp(buf, op->utils[MODPROBE])) {
- if (access(buf, F_OK | X_OK) == 0) {
+ /* If either the modprobe utility reported at /proc/sys/kernel/modprobe or
+ * the one found by find_system_utils() is a symlink, resolve its target. */
+
+ ret = lstat(found_modprobe, &st);
+
+ if (ret == 0 && S_ISLNK(st.st_mode)) {
+ char *target = get_resolved_symlink_target(op, found_modprobe);
+ if (target && access(target, F_OK | X_OK) == 0) {
+ found_modprobe = target;
+ }
+ }
+
+ if (proc_modprobe) {
+ ret = lstat(proc_modprobe, &st);
+
+ if (ret == 0 && S_ISLNK(st.st_mode)) {
+ char *target = get_resolved_symlink_target(op, proc_modprobe);
+ if (target && access(target, F_OK | X_OK) == 0) {
+ nvfree(proc_modprobe);
+ proc_modprobe = target;
+ }
+ }
+ }
+
+ if (proc_modprobe && strcmp(proc_modprobe, found_modprobe)) {
+ if (access(proc_modprobe, F_OK | X_OK) == 0) {
ui_warn(op, "The path to the `modprobe` utility reported by "
"'%s', `%s`, differs from the path determined by "
"`nvidia-installer`, `%s`. Please verify that `%s` "
"works correctly and correct the path in '%s' if "
"it does not.",
- PROC_MODPROBE_PATH_FILE, buf, op->utils[MODPROBE],
- buf, PROC_MODPROBE_PATH_FILE);
- return TRUE;
+ PROC_MODPROBE_PATH_FILE, proc_modprobe, found_modprobe,
+ proc_modprobe, PROC_MODPROBE_PATH_FILE);
+ success = TRUE;
} else {
ui_error(op, "The path to the `modprobe` utility reported by "
"'%s', `%s`, differs from the path determined by "
"`nvidia-installer`, `%s`, and does not appear to "
"point to a valid `modprobe` binary. Please correct "
"the path in '%s'.",
- PROC_MODPROBE_PATH_FILE, buf, op->utils[MODPROBE],
+ PROC_MODPROBE_PATH_FILE, proc_modprobe, found_modprobe,
PROC_MODPROBE_PATH_FILE);
- return FALSE;
}
- } else if (!buf && strcmp("/sbin/modprobe", op->utils[MODPROBE])) {
- if (access(buf, F_OK | X_OK) == 0) {
+ } else if (!proc_modprobe && strcmp("/sbin/modprobe", found_modprobe)) {
+ if (access(proc_modprobe, F_OK | X_OK) == 0) {
ui_warn(op, "The file '%s' is unavailable, the X server will "
"use `/sbin/modprobe` as the path to the `modprobe` "
"utility. This path differs from the one determined "
@@ -664,9 +691,9 @@ int check_proc_modprobe_path(Options *op)
"`/sbin/modprobe` works correctly or mount the /proc "
"file system and verify that '%s' reports the "
"correct path.",
- PROC_MODPROBE_PATH_FILE, op->utils[MODPROBE],
+ PROC_MODPROBE_PATH_FILE, found_modprobe,
PROC_MODPROBE_PATH_FILE);
- return TRUE;
+ success = TRUE;
} else {
ui_error(op, "The file '%s' is unavailable, the X server will "
"use `/sbin/modprobe` as the path to the `modprobe` "
@@ -676,14 +703,19 @@ int check_proc_modprobe_path(Options *op)
"a symbolic link from `/sbin/modprobe` to `%s` or "
"mount the /proc file system and verify that '%s' "
"reports the correct path.",
- PROC_MODPROBE_PATH_FILE, op->utils[MODPROBE],
- op->utils[MODPROBE], PROC_MODPROBE_PATH_FILE);
- return FALSE;
+ PROC_MODPROBE_PATH_FILE, found_modprobe,
+ found_modprobe, PROC_MODPROBE_PATH_FILE);
}
+ } else if (strcmp(proc_modprobe, found_modprobe) == 0) {
+ success = TRUE;
}
- nvfree(buf);
- return TRUE;
+ nvfree(proc_modprobe);
+ if (found_modprobe != op->utils[MODPROBE]) {
+ nvfree(found_modprobe);
+ }
+
+ return success;
} /* check_proc_modprobe_path() */
@@ -1137,8 +1169,7 @@ void should_install_compat32_files(Options *op, Package *p)
for (i = 0; i < p->num_entries; i++) {
if (p->entries[i].compat_arch == FILE_COMPAT_ARCH_COMPAT32) {
/* invalidate file */
- p->entries[i].type = FILE_TYPE_NONE;
- p->entries[i].dst = NULL;
+ invalidate_package_entry(&(p->entries[i]));
}
}
}
diff --git a/version.mk b/version.mk
index 8e97966..6b57a0b 100644
--- a/version.mk
+++ b/version.mk
@@ -1 +1 @@
-NVIDIA_VERSION = 319.17
+NVIDIA_VERSION = 319.23