static void sgi_write_table(void) { sgilabel->csum = 0; sgilabel->csum = SGI_SSWAP32(two_s_complement_32bit_sum( (unsigned int*)sgilabel, sizeof(*sgilabel))); assert(two_s_complement_32bit_sum( (unsigned int*)sgilabel, sizeof(*sgilabel)) == 0); if (lseek(fd, 0, SEEK_SET) < 0) fdisk_fatal(unable_to_seek); if (write(fd, sgilabel, SECTOR_SIZE) != SECTOR_SIZE) fdisk_fatal(unable_to_write); if (!strncmp((char*)sgilabel->directory[0].vol_file_name, "sgilabel", 8)) { /* * keep this habit of first writing the "sgilabel". * I never tested whether it works without (AN 981002). */ sgiinfo *info = fill_sgiinfo(); int infostartblock = SGI_SSWAP32(sgilabel->directory[0].vol_file_start); if (lseek(fd, infostartblock*SECTOR_SIZE, SEEK_SET) < 0) fdisk_fatal(unable_to_seek); if (write(fd, info, SECTOR_SIZE) != SECTOR_SIZE) fdisk_fatal(unable_to_write); free(info); } }
static void sgi_write_table(void) { sgilabel->csum = 0; sgilabel->csum = SGI_SSWAP32(two_s_complement_32bit_sum( (unsigned int*)sgilabel, sizeof(*sgilabel))); assert(two_s_complement_32bit_sum( (unsigned int*)sgilabel, sizeof(*sgilabel)) == 0); write_sector(0, sgilabel); if (is_prefixed_with((char*)sgilabel->directory[0].vol_file_name, "sgilabel")) { /* * keep this habit of first writing the "sgilabel". * I never tested whether it works without (AN 981002). */ sgiinfo *info = fill_sgiinfo(); int infostartblock = SGI_SSWAP32(sgilabel->directory[0].vol_file_start); write_sector(infostartblock, info); free(info); } }
static int sgi_write_disklabel(struct fdisk_context *cxt) { sgiinfo *info = NULL; sgilabel->csum = 0; sgilabel->csum = SSWAP32(two_s_complement_32bit_sum( (unsigned int*)sgilabel, sizeof(*sgilabel))); assert(two_s_complement_32bit_sum( (unsigned int*)sgilabel, sizeof(*sgilabel)) == 0); if (lseek(cxt->dev_fd, 0, SEEK_SET) < 0) goto err; if (write(cxt->dev_fd, sgilabel, SECTOR_SIZE) != SECTOR_SIZE) goto err; if (!strncmp((char *) sgilabel->directory[0].vol_file_name, "sgilabel", 8)) { /* * keep this habit of first writing the "sgilabel". * I never tested whether it works without (AN 981002). */ int infostartblock = SSWAP32(sgilabel->directory[0].vol_file_start); if (lseek(cxt->dev_fd, (off_t) infostartblock * SECTOR_SIZE, SEEK_SET) < 0) goto err; info = fill_sgiinfo(); if (!info) goto err; if (write(cxt->dev_fd, info, SECTOR_SIZE) != SECTOR_SIZE) goto err; } free(info); return 0; err: free(info); return -errno; }