rpms/eject/devel eject-2.1.5-lock.patch,NONE,1.1
Zdenek Prikryl (zprikryl)
fedora-extras-commits at redhat.com
Thu Feb 28 12:44:08 UTC 2008
Author: zprikryl
Update of /cvs/extras/rpms/eject/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15408
Added Files:
eject-2.1.5-lock.patch
Log Message:
lock patch from upstream
eject-2.1.5-lock.patch:
--- NEW FILE eject-2.1.5-lock.patch ---
--- eject.c 2008-02-14 14:11:06.000000000 +0100
+++ /home/zdeny/download/eject.c 2008-02-28 12:40:09.000000000 +0100
@@ -116,6 +117,7 @@ int d_option = 0;
int f_option = 0;
int h_option = 0;
int n_option = 0;
+int i_option = 0;
int q_option = 0;
int r_option = 0;
int s_option = 0;
@@ -129,6 +131,7 @@ int m_option = 0;
int a_arg = 0;
int c_arg = 0;
int x_arg = 0;
+int i_arg = 0;
static char *programName; /* used in error messages */
/*
@@ -163,6 +165,7 @@ static void usage()
" eject [-vn] -c <slot> [<name>] -- switch discs on a CD-ROM changer\n"
" eject [-vn] -t [<name>] -- close tray\n"
" eject [-vn] -T [<name>] -- toggle tray\n"
+" eject [-vn] -i on|off|1|0 [<name>] -- toggle manual eject protection on/off\n"
" eject [-vn] -x <speed> [<name>] -- set CD-ROM max speed\n"
" eject [-vn] -X [<name>] -- list CD-ROM available speeds\n"
"Options:\n"
@@ -200,7 +203,7 @@ static void usage()
#endif
"\n"
" -n --noop -V --version\n"
-" -p --proc -m --no-unmount -T --traytoggle\n"));
+" -p --proc -m --no-unmount -T --traytoggle -i --manualeject\n"));
#endif /* GETOPTLONG */
fprintf(stderr,_(
"Parameter <name> can be a device file or a mount point.\n"
@@ -214,7 +217,7 @@ static void usage()
/* Handle command line options. */
static void parse_args(int argc, char **argv, char **device)
{
- const char *flags = "a:c:x:dfhnqrstTXvVpm";
+ const char *flags = "a:c:x:i:dfhnqrstTXvVpm";
#ifdef GETOPTLONG
static struct option long_options[] =
{
@@ -223,6 +226,7 @@ static void parse_args(int argc, char **
{"default", no_argument, NULL, 'd'},
{"auto", required_argument, NULL, 'a'},
{"changerslot", required_argument, NULL, 'c'},
+ {"manualeject", required_argument, NULL, 'i'},
{"trayclose", no_argument, NULL, 't'},
{"traytoggle", no_argument, NULL, 'T'},
{"cdspeed", required_argument, NULL, 'x'},
@@ -297,6 +301,21 @@ static void parse_args(int argc, char **
usage();
exit(0);
break;
+ 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;
case 'm':
m_option = 1;
break;
@@ -482,6 +501,30 @@ static char *FindDevice(const char *name
}
+/*
+ * 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 inserted in it's drive.
+ * Implemented as found in Documentation/ioctl/cdrom.txt
+ *
+ * TODO: 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
+ */
+static void ManualEject(int fd, int onOff)
+{
+ 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");
+ }
+}
+
+
/* Set or clear auto-eject mode. */
static void AutoEject(int fd, int onOff)
{
@@ -1227,6 +1320,13 @@ int main(int argc, char **argv)
exit(0);
}
+ /* handle -i option */
+ if (i_option) {
+ fd = OpenDevice(deviceName);
+ ManualEject(fd, i_arg);
+ exit(0);
+ }
+
/* handle -a option */
if (a_option) {
if (v_option) {
More information about the fedora-extras-commits
mailing list