Skip to content

Instantly share code, notes, and snippets.

@johnramsden
Created June 21, 2016 22:28
Show Gist options
  • Save johnramsden/8ae4bc7e2f5236c714f8e822001ac842 to your computer and use it in GitHub Desktop.
Save johnramsden/8ae4bc7e2f5236c714f8e822001ac842 to your computer and use it in GitHub Desktop.
File to change hostid on Arch linux after a ZFS install.
#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