check.h 970 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <linux/pagemap.h>
  2. #include <linux/blkdev.h>
  3. /*
  4. * add_gd_partition adds a partitions details to the devices partition
  5. * description.
  6. */
  7. struct parsed_partitions {
  8. struct block_device *bdev;
  9. char name[BDEVNAME_SIZE];
  10. struct {
  11. sector_t from;
  12. sector_t size;
  13. int flags;
  14. } parts[DISK_MAX_PARTS];
  15. int next;
  16. int limit;
  17. bool access_beyond_eod;
  18. char *pp_buf;
  19. };
  20. static inline void *read_part_sector(struct parsed_partitions *state,
  21. sector_t n, Sector *p)
  22. {
  23. if (n >= get_capacity(state->bdev->bd_disk)) {
  24. state->access_beyond_eod = true;
  25. return NULL;
  26. }
  27. return read_dev_sector(state->bdev, n, p);
  28. }
  29. static inline void
  30. put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
  31. {
  32. if (n < p->limit) {
  33. char tmp[1 + BDEVNAME_SIZE + 10 + 1];
  34. p->parts[n].from = from;
  35. p->parts[n].size = size;
  36. snprintf(tmp, sizeof(tmp), " %s%d", p->name, n);
  37. strlcat(p->pp_buf, tmp, PAGE_SIZE);
  38. }
  39. }
  40. extern int warn_no_part;