diff --git a/X. NU/custom/drivers/DKIOCEJECT_ioctl.c b/X. NU/custom/drivers/DKIOCEJECT_ioctl.c new file mode 100644 index 0000000..5e404f7 --- /dev/null +++ b/X. NU/custom/drivers/DKIOCEJECT_ioctl.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) { + if (argc != 2) { + printf("Usage: %s /dev/diskX\n", argv[0]); + return 1; + } + + // Open the disk device + int fd = open(argv[1], O_RDWR); + if (fd < 0) { + perror("Failed to open disk device"); + return 1; + } + + // Attempt to eject the disk using ioctl + if (ioctl(fd, DKIOCEJECT, NULL) < 0) { + perror("Failed to eject disk"); + close(fd); + return 1; + } + + close(fd); + printf("Disk ejected successfully\n"); + return 0; +} diff --git a/X. NU/custom/drivers/ifstatus.c b/X. NU/custom/drivers/ifstatus.c new file mode 100644 index 0000000..2ac9c32 --- /dev/null +++ b/X. NU/custom/drivers/ifstatus.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) { + struct ifreq ifr; + int sockfd; + + // Check if interface name was provided + if (argc != 2) { + printf("Usage: %s \n", argv[0]); + printf("Example: %s en0\n", argv[0]); + return 1; + } + + // Create a UDP socket for interface communication + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd < 0) { + perror("socket"); + return 1; + } + + // Clear the structure and copy interface name + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, argv[1], IFNAMSIZ-1); + + // Get the interface flags + if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { + perror("ioctl"); + close(sockfd); + return 1; + } + + // Print interface status + printf("Interface %s status:\n", argv[1]); + printf("UP: %s\n", (ifr.ifr_flags & IFF_UP) ? "yes" : "no"); + printf("RUNNING: %s\n", (ifr.ifr_flags & IFF_RUNNING) ? "yes" : "no"); + printf("LOOPBACK: %s\n", (ifr.ifr_flags & IFF_LOOPBACK) ? "yes" : "no"); + printf("POINTOPOINT: %s\n", (ifr.ifr_flags & IFF_POINTOPOINT) ? "yes" : "no"); + printf("MULTICAST: %s\n", (ifr.ifr_flags & IFF_MULTICAST) ? "yes" : "no"); + printf("BROADCAST: %s\n", (ifr.ifr_flags & IFF_BROADCAST) ? "yes" : "no"); + printf("PROMISC: %s\n", (ifr.ifr_flags & IFF_PROMISC) ? "yes" : "no"); + + close(sockfd); + return 0; +}