| | |
| | | *@param uuid uuid as read in /dev/disk/by-uuid |
| | | *@param buffer_out: unsigned char buffer[8] output buffer for result |
| | | */ |
| | | static void parseUUID(const char *uuid, unsigned char *buffer_out, |
| | | unsigned int out_size) { |
| | | static void parseUUID(const char *uuid, unsigned char *buffer_out, unsigned int out_size) { |
| | | size_t len; |
| | | unsigned int i, j; |
| | | char *hexuuid; |
| | |
| | | |
| | | currentDrive = 0; |
| | | while (NULL != (ent = getmntent(aFile))) { |
| | | if ((strncmp(ent->mnt_type, "ext", 3) == 0 |
| | | || strncmp(ent->mnt_type, "xfs", 3) == 0 |
| | | || strncmp(ent->mnt_type, "vfat", 4) == 0 |
| | | || strncmp(ent->mnt_type, "ntfs", 4) == 0) |
| | | && ent->mnt_fsname != NULL |
| | | && strncmp(ent->mnt_fsname, "/dev/", 5) == 0) { |
| | | if ((strncmp(ent->mnt_type, "ext", 3) == 0 || strncmp(ent->mnt_type, "xfs", 3) == 0 || |
| | | strncmp(ent->mnt_type, "vfat", 4) == 0 || strncmp(ent->mnt_type, "ntfs", 4) == 0) && |
| | | ent->mnt_fsname != NULL && strncmp(ent->mnt_fsname, "/dev/", 5) == 0) { |
| | | if (stat(ent->mnt_fsname, &mount_stat) == 0) { |
| | | drive_found = -1; |
| | | for (i = 0; i < currentDrive; i++) { |
| | |
| | | if (drive_found == -1) { |
| | | LOG_DEBUG("mntent: %s %s %d\n", ent->mnt_fsname, ent->mnt_dir, |
| | | (unsigned long int)mount_stat.st_ino); |
| | | strncpy(tmpDrives[currentDrive].device, ent->mnt_fsname, |
| | | 255 - 1); |
| | | strncpy(tmpDrives[currentDrive].device, ent->mnt_fsname, 255 - 1); |
| | | statDrives[currentDrive] = mount_stat.st_ino; |
| | | drive_found = currentDrive; |
| | | currentDrive++; |
| | |
| | | if (stat(cur_dir, &sym_stat) == 0) { |
| | | for (i = 0; i < currentDrive; i++) { |
| | | if (sym_stat.st_ino == statDrives[i]) { |
| | | parseUUID(dir->d_name, tmpDrives[i].disk_sn, |
| | | sizeof(tmpDrives[i].disk_sn)); |
| | | parseUUID(dir->d_name, tmpDrives[i].disk_sn, sizeof(tmpDrives[i].disk_sn)); |
| | | #ifdef _DEBUG |
| | | VALGRIND_CHECK_VALUE_IS_DEFINED(tmpDrives[i].device); |
| | | |
| | | LOG_DEBUG("uuid %d %s %02x%02x%02x%02x\n", i, |
| | | tmpDrives[i].device, |
| | | tmpDrives[i].disk_sn[0], |
| | | tmpDrives[i].disk_sn[1], |
| | | tmpDrives[i].disk_sn[2], |
| | | tmpDrives[i].disk_sn[3]); |
| | | LOG_DEBUG("uuid %d %s %02x%02x%02x%02x\n", i, tmpDrives[i].device, tmpDrives[i].disk_sn[0], |
| | | tmpDrives[i].disk_sn[1], tmpDrives[i].disk_sn[2], tmpDrives[i].disk_sn[3]); |
| | | #endif |
| | | } |
| | | } |
| | |
| | | for (i = 0; i < currentDrive; i++) { |
| | | if (sym_stat.st_ino == statDrives[i]) { |
| | | strncpy(tmpDrives[i].label, dir->d_name, 255 - 1); |
| | | printf("label %d %s %s\n", i, tmpDrives[i].label, |
| | | tmpDrives[i].device); |
| | | printf("label %d %s %s\n", i, tmpDrives[i].label, tmpDrives[i].device); |
| | | } |
| | | } |
| | | } |
| | |
| | | return result; |
| | | } |
| | | |
| | | void os_initialize() { |
| | | |
| | | } |
| | | void os_initialize() {} |
| | | |
| | | static void _getCpuid(unsigned int *p, unsigned int ax) { |
| | | __asm __volatile |
| | | ( "movl %%ebx, %%esi\n\t" |
| | | __asm __volatile( |
| | | "movl %%ebx, %%esi\n\t" |
| | | "cpuid\n\t" |
| | | "xchgl %%ebx, %%esi" |
| | | : "=a" (p[0]), "=S" (p[1]), |
| | | "=c" (p[2]), "=d" (p[3]) |
| | | : "0" (ax) |
| | | ); |
| | | : "=a"(p[0]), "=S"(p[1]), "=c"(p[2]), "=d"(p[3]) |
| | | : "0"(ax)); |
| | | } |
| | | |
| | | FUNCTION_RETURN getCpuId(unsigned char identifier[6]) { |
| | |
| | | } |
| | | |
| | | //0=NO 1=Docker/Lxc |
| | | static int checkLXC() { |
| | | return (access("/var/run/systemd/container",F_OK)==0) ? 1:0; |
| | | } |
| | | static int checkLXC() { return (access("/var/run/systemd/container", F_OK) == 0) ? 1 : 0; } |
| | | |
| | | VIRTUALIZATION getVirtualization() { |
| | | VIRTUALIZATION result = NONE; |