Пример #1
0
static void queue_jlog_dispose(fq_rk *qname, fqd_queue_impl_data f) {
  struct queue_jlog *d = (struct queue_jlog *)f;
  uuid_t exist;
  (void)qname;
  uuid_clear(exist);
  read_sig(d, exist);
  if(uuid_compare(d->uuid, exist) == 0) {
    /* This is my jlog queue ... I can delete it */
    fq_debug(FQ_DEBUG_IO, "jlog: removing %s\n", d->qpath);
    nftw(d->qpath, multi_unlink, 2, FTW_DEPTH);
    rmdir(d->qpath);
  }
  free(d);
}
Пример #2
0
static void queue_jlog_dispose(fq_rk *qname, fqd_queue_impl_data f)
{
  struct queue_jlog *d = (struct queue_jlog *)f;
  uuid_t exist;
  (void)qname;

  if (d == NULL) {
    /* there was likely a total failure to init this queue type
       due to file system permissions, bail
    */
    return;
  }

  uuid_clear(exist);
  read_sig(d, exist);
  if(uuid_compare(d->uuid, exist) == 0) {
    /* This is my jlog queue ... I can delete it */
    fq_debug(FQ_DEBUG_IO, "jlog: removing %s\n", d->qpath);
    nftw(d->qpath, multi_unlink, 2, FTW_DEPTH);
    rmdir(d->qpath);
  }
  free(d);
}
Пример #3
0
/*
 * Actually read the partition table elements into their
 * appropriate structure.  byte order conversion handeling included
 */
static int read_ptable(off_t offset, struct ptable_entry *table)
{
     int i;
     sig_t signature;
     u_int8_t *index, *buffer;
     fbvar_t *sectsize_var;
     unsigned sectsize;
     enum { PTABLE_OFFSET      = 446,
            BOOT_INDICATOR_OFF = 0,
            START_HEAD_OFF     = 1,
            START_SECT_OFF     = 2,
            START_CYL_OFF      = 3,
            SYS_INDICATOR_OFF  = 4,
            END_HEAD_OFF       = 5,
            END_SECT_OFF       = 6,
            END_CYL_OFF        = 7,
            SECTOR_OFFSET_OFF  = 8,
            TOTAL_SECTORS_OFF  = 12,
            CYL_MASK           = 0xC0,
            SECT_MASK          = ~CYL_MASK,
            PTABLE_SIZE        = 16
     };

     if (!table)
          return 0;

     /* get the sector size from the fatback global variable table */
     sectsize_var = get_fbvar("sectsize");
     if (!sectsize_var->val.ival) {
          display(NORMAL, "Error: sectsize set to 0!\n");
          free(sectsize_var);
          return 0;
     }
     sectsize = sectsize_var->val.ival;
     free(sectsize_var);

     buffer = emalloc(sectsize);
     if (!read_data(buffer, offset, sectsize)) {
          return 0;
     }
     index = buffer + PTABLE_OFFSET;

     /* Load partition table elements into their apropriate struct.  This may
      * seem a little cumbersome, but it is the easiest way to do it PORTABLY
      */
     for (i = 0; i < NUM_PTABLE_ENTRIES; i++) {
          index += !!i * PTABLE_SIZE;
          table[i].boot_indicator = little_endian_8(index +BOOT_INDICATOR_OFF);
          table[i].start_head = little_endian_8(index + START_HEAD_OFF);
          table[i].start_cyl = little_endian_8(index + START_CYL_OFF);
          table[i].start_cyl += (index[START_SECT_OFF] & CYL_MASK) << 2;
          table[i].start_sect = index[START_SECT_OFF] & SECT_MASK;
          table[i].sys_indicator = little_endian_8(index + SYS_INDICATOR_OFF);
          table[i].end_head = little_endian_8(index + END_HEAD_OFF);
          table[i].end_cyl = little_endian_8(index + END_CYL_OFF);
          table[i].end_cyl += (index[END_SECT_OFF] & CYL_MASK) << 2;
          table[i].end_sect = index[END_SECT_OFF] & SECT_MASK;
          table[i].offset = little_endian_32(index + SECTOR_OFFSET_OFF);
          table[i].sectors = little_endian_32(index + TOTAL_SECTORS_OFF);
     }

     signature = read_sig(&buffer[sectsize - 2]);
     free(buffer);
     return scheck_ptable(table, signature);
}