Anonymous avatar Anonymous committed 41d5eea

Comments (0)

Files changed (2)

 	for (current = strlist, i = 0; current && y < n; current = current->next, i++) {
 		if (i < *start)
 			continue;
-		if (current == selected && !opts & 1)
+		if (current == selected && !(opts & 1))
 			attron(A_STANDOUT);
 		move(y,0); clrtoeol();
 		temp = str_list_convert_node(current);
 		mvaddstr(y,x,temp);
 		if (temp) free(temp);
-		if (current == selected && !opts & 1)
+		if (current == selected && !(opts & 1))
 			attroff(A_STANDOUT);
 		y++;
 	}
 		
 		mvaddstr(y,col_fs,buf);
 		temp = NULL;
-		if (can_name && !free && !part->type & PED_PARTITION_EXTENDED)
+		if (can_name && !free && !(part->type & PED_PARTITION_EXTENDED))
 			temp = ped_partition_get_name(part);
 		if (!temp) temp = "";
 		snprintf(buf, SMALLBUF, "%-*s", col_size-col_label, temp);
 	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_insert(flag_name_list, ped_partition_flag_get_name(walk));
+		flag_name_list = str_list_append(flag_name_list, ped_partition_flag_get_name(walk));
 		if (!flag_name_list)
 			return 0;
 	}
 	for (walk = ped_file_system_type_get_next (NULL); walk;
 	     walk = ped_file_system_type_get_next (walk))
 	{
-		fs_type_list = str_list_insert (fs_type_list, walk->name);
+		fs_type_list = str_list_append (fs_type_list, walk->name);
 		if (walk->ops->create != NULL)
-			fs_type_mkfs = str_list_insert(fs_type_mkfs, walk->name);
+			fs_type_mkfs = str_list_append(fs_type_mkfs, walk->name);
 		//if (talk->ops->resize != NULL)
-		//	fs_type_resize = str_list_insert(fs_type_mkfs, walk->name);
+		//	fs_type_resize = str_list_append(fs_type_mkfs, walk->name);
 		if (!fs_type_list)
 			return 0;
 	}
 	for (walk = ped_disk_type_get_next (NULL); walk;
 	     walk = ped_disk_type_get_next (walk))
 	{
-		disk_type_list = str_list_insert (disk_type_list, walk->name);
+		disk_type_list = str_list_append (disk_type_list, walk->name);
 		if (!disk_type_list)
 			return 0;
 	}
 	return 1;
 }
 
-/* We need a function to get disk type-specific info about filesystem, for now only for msdos */
+/* We need a function to get disk type-specific info about filesystem */
+/* TODO: Decide if we actually need all these... I think we should leave them, at least for the 
+   msdos partition type. */
+
+/* NOTE: We will only read the first byte of the pointer, so I don't believe this can blow up
+   if someone decides to change the struct, only might begin showing wrong info. */
 typedef struct {
         unsigned char   system;
         int             boot;
         void*      orig;                   /* We don't need this */
 } DosPartitionData;
 
+/* FIXME: This could lead to problems. I rely on the belief that the struct will change as little as
+   possible. If these strings are stored in memory as I believe they are, there is almost no possibility
+   that it leads to crashes if the struct changes */
+typedef struct {
+	char		volume_name[33];	/* eg: "Games" */
+	char		system_name[33];	/* eg: "Apple_Unix_SVR2" */
+	char		processor_name[17];
+
+	int		is_boot;
+	int		is_driver;
+	int		is_root;
+	int		is_swap;
+	int		is_lvm;
+	int		is_raid;
+
+	PedSector	data_region_length;
+	PedSector	boot_region_length;
+
+	long long	boot_base_address;
+	long long	boot_entry_address;
+	int		boot_checksum;
+
+	//uint32_t	status;
+	//uint32_t	driver_sig;
+} MacPartitionData;
+
 /* FIXME: This is temporary, make it better, split data into a seperate file */
 const char*
 get_disk_specific_system_name (PedPartition* part) {
-	DosPartitionData *pdata;
 	if (!strcmp(part->disk->type->name,"msdos")) {
 		if (!part->disk_specific) return NULL;
-		pdata = (DosPartitionData *) part->disk_specific;
+		DosPartitionData *pdata = (DosPartitionData *) part->disk_specific;
 		switch (pdata->system) {
 			/* TODO: I don't like some of the strings, change them */
 			case 0x00: return NULL;//return "Empty";
 			default: return NULL;
 		}
 	}
+	else if (!strcmp(part->disk->type->name,"mac")) {
+		if (!part->disk_specific) return NULL;
+		MacPartitionData *pdata = (MacPartitionData *) part->disk_specific;
+		const char* type = pdata->system_name;
+		if (strncmp(type,"Apple_",6))
+			return NULL;
+		else {
+			int i;
+			static char buf[17];
+			for (i = 6; type[i] && i-6 < 16; i++) {
+				if (type[i] == '_')
+					buf[i-6] = ' ';
+				else
+					buf[i-6] = type[i];
+			}
+			buf[i-6] = '\0';
+			return buf;
+
+		}
+	}
 	else return NULL;
 }
 
 	int		status;
 
 	if (_can_create_primary (disk)) {
-		opts = str_list_append_unique (opts, "primary");
-		locopts = str_list_append_unique (opts, _("primary"));
+		opts = str_list_append (opts, "primary");
+		locopts = str_list_append (opts, _("primary"));
 	}
 	if (_can_create_extended (disk)) {
-		opts = str_list_append_unique (opts, "extended");
-		locopts = str_list_append_unique (opts, _("extended"));
+		opts = str_list_append (opts, "extended");
+		locopts = str_list_append (opts, _("extended"));
 	}
 	if (_can_create_logical (disk)) {
-		opts = str_list_append_unique (opts, "logical");
-		locopts = str_list_append_unique (opts, _("logical"));
+		opts = str_list_append (opts, "logical");
+		locopts = str_list_append (opts, _("logical"));
 	}
 	if (!opts) {
 		ped_exception_throw (
 			goto error;
         state = (ped_partition_get_flag (part, flag) == 0 ? 1 : 0);
         
-        if (!opts & UI_FLAG_TOGGLE) {
+        if (!(opts & UI_FLAG_TOGGLE)) {
                 if (!uiquery->getbool (_("New state"), &state))
 		            goto error;
         }
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.