Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hdio.c 957B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2009, 2010 Jeff Mahoney <jeffm@suse.com>
  3. * Copyright (c) 2011-2016 Dmitry V. Levin <ldv@altlinux.org>
  4. * Copyright (c) 2016-2018 The strace developers.
  5. * All rights reserved.
  6. *
  7. * SPDX-License-Identifier: LGPL-2.1-or-later
  8. */
  9. #include "defs.h"
  10. #include DEF_MPERS_TYPE(struct_hd_geometry)
  11. #include <linux/hdreg.h>
  12. typedef struct hd_geometry struct_hd_geometry;
  13. #include MPERS_DEFS
  14. MPERS_PRINTER_DECL(int, hdio_ioctl, struct tcb *const tcp,
  15. const unsigned int code, const kernel_ulong_t arg)
  16. {
  17. switch (code) {
  18. case HDIO_GETGEO:
  19. if (entering(tcp))
  20. return 0;
  21. else {
  22. struct_hd_geometry geo;
  23. tprints(", ");
  24. if (!umove_or_printaddr(tcp, arg, &geo))
  25. tprintf("{heads=%u, sectors=%u, "
  26. "cylinders=%hu, start=%lu}",
  27. (unsigned) geo.heads,
  28. (unsigned) geo.sectors,
  29. geo.cylinders,
  30. (unsigned long) geo.start);
  31. }
  32. break;
  33. default:
  34. return RVAL_DECODED;
  35. }
  36. return RVAL_IOCTL_DECODED;
  37. }