Created
June 21, 2016 22:28
-
-
Save johnramsden/8ae4bc7e2f5236c714f8e822001ac842 to your computer and use it in GitHub Desktop.
File to change hostid on Arch linux after a ZFS install.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <errno.h> | |
#include <unistd.h> | |
int main() { | |
int res; | |
res = sethostid(gethostid()); | |
if (res != 0) { | |
switch (errno) { | |
case EACCES: | |
fprintf(stderr, "Error! No permission to write the" | |
" file used to store the host ID.\n" | |
"Are you root?\n"); | |
break; | |
case EPERM: | |
fprintf(stderr, "Error! The calling process's effective" | |
" user or group ID is not the same as" | |
" its corresponding real ID.\n"); | |
break; | |
default: | |
fprintf(stderr, "Unknown error.\n"); | |
} | |
return 1; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment