From 21d092705cff87dedc0c250c7dbc05ed759dfb40 Mon Sep 17 00:00:00 2001 From: Beeks Date: Sun, 10 Oct 2010 21:55:19 -0400 Subject: [PATCH] fixfixfixfixfixfixfixfixfixfixfixfixfixfixfixfixfixfixfixfix Signed-off-by: Beeks --- indra/newview/llappviewerlinux.cpp | 95 +++++------------------------- 1 file changed, 16 insertions(+), 79 deletions(-) diff --git a/indra/newview/llappviewerlinux.cpp b/indra/newview/llappviewerlinux.cpp index 9e76c2eae..20fd668d7 100644 --- a/indra/newview/llappviewerlinux.cpp +++ b/indra/newview/llappviewerlinux.cpp @@ -732,89 +732,26 @@ std::string LLAppViewerLinux::generateSerialNumber() { char serial_md5[MD5HEX_STR_SIZE]; serial_md5[0] = 0; -#if LL_SOLARIS - // TODO -#else - std::string rootDeviceName = ""; - std::string rootDeviceUUID = ""; - std::ifstream mountsFile ("/proc/mounts", std::ios_base::in); - std::string line; - while (getline(mountsFile, line, '\n')) + std::string best; + std::string uuiddir("/dev/disk/by-uuid/"); + + // trawl /dev/disk/by-uuid looking for a good-looking UUID to grab + std::string this_name; + BOOL wrap = FALSE; + while (gDirUtilp->getNextFileInDir(uuiddir, "*", this_name, wrap)) { - std::vector splitline; - boost::split(splitline, line, boost::is_any_of(" ")); - if(splitline[0] != "rootfs" && splitline[1] == "/") + if (this_name.length() > best.length() || + (this_name.length() == best.length() && + this_name > best)) { - //bingo! - rootDeviceName = splitline[0]; - splitline.clear(); - break; - } - else - { - splitline.clear(); + // longest (and secondarily alphabetically last) so far + best = this_name; } } - mountsFile.close(); - DIR *dp; - struct dirent *ep; - - char targetDir[] = "/dev/disk/by-uuid/"; - dp = opendir (targetDir); - if (dp != NULL) - { - while ((ep = readdir (dp))) - { - if(strcmp(".", ep->d_name) != 0 && strcmp("..", ep->d_name) != 0) - { - char buf[512]; - char* targetLink = new char[1024]; - strcpy(targetLink, targetDir); - - strcat(targetLink, ep->d_name); - int count = readlink(targetLink, buf, sizeof(buf)); - if (count >= 0) - { - buf[count] = '\0'; - std::vector splitSymlink; - boost::split(splitSymlink, buf, boost::is_any_of("/")); - //alright, this is the root partition, print out its uuid - if("/dev/" + splitSymlink[splitSymlink.size() - 1] == rootDeviceName) - { - rootDeviceUUID = ep->d_name; - splitSymlink.clear(); - break; - } - else - { - splitSymlink.clear(); - } - } - } - } - - (void) closedir (dp); - } - else - { - llwarns << "Couldn't open /dev/disk/by-uuid/" << llendl; - } - - if(rootDeviceName != "" && rootDeviceUUID != "") - { - LLMD5 md5; - md5.update( (unsigned char*)rootDeviceUUID.c_str(), sizeof(char[36])); - md5.finalize(); - md5.hex_digest(serial_md5); - - llinfos << "Root Device: " << rootDeviceName << "\tUUID: " << rootDeviceUUID << "\tHash: " << serial_md5 << llendl; - } - else - { - llwarns << "Could not find root device's UUID" << llendl; - } -#endif + // we don't return the actual serial number, just a hash of it. + LLMD5 md5( reinterpret_cast(best.c_str()) ); + md5.hex_digest(serial_md5); return serial_md5; -} +} \ No newline at end of file