device-id.lisp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. (in-package :hurd-common)
  2. (defclass <device-id> ()
  3. ((major :initform nil
  4. :initarg :major
  5. :accessor device-major
  6. :documentation "Major device number.")
  7. (minor :initform nil
  8. :initarg :minor
  9. :accessor device-minor
  10. :documentation "Minor device number."))
  11. (:documentation "Pair of major/minor device numbers representing some resources."))
  12. (defmethod get-device-integer ((device <device-id>))
  13. "Return foreign device number."
  14. (boole boole-ior
  15. (ash (device-major device) 8)
  16. (device-minor device)))
  17. (defmethod print-object ((device <device-id>) stream)
  18. (format stream "#<device-id major=~s minor=~s>"
  19. (device-major device)
  20. (device-minor device)))
  21. (defun get-major-dev (int)
  22. "Get the major device number from an integer, as major(dev) from sys/sysmacros.h"
  23. (boole boole-and
  24. (ash int -8)
  25. #xff))
  26. (defun get-minor-dev (int)
  27. "Get the minor device number from an integer, as minor(dev) from sys/sysmacros.h"
  28. (boole boole-and int #xff))