io-seek.lisp 767 B

1234567891011121314151617181920212223242526
  1. (in-package :hurd-translator)
  2. (def-io-interface :io-seek ((io port)
  3. (offset off-t)
  4. (whence seek-type)
  5. (newoffset :pointer))
  6. (with-lookup protid io
  7. (let ((node (get-node protid))
  8. (user (get-user protid))
  9. (open (open-node protid)))
  10. (case whence
  11. (:seek-cur
  12. (incf offset (file-offset open)))
  13. (:seek-end
  14. (incf offset (stat-get (stat node) 'st-size))))
  15. (cond
  16. ((>= offset 0)
  17. (setf (mem-ref newoffset 'loff-t) offset
  18. (file-offset open) offset)
  19. ; Warn user of pointer change
  20. (report-seek *translator* node user offset)
  21. t)
  22. (t :invalid-argument)))))