Anonymous avatar Anonymous committed 0a7a4a2

Bug-fixed

Comments (0)

Files changed (2)

 	def_str = ped_unit_format (dev, value->sector);
 	if (def_str)
 		input = strdup(def_str);
+	/* uiquery->getstring free input if it's not NULL */
 	uiquery->getstring(prompt,&input,NULL,NULL,1);
 
 
 static int
 get_position(PartPos* pos, PedDisk *disk, GSOpts opts)
 {
-
-	char *start;
-	char *end;
-	if (ped_unit_get_default() == PED_UNIT_CYLINDER) {
-		start = _("First cylinder");
-		end = _("Last cylinder or +size or +sizeMB or +sizeKB");
-	}
-	else if (ped_unit_get_default() == PED_UNIT_SECTOR) {
-		start = _("First sector");
-		end = _("Last sector or +size or +sizeMB or +sizeKB");
-	}
-	else {
-		start = _("Start");
-		end = _("End or +size");
-	}
-        if (!get_sector (start, disk->dev, &(pos->start), -1LL, opts))
-                return 0;
-
-	/* If we are creating a new partition and want to look where to
-           place its end ... */
-	if (opts & PLACE_END_NEWPART)
-		place_part_end(disk,pos);
-
-	/* We give the sector from the first query, so that the user can
-           specify size */
-        if (!get_sector (end, disk->dev, &(pos->end), pos->start.sector, opts))
-                return 0;
-
-	return 1;
+  char *start;
+  char *end;
+  if (ped_unit_get_default() == PED_UNIT_CYLINDER) 
+    { 
+      start = _("First cylinder");
+      end = _("Last cylinder or +size or +sizeMB or +sizeKB");
+    }
+  else if (ped_unit_get_default() == PED_UNIT_SECTOR) 
+    {
+      start = _("First sector");
+      end = _("Last sector or +size or +sizeMB or +sizeKB");
+    }
+  else {
+    start = _("Start");
+    end = _("End or +size");
+  }
+  
+  if (!get_sector (start, disk->dev, &(pos->start), -1LL, opts))
+    return 0;
+  
+  /* If we are creating a new partition and want to look where to
+     place its end ... */
+  if (opts & PLACE_END_NEWPART)
+    place_part_end(disk,pos);
+  
+  /* We give the sector from the first query, so that the user can
+     specify size */
+  if (!get_sector (end, disk->dev, &(pos->end), pos->start.sector, opts))
+    return 0;
+  
+  return 1;
 }
 
 
 	char *help;
 } extd_options[] = {
   /* name   has_arg      flag  val  help */
-	{ "help", no_argument, NULL, 'h', "displays this help message"},
-	{ "list", no_argument, NULL, 'l', "list partition table(s)"},
-	{ "raw-print", no_argument, NULL, 'r', "show the raw data in the partition table(s)"},
-	{ "size", required_argument, NULL, 's', "show partition size"},
+  { "help", no_argument, NULL, 'h', "displays this help message"},
+  { "list", no_argument, NULL, 'l', "list partition table(s)"},
+  { "raw-print", no_argument, NULL, 'r', "show the raw data in the partition table(s)"},
+  { "size", required_argument, NULL, 's', "show partition size"},
 #ifdef GNU_EXT
-	{	"linux-fdisk", no_argument, NULL, 'L', "enable Linux fdisk compatibility mode"},
-	{ "gnu-fdisk", no_argument, NULL, 'G', "disable Linux fdisk compatibility mode"},
+  {	"linux-fdisk", no_argument, NULL, 'L', "enable Linux fdisk compatibility mode"},
+  { "gnu-fdisk", no_argument, NULL, 'G', "disable Linux fdisk compatibility mode"},
 #endif /* GNU_EXT */
-	{ "interactive", no_argument, NULL, 'i', "where necessary, prompts for user intervention"},
-	{ "script", no_argument, NULL, 'p', "never prompts for user intervention"},
-	{ "sector-units", no_argument, NULL, 'u', "use sectors instead of cylinder as a default unit"},
-	{ "sector-size", required_argument, NULL, 'b', "specify the sector size in bytes"},
-	{ "cilyndres", required_argument, NULL, 'C', "specify the number of cylinders, actually does nothing"},
-	{ "heads", required_argument, NULL, 'H', "in lfdisk, specify the number of heads of the disk"},
-	{ "sectors", required_argument, NULL, 'S', "in lfdisk, specify the number of sectors per track"},
-	{ "list-partition-types", no_argument, NULL, 't', "displays a list of supported partition types"},
-	{ "version", no_argument, NULL, 'v', "displays the version"},
-
-	/* Last element must be NULL */
-	{ NULL, 0, NULL, 0, NULL}
+  { "interactive", no_argument, NULL, 'i', "where necessary, prompts for user intervention"},
+  { "script", no_argument, NULL, 'p', "never prompts for user intervention"},
+  { "sector-units", no_argument, NULL, 'u', "use sectors instead of cylinder as a default unit"},
+  { "sector-size", required_argument, NULL, 'b', "specify the sector size in bytes"},
+  { "cilyndres", required_argument, NULL, 'C', "specify the number of cylinders, actually does nothing"},
+  { "heads", required_argument, NULL, 'H', "in lfdisk, specify the number of heads of the disk"},
+  { "sectors", required_argument, NULL, 'S', "in lfdisk, specify the number of sectors per track"},
+  { "list-partition-types", no_argument, NULL, 't', "displays a list of supported partition types"},
+  { "version", no_argument, NULL, 'v', "displays the version"},
+  
+  /* Last element must be NULL */
+  { NULL, 0, NULL, 0, NULL}
 };
 
 
 	pos.start.range = NULL;
 	pos.end.range = NULL;
 
-	if (!fdisk_compatibility_mode && fs_type->ops->create &&
+	/*
+	 * Christian <mail.kristian@yahoo.it> bug-fixed:
+	 *
+	 * (gdb) c
+	 * Continuing.
+	 * Partition type
+	 *   e   extended
+	 *   p   primary partition (1-4)
+	 * e
+	 * 
+	 * Program received signal SIGSEGV, Segmentation fault.
+	 * 0x0804bb3f in do_mkpart (disk=0xbf8c4150) at fdisk.c:673
+	 * 673             if (!fdisk_compatibility_mode && fs_type->ops->create &&
+	 */
+
+	/* if (!fdisk_compatibility_mode && fs_typ->ops->create && */
+
+	if (!fdisk_compatibility_mode && fs_type && fs_type->ops->create &&
 	    part_type != PED_PARTITION_EXTENDED &&
 	    command_line_prompt_boolean_question(
 		_("Do you want to create the filesystem on the partition?")))
 	{
-		return perform_mkpartfs (*disk, &pos, part_type, fs_type,
-		                         NULL, opts | UI_WARN_COMMIT);
+	  return perform_mkpartfs (*disk, &pos, part_type, fs_type,
+				   NULL, opts | UI_WARN_COMMIT);
 	}
 	else
 	{
-		return perform_mkpart (*disk, &pos, part_type, fs_type,
-		                       NULL, opts);
+	  return perform_mkpart (*disk, &pos, part_type, fs_type,
+				 NULL, opts);
 	}
-
 }
 
 #if 0
 static int
 do_set (PedDisk** disk)
 {
-	return perform_set (*disk, NULL, 0, UI_DEFAULT);
+  return perform_set (*disk, NULL, 0, UI_DEFAULT);
 }
 
 static int
 do_toggle_boot_flag (PedDisk** disk)
 {
-
-
-	return perform_set (*disk, NULL, PED_PARTITION_BOOT, UI_FLAG_TOGGLE);
+  return perform_set (*disk, NULL, PED_PARTITION_BOOT, UI_FLAG_TOGGLE);
 }
 
 static int
 do_unit (PedDisk** disk)
 {
-
-	if (cylinder_unit) {
-		printf ("%s\n", _("Changing display/entry units to sectors"));
-		ped_unit_set_default(PED_UNIT_SECTOR);
-		cylinder_unit = 0;
-		return 1;
-	} else {
-		printf ("%s\n", _("Changing display/entry units to cylinders"));
-		ped_unit_set_default(PED_UNIT_CYLINDER);
-		cylinder_unit = 1;
-		return 1;
-	}
+  if (cylinder_unit) {
+    printf ("%s\n", _("Changing display/entry units to sectors"));
+    ped_unit_set_default(PED_UNIT_SECTOR);
+    cylinder_unit = 0;
+    return 1;
+  } else {
+    printf ("%s\n", _("Changing display/entry units to cylinders"));
+    ped_unit_set_default(PED_UNIT_CYLINDER);
+    cylinder_unit = 1;
+    return 1;
+  }
 }
 
 /*
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.