Commit Graph

17 Commits

Author SHA1 Message Date
Karel Zak 92fe6e9633 eject: robust strings usage [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-07 13:43:56 +02:00
Dave Reisner 3514cc3a8f eject: return proper 0/1 from eject_cdrom()
main() expects this method to return 0 for failure and 1 for success, as
the other eject_*() methods do. Add the missing comparison of ioctl() >= 0

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-08-13 15:45:47 +02:00
Sami Kerola 0c7fd6f8f9 eject: fix shadow declaration
sys-utils/eject.c:529:11: warning: declaration of 'str' shadows a previous local [-Wshadow]
sys-utils/eject.c:506:9: warning: shadowed declaration is here [-Wshadow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-26 13:35:59 +02:00
Karel Zak e5d262eec5 eject: fix compiler warning [-Wmissing-prototypes]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-16 18:55:39 +02:00
Sami Kerola 289dcc9023 translation: unify file open error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Karel Zak d5f9b6e5fb Merge branch '2012wk23' of git://github.com/kerolasa/lelux-utiliteetit
* '2012wk23' of git://github.com/kerolasa/lelux-utiliteetit:
  lsblk: use blkdev_scsi_type_to_name()
  blkdev: add blkdev_scsi_type_to_name()
  wipefs: use symbolic value for markup mode
  eject: inform if CD-ROM drive is not ready
  docs: clean up partx.8 manual
  include: fix void pointer arithmetics warnings
  sysfs: fix printf format warnings
  build: fix unused parameter warnings
  build: fix redundant redeclaration warnings
  include: fix spurious list.h warnings
  uuidd: use output redirection which works [checkbashisms]
  blkid: fix realloc memory leak [cppcheck]
  setarch: do not use -1 as array index [cppcheck]
2012-06-15 12:44:17 +02:00
Karel Zak 8cd48d67f4 eject: cleanup umount code
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-13 15:58:16 +02:00
Karel Zak 8388bbb3df eject: don't try to use non-device path
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-13 13:55:49 +02:00
Karel Zak 566cd92c9f eject: add --no-partitions-unmount
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-13 13:46:24 +02:00
Sami Kerola f31d041aaf eject: inform if CD-ROM drive is not ready
Include file (see linux/cdrom.h lines 395 and 398) suggests ioctl() can
return CDS_NO_INFO and CDS_DRIVE_NOT_READY, which where ignored.  This
commit will tell user what is going on.

The commit will also make eject to crash in ioctl() will return
unexpected value.

Reference: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=include/linux/cdrom.h;h=dfd7f187c351440d2ffa81050e46ed2602877f73;hb=HEAD
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 22:06:05 +02:00
Karel Zak 28094b1e3c eject: allow to address device by LABEL/UUID
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-18 12:01:10 +02:00
Sami Kerola 9146de0266 eject: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-23 12:02:07 +02:00
Sami Kerola 92091356f9 eject: close open file [cppcheck]
[eject.c:498]: (error) Resource leak: f

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-10 12:21:37 +02:00
Sami Kerola 38de283e35 eject: inform why open failed
Mostly to cover common case when user does not have permission to use
eject.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-10 12:21:33 +02:00
Mike Frysinger df3449d541 eject: use CDROM_DRIVE_STATUS if available for tray toggling
One some platforms, the -T option can be unreliable (see reference bug
report for some examples).  Instead, if the kernel supports the cdrom
status ioctl, use that to ask explicitly for the current tray status
and then open/close accordingly.

The eject_cdrom() func was reworked slightly, but none of the existing
callers care about the explicit normalization to [0,1] values, so have
it return the raw value so we can convert toggle_tray() over to using
that.

Finally, now that toggle_tray() uses a lot of helper functions, drop
the check on CDROMCLOSETRAY.  The sub-functions take care of that.

Reference: https://bugs.gentoo.org/261880
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-04-10 12:21:27 +02:00
Mike Frysinger e99f842daf eject: constify array
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-04-10 12:21:19 +02:00
Karel Zak 88a3f049ec eject: use BUILD_EJECT, move to sys-utils
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-05 15:51:30 +02:00