tcpConnectionMonitoring.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. * linux/fs/partitions/acorn.c
  3. *
  4. * Copyright (c) 1996-2000 Russell King.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Scan ADFS partitions on hard disk drives. Unfortunately, there
  11. * isn't a standard for partitioning drives on Acorn machines, so
  12. * every single manufacturer of SCSI and IDE cards created their own
  13. * method.
  14. */
  15. #include <linux/buffer_head.h>
  16. #include <linux/adfs_fs.h>
  17. #include "check.h"
  18. #include "acorn.h"
  19. /*
  20. * Partition types. (Oh for reusability)
  21. */
  22. #define PARTITION_RISCIX_MFM 1
  23. #define PARTITION_RISCIX_SCSI 2
  24. #define PARTITION_LINUX 9
  25. #if defined(CONFIG_ACORN_PARTITION_CUMANA) || \
  26. defined(CONFIG_ACORN_PARTITION_ADFS)
  27. static struct adfs_discrecord *
  28. adfs_partition(struct parsed_partitions *state, char *name, char *data,
  29. unsigned long first_sector, int slot)
  30. {
  31. struct adfs_discrecord *dr;
  32. unsigned int nr_sects;
  33. if (adfs_checkbblk(data))
  34. return NULL;
  35. dr = (struct adfs_discrecord *)(data + 0x1c0);
  36. if (dr->disc_size == 0 && dr->disc_size_high == 0)
  37. return NULL;
  38. nr_sects = (le32_to_cpu(dr->disc_size_high) << 23) |
  39. (le32_to_cpu(dr->disc_size) >> 9);
  40. if (name) {
  41. strlcat(state->pp_buf, " [", PAGE_SIZE);
  42. strlcat(state->pp_buf, name, PAGE_SIZE);
  43. strlcat(state->pp_buf, "]", PAGE_SIZE);
  44. }
  45. put_partition(state, slot, first_sector, nr_sects);
  46. return dr;
  47. }
  48. #endif
  49. #ifdef CONFIG_ACORN_PARTITION_RISCIX
  50. struct riscix_part {
  51. __le32 start;
  52. __le32 length;
  53. __le32 one;
  54. char name[16];
  55. };
  56. struct riscix_record {
  57. __le32 magic;
  58. #define RISCIX_MAGIC cpu_to_le32(0x4a657320)
  59. __le32 date;
  60. struct riscix_part part[8];
  61. };
  62. #if defined(CONFIG_ACORN_PARTITION_CUMANA) || \
  63. defined(CONFIG_ACORN_PARTITION_ADFS)
  64. static int riscix_partition(struct parsed_partitions *state,
  65. unsigned long first_sect, int slot,
  66. unsigned long nr_sects)
  67. {
  68. Sector sect;
  69. struct riscix_record *rr;
  70. rr = read_part_sector(state, first_sect, &sect);
  71. if (!rr)
  72. return -1;
  73. strlcat(state->pp_buf, " [RISCiX]", PAGE_SIZE);
  74. if (rr->magic == RISCIX_MAGIC) {
  75. unsigned long size = nr_sects > 2 ? 2 : nr_sects;
  76. int part;
  77. strlcat(state->pp_buf, " <", PAGE_SIZE);
  78. put_partition(state, slot++, first_sect, size);
  79. for (part = 0; part < 8; part++) {
  80. if (rr->part[part].one &&
  81. memcmp(rr->part[part].name, "All\0", 4)) {
  82. put_partition(state, slot++,
  83. le32_to_cpu(rr->part[part].start),
  84. le32_to_cpu(rr->part[part].length));
  85. strlcat(state->pp_buf, "(", PAGE_SIZE);
  86. strlcat(state->pp_buf, rr->part[part].name, PAGE_SIZE);
  87. strlcat(state->pp_buf, ")", PAGE_SIZE);
  88. }
  89. }
  90. strlcat(state->pp_buf, " >\n", PAGE_SIZE);
  91. } else {
  92. put_partition(state, slot++, first_sect, nr_sects);
  93. }
  94. put_dev_sector(sect);
  95. return slot;
  96. }
  97. #endif
  98. #endif
  99. #define LINUX_NATIVE_MAGIC 0xdeafa1de
  100. #define LINUX_SWAP_MAGIC 0xdeafab1e
  101. struct linux_part {
  102. __le32 magic;
  103. __le32 start_sect;
  104. __le32 nr_sects;
  105. };
  106. #if defined(CONFIG_ACORN_PARTITION_CUMANA) || \
  107. defined(CONFIG_ACORN_PARTITION_ADFS)
  108. static int linux_partition(struct parsed_partitions *state,
  109. unsigned long first_sect, int slot,
  110. unsigned long nr_sects)
  111. {
  112. Sector sect;
  113. struct linux_part *linuxp;
  114. unsigned long size = nr_sects > 2 ? 2 : nr_sects;
  115. strlcat(state->pp_buf, " [Linux]", PAGE_SIZE);
  116. put_partition(state, slot++, first_sect, size);
  117. linuxp = read_part_sector(state, first_sect, &sect);
  118. if (!linuxp)
  119. return -1;
  120. strlcat(state->pp_buf, " <", PAGE_SIZE);
  121. while (linuxp->magic == cpu_to_le32(LINUX_NATIVE_MAGIC) ||
  122. linuxp->magic == cpu_to_le32(LINUX_SWAP_MAGIC)) {
  123. if (slot == state->limit)
  124. break;
  125. put_partition(state, slot++, first_sect +
  126. le32_to_cpu(linuxp->start_sect),
  127. le32_to_cpu(linuxp->nr_sects));
  128. linuxp ++;
  129. }
  130. strlcat(state->pp_buf, " >", PAGE_SIZE);
  131. put_dev_sector(sect);
  132. return slot;
  133. }
  134. #endif
  135. #ifdef CONFIG_ACORN_PARTITION_CUMANA
  136. int adfspart_check_CUMANA(struct parsed_partitions *state)
  137. {
  138. unsigned long first_sector = 0;
  139. unsigned int start_blk = 0;
  140. Sector sect;
  141. unsigned char *data;
  142. char *name = "CUMANA/ADFS";
  143. int first = 1;
  144. int slot = 1;
  145. /*
  146. * Try Cumana style partitions - sector 6 contains ADFS boot block
  147. * with pointer to next 'drive'.
  148. *
  149. * There are unknowns in this code - is the 'cylinder number' of the
  150. * next partition relative to the start of this one - I'm assuming
  151. * it is.
  152. *
  153. * Also, which ID did Cumana use?
  154. *
  155. * This is totally unfinished, and will require more work to get it
  156. * going. Hence it is totally untested.
  157. */
  158. do {
  159. struct adfs_discrecord *dr;
  160. unsigned int nr_sects;
  161. data = read_part_sector(state, start_blk * 2 + 6, &sect);
  162. if (!data)
  163. return -1;
  164. if (slot == state->limit)
  165. break;
  166. dr = adfs_partition(state, name, data, first_sector, slot++);
  167. if (!dr)