Beispiel #1
0
void optFinalize(poffHandle_t poffHandle, poffProgHandle_t poffProgHandle)
{
    /* Build label / line number reference table */

    pass1(poffHandle, poffProgHandle);

    /* Reset for next pass */

    insn_ResetOpCodeRead(poffHandle);
    insn_ResetTmpOpCodeWrite(poffProgHandle);

    /* Now process all of the symbols */

    pass2(poffHandle, poffProgHandle);

    /* Reset for next pass */

    insn_ResetOpCodeRead(poffHandle);

    /* Generate relocation information and replace all label references
     * in the code with actual program section data offsets.
     */

    pass3(poffHandle, poffProgHandle);

    /* Fixed label references in the debug function information */

    pass4(poffHandle);

    /* Reset for next pass */

    insn_ResetOpCodeRead(poffHandle);
    insn_ResetTmpOpCodeWrite(poffProgHandle);

    /* Finally, replace file header entry point with the I-space offset */

    pass5(poffHandle);

    /* Clean up after ourselves */

    poffReleaseLabelReferences();
}
Beispiel #2
0
int main(int argc, char **argv)
{
    char *buf;
    char *op;

    if(argc != 2){
        fprintf(stderr, "syntax: fsck [devfile][:offset]\n");
        return 1;
    }
    
    op = strchr(argv[1], ':');
    if (op) {
        *op++ = 0;
        offset = atol(op);
    }

    if(fd_open(argv[1])){
        printf("Cannot open file\n");
        return -1;
    }

    buf = daread(1);
    bcopy(buf, (char *) &superblock, sizeof(struct filesys));

    /* Verify the fsize and isize parameters */
    if (superblock.s_mounted == SMOUNTED_WRONGENDIAN) {
        swizzling = 1;
        printf("Checking file system with reversed byte order.\n");
    }

    if (swizzle16(superblock.s_mounted) != SMOUNTED) {
        printf("Device %d has invalid magic number %d. Fix? ", dev, superblock.s_mounted);
        if (!yes())
            exit(-1);
        superblock.s_mounted = swizzle16(SMOUNTED);
        dwrite((blkno_t) 1, (char *) &superblock);
    }
    printf("Device %d has fsize = %d and isize = %d. Continue? ",
            dev, swizzle16(superblock.s_fsize), swizzle16(superblock.s_isize));
    if (!yes())
        exit(-1);

    bitmap = calloc(swizzle16(superblock.s_fsize), sizeof(char));
    linkmap = (int16_t *) calloc(8 * swizzle16(superblock.s_isize), sizeof(int16_t));

    if (!bitmap || !linkmap) {
        fprintf(stderr, "Not enough memory.\n");
        exit(-1);
    }

    printf("Pass 1: Checking inodes...\n");
    pass1();

    printf("Pass 2: Rebuilding free list...\n");
    pass2();

    printf("Pass 3: Checking block allocation...\n");
    pass3();

    printf("Pass 4: Checking directory entries...\n");
    pass4();

    printf("Pass 5: Checking link counts...\n");
    pass5();

    printf("Done.\n");

    exit(0);
}
Beispiel #3
0
int
main (int argc, char **argv)
{
  int silent = 0, force = 0;
  char *device = 0;
  error_t parse_opt (int key, char *arg, struct argp_state *state)
    {
      switch (key)
	{
	case 'p': preen = 1; break;
	case 'y': noquery = 1; break;
	case 'n': nowrite = 1; break;
	case 'l': lfname = arg; break;
	case 'm': lfmode = strtol (arg, 0, 8); break;
	case 'f': force = 1; break;
	case 's': silent = 1; break;
	case ARGP_KEY_ARG:
	  if (!device)
	    {
	      device = arg;
	      break;
	    }
	  /* Fall through */
	case ARGP_KEY_NO_ARGS:
	  argp_usage (state);
	default:
	  return ARGP_ERR_UNKNOWN;
	}
      return 0;
    }
  struct argp argp = {options, parse_opt, args_doc};

  preen = nowrite = noquery = 0;
  argp_parse (&argp, argc, argv, 0, 0, 0);

  if (!setup (device))
    exit (1);
  
  if (preen && sblock->fs_clean && !force)
    {
      if (! silent)
	warning (0, "FILESYSTEM CLEAN");
    }
  else
    {
      if (!preen)
	printf ("** Phase 1 -- Check Blocks and Sizes\n");
      pass1 ();
  
      if (duplist)
	{
	  if (!preen)
	    printf ("** Phase 1b -- Rescan for More Duplicates\n");
	  pass1b ();
	}
  
      if (!preen)
	printf ("** Phase 2 -- Check Pathnames\n");
      pass2 ();
  
      if (!preen)
	printf ("** Phase 3 -- Check Connectivity\n");
      pass3 ();
  
      if (!preen)
	printf ("** Phase 4 -- Check Reference Counts\n");
      pass4 ();
  
      if (!preen)
	printf ("** Phase 5 -- Check Cyl Groups\n");
      pass5 ();
      
      if (! silent)
	show_stats (sblock);
    }

  if (fsmodified && !preen)
    printf ("\n***** FILE SYSTEM WAS MODIFIED *****\n");

  exit (fsmodified ? 2 : 0);
}