Anonymous avatar Anonymous committed e3f12bd

changed ChangeLog
changed src/common.c
changed src/fdisk.c
bug-fixed in src/fdisk.c

Comments (0)

Files changed (3)

-10/04/2008 <mail.kristian@yahoo.it>
+10/17/2008 Christian <mail.kristian@yahoo.it>
+
+	* common.c: new global `compat_mode'.
+	* common.c: make get_position show `or +size%' when not `compat_mode'
+	* fdisk.c: use `compat_mode' rather than `fdisk_compatibility_mode'.
+	
+10/16/2008 Christian <mail.kristian@yahoo.it>
+
+	* fdisk.c: do_mkpart bug-fixed.
+	
+10/04/2008 Christian <mail.kristian@yahoo.it>
+
 	* ui.c: Add termcap initialization routine.
-09/28/2008 <mail.kristian@yahoo.it>
+	
+09/28/2008 Christian <mail.kristian@yahoo.it>
+
 	* Completed readline support.
 	* Better command line option handling.
 	* Add getopt module from GNU Lib.
 
 #define SMALLBUF 256
 
+/* Christian <mail.kristian@yahoo.it> 
+ *
+ * This variable is global and referred from fdisk.c and cfdisk.c.
+ * Value of this variable is zero when extensions must be avaiable,
+ * othervise code must be compatible with linux fdisk and cfdisk. 
+ */
+
+int compat_mode = 1; /* Start compatible with fdisk and cfdisk */
+
 /* Here we store the struct with interface functions */
 static UICalls *uiquery;
 
 static int MEGABYTE_SECTORS (PedDevice* dev)
 {
-        return PED_MEGABYTE_SIZE / dev->sector_size;
+  return PED_MEGABYTE_SIZE / dev->sector_size;
 }
 
 
 int
 init_flag_str ()
 {
-	PedPartitionFlag walk;
-	flag_name_list = NULL;
-	for (walk = ped_partition_flag_next(0); walk; walk =ped_partition_flag_next(walk)) {
-		flag_name_list = str_list_append(flag_name_list, ped_partition_flag_get_name(walk));
-		if (!flag_name_list)
-			return 0;
-	}
-	return 1;
+  PedPartitionFlag walk;
+  flag_name_list = NULL;
+  for (walk = ped_partition_flag_next(0); 
+       walk; walk =ped_partition_flag_next(walk)) 
+    {
+      flag_name_list = 
+	str_list_append(flag_name_list, ped_partition_flag_get_name(walk));
+      if (!flag_name_list)
+	return 0;
+    }
+  return 1;
 }
 
 int
   if (ped_unit_get_default() == PED_UNIT_CYLINDER) 
     { 
       start = _("First cylinder");
-      end = _("Last cylinder or +size or +sizeMB or +sizeKB");
+      end = 
+	(compat_mode == 0) ? 
+	    _("Last cilynder or +size or +sizeMB or +sizeKB or +size%")
+	  : _("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");
+      end = 
+	(compat_mode == 0) ?
+	  _("Last sector or +size or +sizeMB or +sizeKB or +size%")
+	: _("Last sector or +size or +sizeMB or +sizeKB");
     }
   else {
     start = _("Start");
 extern void init_termcap_library(void);
 #endif
 
+/* Christian <mail.kristian@yahoo.it>
+ *
+ * This is defined in `common.c' and used from common function
+ * to say if compatible mode should be used.
+ *
+ * A value of 0 mean that extended mode should be used.
+ * A value not equal to zero mean that extensions must be excluded 
+ *
+ * Future changes can make labels for various levels of compatibility */
+extern int compat_mode;
+
 /* minimum amount of free space to leave, or maximum amount to gobble up,
  * depending on your POV ;)
  */
 };
 
 
-/* String to use whit getopt() or getopt_long() if you update extd_options[] you must
- * also add option in short form to this string
-   NOTE: I will make function to build dynamic in the future */
+/* String to use whit getopt() or getopt_long()
+ *
+ * if you update extd_options[] you must also add option in short form
+ * to this string 
+ *
+ * NOTE: I will make function to build dynamic in the future */
 static const char* short_option_string = "hlipvLGs:utb:C:H:S:r";
 
-#ifdef GNU_EXT
-int fdisk_compatibility_mode = 0;
-#else
-#define fdisk_compatibility_mode 1
-#endif
+
+
+/* #ifdef GNU_EXT */
+/* int fdisk_compatibility_mode = 0; */
+/* #else */
+/* # define compat_mode 1 */
+/* #endif */
+
 int fdisk_opt_script_mode;
 int fdisk_list_table = 0;
 int fdisk_print_raw = 0;
 		fs_type = NULL;
 	}
 	/* gfdisk should ask for filesystem, lfdisk should not */
-	else if (!fdisk_compatibility_mode) {
+	else if (!compat_mode) {
 		if (!get_fs_type (_("File system type"),
 					       &fs_type, 0))
 			return 0;
 
 	/* if (!fdisk_compatibility_mode && fs_typ->ops->create && */
 
-	if (!fdisk_compatibility_mode && fs_type && fs_type->ops->create &&
+	if (!compat_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?")))
 			   we are in gfdisk, we warn the user about it */
 			else if (!is_bsd_partition((*disk)->dev->path,
 				part->geom.start * sect_size, sect_size) &&
-				(!fdisk_compatibility_mode)) {
+				(!compat_mode)) {
 				if (ped_exception_throw(PED_EXCEPTION_WARNING,
 				                        PED_EXCEPTION_YES_NO,
 				     _("There is a BSD partition on the disk, "
 
 	/* TODO: Make this output the same output as util-linux fdisk(?),
 	   possibly split into seperate functions */
-	if (fdisk_compatibility_mode && !strcmp((*disk)->type->name,"bsd")) {
+	if (compat_mode && !strcmp((*disk)->type->name,"bsd")) {
 		printf ("%s %+10s %+11s %+11s %+4s %+7s ", _("#   "),
 		      _("start"), _("end"), _("blocks"), _("id"), _("system"));
 		printf ("\n");
 
 	  	if (unit == PED_UNIT_SECTOR) {
 			/* In Linux fdisk compatibility mode, display exact */
-			if (fdisk_compatibility_mode) {
+			if (compat_mode) {
 				start = part->geom.start;
 				end = part->geom.end;
 			}
 	       		continue;
 
 
-		if (fdisk_compatibility_mode && !strcmp((*disk)->type->name,"bsd")) {
+		if (compat_mode && !strcmp((*disk)->type->name,"bsd")) {
 			printf("  %c: ", 'a' + part->num - 1);
 		}
 		else {
 		printf ("\n");
 		start = end = blocks = 0;
 		/* At the end we check the partition consistency for lfdisk */
-		if (fdisk_compatibility_mode)
+		if (compat_mode)
 			check_partition_consistency(part);
 	}
 	ped_free (cyl_size);
 _init_ex_menu_commands () {
 
 
-  if (!fdisk_compatibility_mode)
+  if (!compat_mode)
   {
 
 	fdisk_command_register (
 
 
   }
-  if (fdisk_compatibility_mode)
+  if (compat_mode)
 	fdisk_command_register (fdisk_ex_menu_commands, fdisk_command_create (
 		str_list_create_unique ("b", _("b"), NULL),
 		do_move_partition_beginning,
 _(" b   move beginning of data in a partition"),
 NULL), NULL, 1));
 
-  if (fdisk_compatibility_mode)
+  if (compat_mode)
 	fdisk_command_register (fdisk_ex_menu_commands, fdisk_command_create (
 		str_list_create_unique ("c", _("c"), NULL),
 		do_change_cylinders,
 _(" c   change number of cylinders"),
 NULL), NULL, 1));
 
-  if (fdisk_compatibility_mode)
+  if (compat_mode)
 	fdisk_command_register (fdisk_ex_menu_commands, fdisk_command_create (
 		str_list_create_unique ("e", _("e"), NULL),
 		do_eprint,
 _(" g   create an IRIX (SGI) partition table"),
 NULL), NULL, 1));
 
-  if (fdisk_compatibility_mode)
+  if (compat_mode)
   {
 	fdisk_command_register (fdisk_ex_menu_commands, fdisk_command_create (
 		str_list_create_unique ("h", _("h"), NULL),
 _(" m   print this menu"),
 NULL), NULL, 1));
  }
-  if (fdisk_compatibility_mode)
+  if (compat_mode)
 	fdisk_command_register (fdisk_ex_menu_commands, fdisk_command_create (
 		str_list_create_unique ("p", _("p"), NULL),
 		do_xprint,
 _(" r   return to the main menu"),
 NULL), NULL, 1));
 
-  if (fdisk_compatibility_mode)
+  if (compat_mode)
 	fdisk_command_register (fdisk_ex_menu_commands, fdisk_command_create (
 		str_list_create_unique ("s", _("s"), NULL),
 		do_change_sectors,
 _(" s   change number of sectors/track"),
 NULL), NULL, 1));
 
-  if (fdisk_compatibility_mode)
+  if (compat_mode)
 	fdisk_command_register (fdisk_ex_menu_commands, fdisk_command_create (
 		str_list_create_unique ("v", _("v"), NULL),
 		do_verify,
 _(" u   change display/entry units"),
 NULL), NULL, 1));
 
-  if (fdisk_compatibility_mode)
+  if (compat_mode)
 	fdisk_command_register (fdisk_main_menu_commands, fdisk_command_create (
 		str_list_create_unique ("v", _("v"), NULL),
 		do_verify,
 	  break;
 #ifdef GNU_EXT
 	case 'G':
-	  fdisk_compatibility_mode = 0;
+	  compat_mode = 0;
 	  break;
 	case 'L':
-	  fdisk_compatibility_mode = 1;
+	  compat_mode = 1;
 	  break;
 #endif
 	case 's':
 	}
       /* If sector size, cylnders, heads or sectors are specified on
 	 the command line */
-      if (fdisk_compatibility_mode) 
+      if (compat_mode) 
 	{
 	  if (user_sectsize) 
 	    {
 {
   PedDevice*	dev;
 
+
+  /* Christian <mail.kristian@yahoo.it>
+   * 
+   * Before global `compat_mode' fdisk use a variable only for this
+   * file. If GNU_EXT isn't defined identifyer of this variable was
+   * defined as a macro wich expand to a value of 1 
+   */
+#if !defined GNU_EXT || !GNU_EXT 
+  compat_mode = 1; 
+#endif
+
 #ifdef ENABLE_MTRACE
   mtrace();
 #endif
 #endif
 
   _init_i18n ();
+  
   if (!fdisk_init_ui ())
     goto error;
 
 	program_name++;
       else
 	program_name = argv[0];
-      fdisk_compatibility_mode = !strcmp(program_name,"lfdisk");
+      compat_mode = !strcmp(program_name,"lfdisk");
     }
   else
-    fdisk_compatibility_mode = 0;
+    compat_mode = 0;
 #endif /* GNU_EXT */
   
   dev = _init (&argc, &argv);
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.