Sun Oct 4 23:25:32 2015 UTC ()
put back module filename finding code.


(christos)
diff -r1.9 -r1.10 src/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c

cvs diff -r1.9 -r1.10 src/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c (expand / switch to unified diff)

--- src/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c 2015/09/24 14:25:29 1.9
+++ src/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c 2015/10/04 23:25:32 1.10
@@ -1159,26 +1159,56 @@ dt_module_update(dtrace_hdl_t *dtp, stru @@ -1159,26 +1159,56 @@ dt_module_update(dtrace_hdl_t *dtp, stru
1159#ifdef illumos 1159#ifdef illumos
1160 (void) snprintf(fname, sizeof (fname), 1160 (void) snprintf(fname, sizeof (fname),
1161 "%s/%s/object", OBJFS_ROOT, name); 1161 "%s/%s/object", OBJFS_ROOT, name);
1162#elif defined(__FreeBSD__) 1162#elif defined(__FreeBSD__)
1163 GElf_Ehdr ehdr; 1163 GElf_Ehdr ehdr;
1164 GElf_Phdr ph; 1164 GElf_Phdr ph;
1165 char name[MAXPATHLEN]; 1165 char name[MAXPATHLEN];
1166 uintptr_t mapbase, alignmask; 1166 uintptr_t mapbase, alignmask;
1167 int i = 0; 1167 int i = 0;
1168 int is_elf_obj; 1168 int is_elf_obj;
1169 1169
1170 (void) strlcpy(name, k_stat->name, sizeof(name)); 1170 (void) strlcpy(name, k_stat->name, sizeof(name));
1171 (void) strlcpy(fname, k_stat->pathname, sizeof(fname)); 1171 (void) strlcpy(fname, k_stat->pathname, sizeof(fname));
 1172#elif defined(__NetBSD__)
 1173 int mib_osrel[2] = { CTL_KERN, KERN_OSRELEASE };
 1174 int mib_mach[2] = { CTL_HW, HW_MACHINE };
 1175 char osrel[64];
 1176 char machine[64];
 1177 size_t len;
 1178
 1179 if (strcmp("netbsd", name) == 0) {
 1180 /* want the kernel */
 1181 strncpy(fname, "/netbsd", sizeof(fname));
 1182 } else {
 1183
 1184 /* build stand module path from system */
 1185 len = sizeof(osrel);
 1186 if (sysctl(mib_osrel, 2, osrel, &len, NULL, 0) == -1) {
 1187 dt_dprintf("sysctl osrel failed: %s\n",
 1188 strerror(errno));
 1189 return;
 1190 }
 1191
 1192 len = sizeof(machine);
 1193 if (sysctl(mib_mach, 2, machine, &len, NULL, 0) == -1) {
 1194 dt_dprintf("sysctl machine failed: %s\n",
 1195 strerror(errno));
 1196 return;
 1197 }
 1198
 1199 (void) snprintf(fname, sizeof (fname),
 1200 "/stand/%s/%s/modules/%s/%s.kmod", machine, osrel, name, name);
 1201 }
1172#endif 1202#endif
1173 1203
1174 if ((fd = open(fname, O_RDONLY)) == -1 || fstat64(fd, &st) == -1 || 1204 if ((fd = open(fname, O_RDONLY)) == -1 || fstat64(fd, &st) == -1 ||
1175 (dmp = dt_module_create(dtp, name)) == NULL) { 1205 (dmp = dt_module_create(dtp, name)) == NULL) {
1176 dt_dprintf("failed to open %s: %s\n", fname, strerror(errno)); 1206 dt_dprintf("failed to open %s: %s\n", fname, strerror(errno));
1177 (void) close(fd); 1207 (void) close(fd);
1178 return; 1208 return;
1179 } 1209 }
1180 1210
1181 /* 1211 /*
1182 * Since the module can unload out from under us (and /system/object 1212 * Since the module can unload out from under us (and /system/object
1183 * will return ENOENT), tell libelf to cook the entire file now and 1213 * will return ENOENT), tell libelf to cook the entire file now and
1184 * then close the underlying file descriptor immediately. If this 1214 * then close the underlying file descriptor immediately. If this