118a119 > int i_option = 0; 131a133 > int i_arg = 0; 165a168 > " eject [-vn] -i [] -- toggle manual eject protection on/off\n" 217c220 < const char *flags = "a:c:x:dfhnqrstTXvVpm"; --- > const char *flags = "a:c:x:i:dfhnqrstTXvVpm"; 225a229 > {"manualeject", required_argument, NULL, 'i'}, 299a304,318 > case 'i': > i_option = 1; > if (!strcmp(optarg, "0")) > i_arg = 0; > else if (!strcmp(optarg, "off")) > i_arg = 0; > else if (!strcmp(optarg, "1")) > i_arg = 1; > else if (!strcmp(optarg, "on")) > i_arg = 1; > else { > fprintf(stderr, _("%s: invalid argument to -i option\n"), programName); > exit(1); > } > break; 459a479,500 > /* stops CDROM from opening on manual eject pressing the button > ** -> this can be useful when you carry your laptop > ** in your bag while it's on and no cd mounted in it's drive > ** implemented as found in Documentation/ioctl/cdrom.txt > */ > static void ManualEject(int fd, int onOff) > { > > // maybe we should check this also > // EDRIVE_CANT_DO_THIS Door lock function not supported. > // EBUSY Attempt to unlock when multiple users > // have the drive open and not CAP_SYS_ADMIN > > if (ioctl(fd, CDROM_LOCKDOOR, onOff) < 0) { > perror("ioctl on CDROM_LOCKDOOR"); > } else { > if (onOff) > printf("CD-Drive may NOT be ejected with device button\n"); > else > printf("CD-Drive may be ejected with device button\n"); > } > } 1195a1237,1245 > /* handle -i option */ > if (i_option) { > fd = OpenDevice(deviceName); > ManualEject(fd, i_arg); > exit(0); > } > > >