Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fwsetup-ng.git;a=commitdiff;h=fa9c9304849c4ffbc58aa8f61edf648c3dd19465
commit fa9c9304849c4ffbc58aa8f61edf648c3dd19465 Author: James Buren <[email protected]> Date: Tue Oct 9 07:54:26 2012 -0500 add function for creating the extended partition diff --git a/src/block.c b/src/block.c index 5666d85..19a5eef 100644 --- a/src/block.c +++ b/src/block.c @@ -509,7 +509,39 @@ extern int disk_create_partition(struct disk *disk,long long size) disk->modified = true; - return disk->size; + return disk->size - 1; +} + +extern int disk_create_extended_partition(struct disk *disk) +{ + int i = 0; + struct partition part = {0}; + + if(disk == 0 || disk->size < 0 || disk->type != DISKTYPE_DOS) + { + errno = EINVAL; + fprintf(logfile,"%s: %s\n",__func__,strerror(errno)); + return -1; + } + + for( ; i < disk->size ; ++i ) + if(disk->table[i].dostype == DOS_EXTENDED) + { + errno = EINVAL; + fprintf(logfile,"%s: %s\n",__func__,strerror(errno)); + return -1; + } + + if(!newpartition(disk,disk->sectors,&part)) + return -1; + + part.dostype = DOS_EXTENDED; + + memcpy(&disk->table[disk->size++],&part,sizeof(struct partition)); + + disk->modified = true; + + return disk->size - 1; } extern void disk_delete_partition(struct disk *disk) _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
