diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f475a8f --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +all: + chmod +x build.sh + ./build.sh rootfs + +clean: + ./build.sh clean diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 diff --git a/networking/hostname.c b/networking/hostname.c index dbd641e..ed5a81a 100644 --- a/networking/hostname.c +++ b/networking/hostname.c @@ -3,31 +3,15 @@ #include #include #include -#include -#include -#include int main(const int argc, const char **argv) { - unsigned int f_flag = 0; - unsigned int d_flag = 0; - unsigned int i_flag = 0; - int i; for (i = 1; i < argc; i++) { if (argv[i][0] != '-') break; - else if (!strcmp(argv[i], "-f")) - f_flag = 1; - - else if (!strcmp(argv[i], "-d")) - d_flag = 1; - - else if (!strcmp(argv[i], "-i")) - i_flag = 1; - else if (!strcmp(argv[i], "--help")) { - printf("hostname [-f (Display the FQDN)] [-d (Display domainname)] [-i (Addresses for the hostname)]/ [hostname (Set new hostname)]\n"); + printf("hostname [hostname (Set new hostname)]\n"); return 0; } } @@ -44,37 +28,13 @@ int main(const int argc, const char **argv) { } /* Get info */ - char hostname[HOST_NAME_MAX]; + char hostname[HOST_NAME_MAX + 1]; if (gethostname(hostname, sizeof(hostname)) < 0) { fprintf(stderr, "hostname: %s\n", strerror(errno)); return 1; } - struct hostent *hp = gethostbyname(hostname); - if (!hp) { - fprintf(stderr, "hostname: %s\n", strerror(errno)); - return 1; - } - - /* Print info */ - if (f_flag) - puts(hp->h_name); - - else if (d_flag) { - char *ptr = strchr(hp->h_name, '.'); - if (ptr) - puts(ptr + 1); - } - - else if (i_flag) { - while (hp->h_addr_list[0]) - printf("%s ", inet_ntoa( *(struct in_addr *) *(hp->h_addr_list++) )); - printf("\n"); - } - - else - puts(hostname); - + puts(hostname); return 0; }