diff options
author | Karel Zak | 2006-12-07 00:25:39 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:25:39 +0100 |
commit | 7eda085c41faa3445b4b168ce78ab18dab87d98a (patch) | |
tree | eb8da4baebd0af68fa84818d3d51b4a3714667fc /fdisk | |
parent | Imported from util-linux-2.9i tarball. (diff) | |
download | kernel-qcow2-util-linux-7eda085c41faa3445b4b168ce78ab18dab87d98a.tar.gz kernel-qcow2-util-linux-7eda085c41faa3445b4b168ce78ab18dab87d98a.tar.xz kernel-qcow2-util-linux-7eda085c41faa3445b4b168ce78ab18dab87d98a.zip |
Imported from util-linux-2.9v tarball.
Diffstat (limited to 'fdisk')
-rw-r--r-- | fdisk/Makefile | 37 | ||||
-rw-r--r-- | fdisk/README.fdisk | 2 | ||||
-rw-r--r-- | fdisk/addpart.c | 40 | ||||
-rw-r--r-- | fdisk/cfdisk.8 | 37 | ||||
-rw-r--r-- | fdisk/cfdisk.c | 1202 | ||||
-rw-r--r-- | fdisk/common.h | 8 | ||||
-rw-r--r-- | fdisk/delpart.c | 40 | ||||
-rw-r--r-- | fdisk/doc/CFdisk-Portuguese.html | 1704 | ||||
-rw-r--r-- | fdisk/doc/CFdisk-Portuguese.txt | 1236 | ||||
-rw-r--r-- | fdisk/doc/Fdisk-Portuguese.html | 1118 | ||||
-rw-r--r-- | fdisk/doc/Fdisk-Portuguese.txt | 855 | ||||
-rw-r--r-- | fdisk/fdisk.8 | 32 | ||||
-rw-r--r-- | fdisk/fdisk.c | 799 | ||||
-rw-r--r-- | fdisk/fdisk.h | 20 | ||||
-rw-r--r-- | fdisk/fdiskaixlabel.c | 13 | ||||
-rw-r--r-- | fdisk/fdiskbsdlabel.c | 150 | ||||
-rw-r--r-- | fdisk/fdisksgilabel.c | 182 | ||||
-rw-r--r-- | fdisk/fdisksgilabel.h | 1 | ||||
-rw-r--r-- | fdisk/fdisksunlabel.c | 164 | ||||
-rw-r--r-- | fdisk/fdisksunlabel.h | 2 | ||||
-rw-r--r-- | fdisk/i386_sys_types.c | 86 | ||||
-rw-r--r-- | fdisk/sfdisk.c | 718 |
22 files changed, 6860 insertions, 1586 deletions
diff --git a/fdisk/Makefile b/fdisk/Makefile index e5415acdc..873b2850d 100644 --- a/fdisk/Makefile +++ b/fdisk/Makefile @@ -3,24 +3,33 @@ # Revised: Fri Oct 6 21:02:21 1995 by r.faith@ieee.org # Copyright 1992, 1993, 1994, 1995 Rickard E. Faith (faith@cs.unc.edu) # - +include ../make_include include ../MCONFIG MAN8= SBIN= +CFDISK=cfdisk +NOTMADE= -ifneq "$(CPU)" "sparc" -# fsck and mkfs will compile, but there is no kernel support on sparc -ifneq "$(CPU)" "m68k" -MAN8:=$(MAN8) fdisk.8 cfdisk.8 sfdisk.8 -SBIN:=$(SBIN) fdisk cfdisk sfdisk +ifneq "$(HAVE_SLANG)" "yes" +ifneq "$(HAVE_NCURSES)" "yes" +CFDISK= +NOTMADE=cfdisk endif +endif + +ifeq "$(CPU)" "m68k" +# It seems the m68k people do not want *fdisk else -MAN8:=$(MAN8) fdisk.8 SBIN:=$(SBIN) fdisk +MAN8:=$(MAN8) fdisk.8 +ifneq "$(CPU)" "sparc" +SBIN:=$(SBIN) $(CFDISK) sfdisk +MAN8:=$(MAN8) cfdisk.8 sfdisk.8 +endif endif -all: $(SBIN) +all: $(SBIN) $(NOTMADE) cfdisk.o: cfdisk.c ifeq "$(HAVE_SLANG)" "yes" @@ -33,12 +42,12 @@ else endif endif -cfdisk: cfdisk.o llseek.o +cfdisk: cfdisk.o llseek.o i386_sys_types.o ifeq "$(HAVE_SLANG)" "yes" $(CC) $(LDFLAGS) $^ -o $@ $(LIBSLANG) else ifeq "$(HAVE_NCURSES)" "yes" - $(CC) $(LDFLAGS) $^ -o $@ $(LIBCURSES) -lm + $(CC) $(LDFLAGS) $^ -o $@ $(LIBCURSES) else @echo $@ not made since it requires ncurses or slang endif @@ -50,12 +59,14 @@ activate: sfdisk ln -s sfdisk activate fdisk: fdisk.o llseek.o fdiskbsdlabel.o fdisksgilabel.o fdisksunlabel.o \ - fdiskaixlabel.o + fdiskaixlabel.o i386_sys_types.o fdisk.o: fdisk.c fdisk.h fdiskbsdlabel.o: fdiskbsdlabel.c fdisk.h fdiskbsdlabel.h fdisksunlabel.o: fdisksunlabel.c fdisksunlabel.h fdisk.h fdiskaixlabel.o: fdiskaixlabel.c fdiskaixlabel.h fdisk.h -sfdisk: sfdisk.o +fdisk.o cfdisk.o sfdisk.o fdiskbsdlabel.o fdisksunlabel.o \ + fdisksgilabel.o fdiskaixlabel.o i386_sys_types.o: common.h +sfdisk: sfdisk.o i386_sys_types.o install: all $(INSTALLDIR) $(SBINDIR) @@ -65,4 +76,4 @@ install: all .PHONY: clean clean: - -rm -f *.o *~ core $(SBIN) + -rm -f *.o *~ core $(SBIN) addpart delpart diff --git a/fdisk/README.fdisk b/fdisk/README.fdisk index 86b182525..b02d6aa22 100644 --- a/fdisk/README.fdisk +++ b/fdisk/README.fdisk @@ -369,7 +369,7 @@ unless there are sectors available inside the extended partition. If space is available, you are prompted for the first cylinder: - First sector ([237]-977): _ + First cylinder ([237]-977): _ The limits are the lowest and the highest cylinders in which sectors are available in the appropriate part of the disk. The square-bracketed diff --git a/fdisk/addpart.c b/fdisk/addpart.c new file mode 100644 index 000000000..11d4305b9 --- /dev/null +++ b/fdisk/addpart.c @@ -0,0 +1,40 @@ +/* very primitive wrapper around the `add partition' ioctl */ +#include <stdio.h> +#include <fcntl.h> +#include <stdlib.h> +#include <sys/ioctl.h> +#include <linux/blkpg.h> + +int +main(int argc, char **argv){ + int fd; + struct blkpg_ioctl_arg a; + struct blkpg_partition p; + + if (argc != 5) { + fprintf(stderr, + "usage: %s diskdevice partitionnr start length\n", + argv[0]); + exit(1); + } + if ((fd = open(argv[1], O_RDONLY)) < 0) { + perror(argv[1]); + exit(1); + } + p.pno = atoi(argv[2]); + p.start = 512 * ((long long) atol(argv[3])); + p.length = 512 * ((long long) atol(argv[4])); + p.devname[0] = 0; + p.volname[0] = 0; + a.op = BLKPG_ADD_PARTITION; + a.flags = 0; + a.datalen = sizeof(p); + a.data = &p; + + if (ioctl(fd, BLKPG, &a) == -1) { + perror("BLKPG"); + exit(1); + } + + return 0; +} diff --git a/fdisk/cfdisk.8 b/fdisk/cfdisk.8 index c8391af2a..09dd54701 100644 --- a/fdisk/cfdisk.8 +++ b/fdisk/cfdisk.8 @@ -15,13 +15,14 @@ .SH NAME cfdisk \- Curses based disk partition table manipulator for Linux .SH SYNOPSIS -.BI "cfdisk [ \-avz ] [ \-c " cylinders " ] [ \-h " heads " ]" +.BI "cfdisk [ \-agvz ] [ \-c " cylinders " ] [ \-h " heads " ]" .BI "[ \-s " sectors-per-track " ] [ -P " opt " ] [ " device " ]" .SH DESCRIPTION .B cfdisk -is a curses based program for partitioning a hard disk drive. The +is a curses based program for partitioning any hard disk drive. +Typical values of the .I device -can be any one of the following: +argument are: .sp .nf .RS @@ -34,14 +35,28 @@ can be any one of the following: .RE .fi +In order to write the partition table .B cfdisk -first tries to read the geometry of the hard disk. If it fails, an -error message is displayed and +needs something called the `geometry' of the disk: the number +of `heads' and the number of `sectors per track'. Linux does not +use any geometry, so if the disk will not be accessed by other +operating systems, you can safely accept the defaults that .B cfdisk -exits. This should only happen when partitioning a SCSI drive on an -adapter without a BIOS. To correct this problem, you can set the -.IR cylinders ", " heads " and " sectors-per-track -on the command line. Next, +chooses for you. The geometry used by +.B cfdisk +is found as follows. First the partition table is examined, +to see what geometry was used by the previous program that +changed it. If the partition table is empty, or contains garbage, +or does not point at a consistent geometry, the kernel is +asked for advice. If nothing works 255 heads and 63 sectors/track +is assumed. The geometry can be overridden on the command line +or by use of the `g' command. When partitioning an empty large modern +disk, picking 255 heads and 63 sectors/track is always a good idea. +There is no need to set the number of cylinders, since +.B cfdisk +knows the disk size. + +Next, .B cfdisk tries to read the current partition table from the disk drive. If it is unable to figure out the partition table, an error is displayed and @@ -368,6 +383,10 @@ key to return to the main command line. Use an arrow cursor instead of reverse video for highlighting the current partition. .TP +.B \-g +Do not use the geometry given by the disk driver, but try to +guess a geometry from the partition table. +.TP .B \-v Print the version number and copyright. .TP diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c index 96ddbbf24..4fe759b68 100644 --- a/fdisk/cfdisk.c +++ b/fdisk/cfdisk.c @@ -29,15 +29,24 @@ * >2GB patches: Sat Feb 11 09:08:10 1995, faith@cs.unc.edu * Prettier menus: Sat Feb 11 09:08:25 1995, Janne Kukonlehto * <jtklehto@stekt.oulu.fi> - * Versions 0.8e-n: aeb@cwi.nl + * Versions 0.8e-p: aeb@cwi.nl + * Rebaptised 2.9p, following util-linux versioning. + * * Recognition of NTFS / HPFS difference inspired by patches * from Marty Leisner <leisner@sdsp.mc.xerox.com> * Exit codes by Enrique Zanardi <ezanardi@ull.es>: * 0: all went well - * 1: command line error - * 2: hardware problems [BAD_SEEK, BAD_READ, BAD_WRITE or BAD_OPEN]. - * 3: ioctl(fd, HDIO_GETGEO,...) failed [BAD_GEOMETRY]. - * 4: bad partition table on disk. [BAD_PRIMARY or BAD_LOGICAL]. + * 1: command line error, out of memory + * 2: hardware problems [Cannot open/seek/read/write disk drive]. + * 3: ioctl(fd, HDIO_GETGEO,...) failed. (Probably it is not a disk.) + * 4: bad partition table on disk. [Bad primary/logical partition]. + * + * Sat, 23 Jan 1999 19:34:45 +0100 <Vincent.Renardias@ldsol.com> + * Internationalized + provided initial French translation. + * Sat Mar 20 09:26:34 EST 1999 <acme@conectiva.com.br> + * Some more i18n. + * Sun Jul 18 03:19:42 MEST 1999 <aeb@cwi.nl> + * Terabyte-sized disks. * ****************************************************************************/ @@ -66,7 +75,10 @@ #include <sys/ioctl.h> #include <linux/types.h> #include <linux/hdreg.h> -#include <linux/fs.h> /* for BLKRRPART */ +#include <linux/fs.h> /* for BLKRRPART, BLKGETSIZE */ + +#include "nls.h" +#include "common.h" #if defined(__GNUC__) || defined(HAS_LONG_LONG) typedef long long ext2_loff_t; @@ -77,17 +89,25 @@ typedef long ext2_loff_t; extern ext2_loff_t ext2_llseek(unsigned int fd, ext2_loff_t offset, unsigned int origin); -#define VERSION "0.8n" +#include "../version.h" +#define VERSION UTIL_LINUX_VERSION #define DEFAULT_DEVICE "/dev/hda" #define ALTERNATE_DEVICE "/dev/sda" +/* With K=1024 we have `binary' megabytes, gigabytes, etc. + Some misguided hackers like that. + With K=1000 we have MB and GB that follow the standards + [SI, ATA, IEEE etc] and the disk manufacturers and the law. */ +#define K 1000 + #define LINE_LENGTH 80 #define MAXIMUM_PARTS 60 #define SECTOR_SIZE 512 -#define MAX_CYLINDERS 65535 +#define MAX_CYLINDERS 65535 /* there is no maximum anymore */ + /* the kernel max is 65535 */ #define MAX_HEADS 255 #define MAX_SECTORS 63 @@ -105,55 +125,48 @@ extern ext2_loff_t ext2_llseek(unsigned int fd, ext2_loff_t offset, #define LINUX_SWAP 0x82 #define LINUX 0x83 -#define ADD_EXISTS "This partition is already in use" -#define ADD_UNUSABLE "This partition is unusable" -#define DEL_EMPTY "Cannot delete an empty partition" -#define ID_EMPTY "Cannot change FS Type to empty" -#define ID_EXT "Cannot change FS Type to extended" -#define NEED_EXT "No room to create the extended partition" -#define NO_FLAGS "Cannot make this partition bootable" -#define NO_MORE_PARTS "No more partitions" -#define PRINT_OPEN_ERR "Cannot open file '%s'" -#define TWO_EXTENDEDS "Cannot create logical drive here -- would create two extended partitions" -#define TYPE_EMPTY "Cannot change the type of an empty partition" -#define BAD_COMMAND "Illegal command" -#define MAX_UNMAXABLE "Cannot maximize this partition" -#define BAD_OPEN "Cannot open disk drive" -#define BAD_SEEK "Cannot seek on disk drive" -#define BAD_READ "Cannot read disk drive" -#define BAD_WRITE "Cannot write disk drive" -#define BAD_GEOMETRY "Cannot read disk drive geometry" -#define BAD_PRIMARY "Bad primary partition" -#define BAD_LOGICAL "Bad logical partition" -#define BAD_CYLINDERS "Illegal cylinders value" -#define BAD_HEADS "Illegal heads value" -#define BAD_SECTORS "Illegal sectors value" -#define READONLY_WARN "Opened disk read-only - you have no permission to write" -#define WRITE_WARN "Warning!! This may destroy data on your disk!" -#define YES_NO "Please enter `yes' or `no'" -#define WRITING_PART "Writing partition table to disk..." -#define YES_WRITE "Wrote partition table to disk" -#define NO_WRITE "Did not write partition table to disk" -#define RRPART_FAILED "Wrote partition table, but re-read table failed. Reboot to update table." -#define NOT_DOS_MBR_BOOTABLE "Not precisely one primary partition is bootable. DOS MBR cannot boot this." +/* There used to be defined error messages here. However, it turns out + * that gettext cannot handle constructions like + * + * #define ADD_EXISTS _("This partition is already in use") + * ... + * print_warning(ADD_EXISTS); + * + * So, now the messages are spread over the source again. + * Another thing which gettext cannot cope with are multi-line strings: + * + * printf("Usage: + * Print version: + * cfdisk -v + * Print partition table: + * cfdisk -P{r|s|t} device + * "); + * + * (This is a commonly used gnu extension of the C syntax, but not ANSI-C.) + * Another reason to uglify the source a little. + */ + #define PRI_OR_LOG -1 #define PRIMARY -2 #define LOGICAL -3 -#define COL_ID_WIDTH 20 +#define COL_ID_WIDTH 25 #define CR '\015' #define ESC '\033' #define DEL '\177' #define BELL '\007' -/* '\014' == ^L */ -#define REDRAWKEY '\014' +#define TAB '\011' +#define REDRAWKEY '\014' /* ^L */ +#define UPKEY '\020' /* ^P */ +#define DOWNKEY '\016' /* ^N */ /* Display units */ -#define MEGABYTES 1 -#define SECTORS 2 -#define CYLINDERS 3 +#define GIGABYTES 1 +#define MEGABYTES 2 +#define SECTORS 3 +#define CYLINDERS 4 #define GS_DEFAULT -1 #define GS_ESCAPE -2 @@ -168,24 +181,6 @@ extern ext2_loff_t ext2_llseek(unsigned int fd, ext2_loff_t offset, #define round_int(d) ((double)((int)(d+0.5))) #define ceiling(d) ((double)(((d) != (int)(d)) ? (int)(d+1.0) : (int)(d))) -#define set_hsc(h,s,c,sector) \ -{ \ - s = sector % sectors + 1; \ - sector /= sectors; \ - h = sector % heads; \ - sector /= heads; \ - c = sector & 0xFF; \ - s |= (sector >> 2) & 0xC0;\ -} - -#define is_extended(x) ((x) == DOS_EXTENDED || (x) == WIN98_EXTENDED || \ - (x) == LINUX_EXTENDED) - -#define is_dos_partition(x) ((x) == 1 || (x) == 4 || (x) == 6) -#define may_have_dos_label(x) (is_dos_partition(x) \ - || (x) == 7 || (x) == 0xb || (x) == 0xc || (x) == 0xe \ - || (x) == 0x11 || (x) == 0x14 || (x) == 0x16 || (x) == 0x17) - struct partition { unsigned char boot_ind; /* 0x80 - active */ unsigned char head; /* starting head */ @@ -199,6 +194,58 @@ struct partition { unsigned char size4[4]; /* nr of sectors in partition */ }; +int heads = 0; +int sectors = 0; +int cylinders = 0; +int cylinder_size = 0; /* heads * sectors */ +int total_size = 0; /* actual_size rounded down */ +long actual_size = 0; /* set using ioctl */ + /* explicitly given user values */ +int user_heads = 0, user_sectors = 0, user_cylinders = 0; + /* kernel values; ignore the cylinders */ +int kern_heads = 0, kern_sectors = 0; + /* partition-table derived values */ +int pt_heads = 0, pt_sectors = 0; + + +void +set_hsc0(unsigned char *h, unsigned char *s, int *c, int sector) { + if (sector >= 1024*cylinder_size) + sector = 1024*cylinder_size - 1; + *s = sector % sectors + 1; + sector /= sectors; + *h = sector % heads; + sector /= heads; + *c = sector; +} + +void +set_hsc(unsigned char *h, unsigned char *s, unsigned char *c, int sector) { + int cc; + + set_hsc0(h, s, &cc, sector); + *c = cc & 0xFF; + *s |= (cc >> 2) & 0xC0; +} + +void +set_hsc_begin(struct partition *p, int sector) { + set_hsc(& p->head, & p->sector, & p->cyl, sector); +} + +void +set_hsc_end(struct partition *p, int sector) { + set_hsc(& p->end_head, & p->end_sector, & p->end_cyl, sector); +} + +#define is_extended(x) ((x) == DOS_EXTENDED || (x) == WIN98_EXTENDED || \ + (x) == LINUX_EXTENDED) + +#define is_dos_partition(x) ((x) == 1 || (x) == 4 || (x) == 6) +#define may_have_dos_label(x) (is_dos_partition(x) \ + || (x) == 7 || (x) == 0xb || (x) == 0xc || (x) == 0xe \ + || (x) == 0x11 || (x) == 0x14 || (x) == 0x16 || (x) == 0x17) + /* start_sect and nr_sects are stored little endian on all machines */ /* moreover, they are not aligned correctly */ void @@ -266,9 +313,6 @@ typedef struct { char *disk_device = DEFAULT_DEVICE; int fd; -int heads = 0; -int sectors = 0; -int cylinders = 0; int changed = FALSE; int opened = FALSE; int opentype; @@ -286,6 +330,7 @@ __sighandler_t old_SIGINT, old_SIGTERM; int arrow_cursor = FALSE; int display_units = MEGABYTES; int zero_table = FALSE; +int use_partition_table_geometry = FALSE; int print_only = 0; /* Curses screen information */ @@ -297,7 +342,7 @@ int NUM_ON_SCREEN = 1; /* Y coordinates */ int HEADER_START = 0; -int DISK_TABLE_START = 5; +int DISK_TABLE_START = 6; int WARNING_START = 23; int COMMAND_LINE_Y = 21; @@ -310,55 +355,24 @@ int LABEL_START = 54; int SIZE_START = 70; int COMMAND_LINE_X = 5; -#define NUM_PART_TYPES 256 -char *partition_type[NUM_PART_TYPES] = { - [LINUX_MINIX] = "Linux/MINIX", - [LINUX_SWAP] = "Linux Swap", - [LINUX] = "Linux", - [FREE_SPACE] = "Free Space", - [DOS_EXTENDED]= "Extended", - [LINUX_EXTENDED] = "Linux extended", - [0x01] = "DOS FAT12", - [0x02] = "XENIX root", - [0x03] = "XENIX usr", - [0x04] = "DOS FAT16", - [0x06] = "DOS FAT16 (big)", - [OS2_OR_NTFS] = "OS/2 HPFS or NTFS", - [0x08] = "AIX", - [0x09] = "AIX bootable", - [0x0A] = "OS/2 Boot Manager", - [0x0B] = "Win95 FAT32", - [0x0C] = "Win95 FAT32 (LBA)", - [0x0E] = "Win95 FAT16 (LBA)", - [0x0F] = "Win95 Extended (LBA)", - [0x11] = "Hidden DOS FAT12", - [0x14] = "Hidden DOS FAT16", - [0x16] = "Hidden DOS FAT16 (big)", - [0x17] = "Hidden OS/2 HPFS or NTFS", - [0x40] = "Venix 80286", - [0x41] = "PPC PReP boot", - [0x51] = "Novell?", - [0x52] = "Microport", - [0x63] = "GNU HURD", - [0x64] = "Novell Netware 286", - [0x65] = "Novell Netware 386", - [0x75] = "PC/IX", - [0x80] = "Old MINIX", - [0x93] = "Amoeba", - [0x94] = "Amoeba BBT", - [0xA5] = "BSD/386", - [0xA6] = "OpenBSD", - [0xA7] = "NEXTSTEP", - [0xB7] = "BSDI fs", - [0xB8] = "BSDI swap", - [0xC7] = "Syrinx", - [0xDB] = "CP/M", - [0xE1] = "DOS access", - [0xE3] = "DOS R/O", - [0xEB] = "BeOS fs", - [0xF2] = "DOS secondary", - [0xFF] = "BBT" -}; +void die_x(int ret); +void draw_screen(void); + +/* Guaranteed alloc */ +void * +xmalloc (size_t size) { + void *t; + + if (size == 0) + return NULL; + + t = malloc (size); + if (t == NULL) { + fprintf (stderr, _("%s: Out of memory!\n"), "cfdisk"); + die_x(1); + } + return t; +} /* Some libc's have their own basename() */ char *my_basename(char *devname) @@ -367,28 +381,37 @@ char *my_basename(char *devname) return s ? s+1 : devname; } +char *partition_type_name(unsigned char type) +{ + struct systypes *s = i386_sys_types; + + while(s->name && s->type != type) + s++; + return s->name; +} + char *partition_type_text(int i) { if (p_info[i].id == UNUSABLE) - return "Unusable"; + return _("Unusable"); else if (p_info[i].id == FREE_SPACE) - return "Free Space"; + return _("Free Space"); else if (p_info[i].id == LINUX) { if (!strcmp(p_info[i].fstype, "ext2")) - return "Linux ext2"; + return _("Linux ext2"); else - return "Linux"; + return _("Linux"); } else if (p_info[i].id == OS2_OR_NTFS) { if (!strncmp(p_info[i].fstype, "HPFS", 4)) - return "OS/2 HPFS"; + return _("OS/2 HPFS"); else if (!strncmp(p_info[i].ostype, "OS2", 3)) - return "OS/2 IFS"; + return _("OS/2 IFS"); else if (!p_info[i].ostype) return p_info[i].ostype; else - return "NTFS"; + return _("NTFS"); } else - return partition_type[p_info[i].id]; + return partition_type_name(p_info[i].id); } void fdexit(int ret) @@ -397,13 +420,13 @@ void fdexit(int ret) close(fd); if (changed) { - fprintf(stderr, "Disk has been changed.\n"); - fprintf(stderr, "Reboot the system to ensure the partition " - "table is correctly updated.\n"); + fprintf(stderr, _("Disk has been changed.\n")); + fprintf(stderr, _("Reboot the system to ensure the partition " + "table is correctly updated.\n")); - fprintf( stderr, "\nWARNING: If you have created or modified any\n" + fprintf( stderr, _("\nWARNING: If you have created or modified any\n" "DOS 6.x partitions, please see the cfdisk manual\n" - "page for additional information.\n" ); + "page for additional information.\n") ); } exit(ret); @@ -494,23 +517,25 @@ void print_warning(char *s) } } -void die_x(int ret); - void fatal(char *s, int ret) { - char str[LINE_LENGTH]; + char *err = _("FATAL ERROR"); if (curses_started) { - sprintf(str, "FATAL ERROR: %s", s); + char *str = xmalloc(strlen(s) + strlen(err) + 10); + /* snprintf does not compile on all libc's */ + sprintf(str, "%s: %s", err, s); + if (strlen(str) > COLS) + str[COLS] = 0; mvaddstr(WARNING_START, (COLS-strlen(str))/2, str); - sprintf(str, "Press any key to exit fdisk"); + sprintf(str, _("Press any key to exit cfdisk")); mvaddstr(WARNING_START+1, (COLS-strlen(str))/2, str); putchar(BELL); /* CTRL-G */ refresh(); (void)getch(); die_x(ret); } else { - fprintf(stderr, "FATAL ERROR: %s\n", s); + fprintf(stderr, "%s: %s\n", err, s); exit(ret); } } @@ -539,17 +564,17 @@ void die_x(int ret) void read_sector(char *buffer, int sect_num) { if (ext2_llseek(fd, ((ext2_loff_t) sect_num)*SECTOR_SIZE, SEEK_SET) < 0) - fatal(BAD_SEEK, 2); + fatal(_("Cannot seek on disk drive"), 2); if (read(fd, buffer, SECTOR_SIZE) != SECTOR_SIZE) - fatal(BAD_READ, 2); + fatal(_("Cannot read disk drive"), 2); } void write_sector(char *buffer, int sect_num) { if (ext2_llseek(fd, ((ext2_loff_t) sect_num)*SECTOR_SIZE, SEEK_SET) < 0) - fatal(BAD_SEEK, 2); + fatal(_("Cannot seek on disk drive"), 2); if (write(fd, buffer, SECTOR_SIZE) != SECTOR_SIZE) - fatal(BAD_WRITE, 2); + fatal(_("Cannot write disk drive"), 2); } void dos_copy_to_info(char *to, int tosz, char *from, int fromsz) { @@ -703,6 +728,8 @@ void remove_part(int i) p_info[p] = p_info[p+1]; num_parts--; + if (cur_part == num_parts) + cur_part--; } void insert_empty_part(int i, int first, int last) @@ -751,7 +778,7 @@ void del_part(int i) if (i < num_parts - 1) p_info[i].last_sector = p_info[i+1].first_sector - 1; else - p_info[i].last_sector = sectors*heads*cylinders - 1; + p_info[i].last_sector = total_size - 1; p_info[i].offset = 0; p_info[i].flags = 0; @@ -781,23 +808,41 @@ void del_part(int i) } int add_part(int num, int id, int flags, int first, int last, int offset, - int want_label) + int want_label, char **errmsg) { int i, pri = 0, log = 0; - if (num_parts == MAXIMUM_PARTS || - first < 0 || - first >= cylinders*heads*sectors || - last < 0 || - last >= cylinders*heads*sectors) { - return -1; /* bad start or end */ + if (num_parts == MAXIMUM_PARTS) { + *errmsg = _("Too many partitions"); + return -1; } - for (i = 0; i < num_parts; i++) + if (first < 0) { + *errmsg = _("Partition begins before sector 0"); + return -1; + } + + if (last < 0) { + *errmsg = _("Partition ends before sector 0"); + return -1; + } + + if (first >= total_size) { + *errmsg = _("Partition begins after end-of-disk"); + return -1; + } + + if (last >= total_size) { + *errmsg = _("Partition ends after end-of-disk"); + return -1; + } + + for (i = 0; i < num_parts; i++) { if (p_info[i].id > 0 && IS_PRIMARY(p_info[i].num)) pri++; else if (p_info[i].id > 0 && IS_LOGICAL(p_info[i].num)) log++; + } if (is_extended(ext_info.id) && log > 0) pri++; @@ -810,8 +855,18 @@ int add_part(int num, int id, int flags, int first, int last, int offset, for (i = 0; i < num_parts && p_info[i].last_sector < first; i++); - if (i == num_parts || p_info[i].id != FREE_SPACE - || last > p_info[i].last_sector) { + if (i < num_parts && p_info[i].id != FREE_SPACE) { + if (last < p_info[i].first_sector) + *errmsg = _("logical partitions not in disk order"); + else if (first + offset <= p_info[i].last_sector && + p_info[i].first_sector + p_info[i].offset <= last) + *errmsg = _("logical partitions overlap"); + else + *errmsg = _("enlarged logical partitions overlap"); + return -1; + } + + if (i == num_parts || last > p_info[i].last_sector) { return -1; } @@ -837,8 +892,8 @@ int add_part(int num, int id, int flags, int first, int last, int offset, if (IS_LOGICAL(num)) { if (!is_extended(ext_info.id)) { - print_warning("!!!! Internal error creating logical " - "drive with no extended partition !!!!"); + print_warning(_("!!!! Internal error creating logical " + "drive with no extended partition !!!!")); } else { /* We might have a logical partition outside of the extended * partition's range --> we have to extend the extended @@ -848,7 +903,7 @@ int add_part(int num, int id, int flags, int first, int last, int offset, */ if (first < ext_info.first_sector) { if (i < num_parts-1 && IS_PRIMARY(p_info[i+1].num)) { - print_warning(TWO_EXTENDEDS); + print_warning(_("Cannot create logical drive here -- would create two extended partitions")); return -1; } else { if (first == 0) { @@ -860,7 +915,7 @@ int add_part(int num, int id, int flags, int first, int last, int offset, } } else if (last > ext_info.last_sector) { if (i > 0 && IS_PRIMARY(p_info[i-1].num)) { - print_warning(TWO_EXTENDEDS); + print_warning(_("Cannot create logical drive here -- would create two extended partitions")); return -1; } else { ext_info.last_sector = last; @@ -976,36 +1031,57 @@ int menuUpdate( int y, int x, struct MenuItem *menuItems, int itemLength, char *available, int menuType, int current ) { int i, lmargin = x, ymargin = y; + char *mcd; + /* Print available buttons */ move( y, x ); clrtoeol(); + for( i = 0; menuItems[i].key; i++ ) { char buff[20]; int lenName; + const char *mi; + /* Search next available button */ while( menuItems[i].key && !strchr(available, menuItems[i].key) ) { i++; } if( !menuItems[i].key ) break; /* No more menu items */ + /* If selected item is not available and we have bypassed it, make current item selected */ if( current < i && menuItems[current].key < 0 ) current = i; + /* If current item is selected, highlight it */ if( current == i ) /*attron( A_REVERSE )*/ standout (); + /* Print item */ - lenName = strlen( menuItems[i].name ); - if(lenName > itemLength) - print_warning("Menu item too long. Menu may look odd."); + /* Because of a bug in gettext() we must not translate empty strings */ + if (menuItems[i].name[0]) + mi = _(menuItems[i].name); + else + mi = ""; + lenName = strlen( mi ); +#if 0 + if(lenName > itemLength || lenName >= sizeof(buff)) + print_warning(_("Menu item too long. Menu may look odd.")); +#endif + if (lenName >= sizeof(buff)) { /* truncate ridiculously long string */ + strncpy( buff, mi, sizeof(buff)-1); + buff[sizeof(buff)-1] = 0; + } else if( menuType & MENU_BUTTON ) sprintf( buff, "[%*s%-*s]", (itemLength - lenName) / 2, "", - (itemLength - lenName + 1) / 2 + lenName, menuItems[i].name ); + (itemLength - lenName + 1) / 2 + lenName, mi ); else sprintf( buff, "%*s%-*s", (itemLength - lenName) / 2, "", - (itemLength - lenName + 1) / 2 + lenName, menuItems[i].name ); + (itemLength - lenName + 1) / 2 + lenName, mi ); mvaddstr( y, x, buff ); + /* Lowlight after selected item */ if( current == i ) /*attroff( A_REVERSE )*/ standend (); + /* Calculate position for the next item */ if( menuType & MENU_VERT ) { @@ -1028,30 +1104,34 @@ int menuUpdate( int y, int x, struct MenuItem *menuItems, int itemLength, } } } + /* Print the description of selected item */ - mvaddstr( WARNING_START + 1, - (COLUMNS - strlen( menuItems[current].desc )) / 2, - menuItems[current].desc ); + mcd = _(menuItems[current].desc); + mvaddstr( WARNING_START + 1, (COLUMNS - strlen( mcd )) / 2, mcd ); return y; } -/* This function takes a list of menu items, lets the user choose one of them * - * and returns the value keyboard shortcut of the selected menu item */ +/* This function takes a list of menu items, lets the user choose one * + * and returns the value keyboard shortcut of the selected menu item */ -int menuSelect( int y, int x, struct MenuItem *menuItems, int itemLength, char *available, int menuType, int menuDefault ) +int menuSelect( int y, int x, struct MenuItem *menuItems, int itemLength, + char *available, int menuType, int menuDefault ) { int i, ylast = y, key = 0, current = menuDefault; + if( !( menuType & ( MENU_HORIZ | MENU_VERT ) ) ) { - print_warning("Menu without direction. Defaulting horizontal."); + print_warning(_("Menu without direction. Defaulting horizontal.")); menuType |= MENU_HORIZ; } + /* Make sure that the current is one of the available items */ while( !strchr(available, menuItems[current].key) ) { current ++ ; if( !menuItems[current].key ) current = 0; } + /* Repeat until allowable choice has been made */ while( !key ) { @@ -1087,67 +1167,80 @@ int menuSelect( int y, int x, struct MenuItem *menuItems, int itemLength, char * switch( getch() ) { case 'A': /* Up arrow */ - if( menuType & MENU_VERT ) - { - do { - current -- ; - if( current < 0 ) while( menuItems[current+1].key ) current ++ ; - } while( !strchr( available, menuItems[current].key ) ); - key = 0; - } - else - key = MENU_UP; + key = MENU_UP; break; case 'B': /* Down arrow */ - if( menuType & MENU_VERT ) - { - do { - current ++ ; - if( !menuItems[current].key ) current = 0 ; - } while( !strchr( available, menuItems[current].key ) ); - key = 0; - } - else - key = MENU_DOWN; + key = MENU_DOWN; break; case 'C': /* Right arrow */ - if( menuType & MENU_HORIZ ) - { - do { - current ++ ; - if( !menuItems[current].key ) - { - current = 0 ; - } - } while( !strchr( available, menuItems[current].key ) ); - key = 0; - } - else - key = MENU_RIGHT; + key = MENU_RIGHT; break; case 'D': /* Left arrow */ - if( menuType & MENU_HORIZ ) - { - do { - current -- ; - if( current < 0 ) - { - while( menuItems[current + 1].key ) current ++ ; - } - } while( !strchr( available, menuItems[current].key ) ); - key = 0; - } - else - key = MENU_LEFT; + key = MENU_LEFT; break; } } } + /* Enter equals to the keyboard shortcut of current menu item */ - if( key == 13 ) - { + if( key == CR) key = menuItems[current].key; - } + + /* Give alternatives for arrow keys in case the window manager + swallows these */ + if ( key == TAB ) + key = MENU_RIGHT; + if ( key == UPKEY ) /* ^P */ + key = MENU_UP; + if ( key == DOWNKEY ) /* ^N */ + key = MENU_DOWN; + + if (key == MENU_UP) { + if( menuType & MENU_VERT ) { + do { + current -- ; + if( current < 0 ) + while( menuItems[current+1].key ) + current ++ ; + } while( !strchr( available, menuItems[current].key )); + key = 0; + } + } + + if (key == MENU_DOWN) { + if( menuType & MENU_VERT ) { + do { + current ++ ; + if( !menuItems[current].key ) current = 0 ; + } while( !strchr( available, menuItems[current].key )); + key = 0; + } + } + + if (key == MENU_RIGHT) { + if( menuType & MENU_HORIZ ) { + do { + current ++ ; + if( !menuItems[current].key ) + current = 0 ; + } while( !strchr( available, menuItems[current].key )); + key = 0; + } + } + + if (key == MENU_LEFT) { + if( menuType & MENU_HORIZ ) { + do { + current -- ; + if( current < 0 ) { + while( menuItems[current + 1].key ) + current ++ ; + } + } while( !strchr( available, menuItems[current].key )); + key = 0; + } + } + /* Should all keys to be accepted? */ if( key && (menuType & MENU_ACCEPT_OTHERS) ) break; /* Is pressed key among acceptable ones */ @@ -1158,7 +1251,7 @@ int menuSelect( int y, int x, struct MenuItem *menuItems, int itemLength, char * { key = 0; putchar( BELL ); - print_warning("Illegal key"); + print_warning(_("Illegal key")); } } /* Clear out prompts and such */ @@ -1181,7 +1274,7 @@ void menuContinue(void) { static struct MenuItem menuContinueBtn[]= { - { 'c', "", "Press a key to continue" }, + { 'c', "", N_("Press a key to continue") }, { 0, NULL, NULL } }; @@ -1196,9 +1289,10 @@ int menuSimple(struct MenuItem *menuItems, int menuDefault) { int i, j, itemLength = 0; char available[MENU_MAX_ITEMS]; + for(i = 0; menuItems[i].key; i++) { - j = strlen( menuItems[i].name ); + j = strlen( _(menuItems[i].name) ); if( j > itemLength ) itemLength = j; available[i] = menuItems[i].key; } @@ -1221,13 +1315,15 @@ void new_part(int i) int num = -1; int num_sects = last - first + 1; int len, ext, j; + char *errmsg; + if (p_info[i].num == PRI_OR_LOG) { static struct MenuItem menuPartType[]= { - { 'p', "Primary", "Create a new primary partition" }, - { 'l', "Logical", "Create a new logical partition" }, - { ESC, "Cancel", "Don't create a partition" }, + { 'p', N_("Primary"), N_("Create a new primary partition") }, + { 'l', N_("Logical"), N_("Create a new logical partition") }, + { ESC, N_("Cancel"), N_("Don't create a partition") }, { 0, NULL, NULL } }; @@ -1243,28 +1339,30 @@ void new_part(int i) else if (p_info[i].num == LOGICAL) num = find_logical(i); else - print_warning("!!! Internal error !!!"); + print_warning(_("!!! Internal error !!!")); - sprintf(def, "%.2f", ceiling(num_sects/20.48)/100); - mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X, "Size (in MB): "); + sprintf(def, "%.2f", ceiling(num_sects/(K*0.02))/100); + mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X, _("Size (in MB): ")); if ((len = get_string(response, LINE_LENGTH, def)) <= 0 && len != GS_DEFAULT) return; else if (len > 0) { -#define num_cyls(bytes) (round_int(bytes/SECTOR_SIZE/(sectors*heads))) +#define num_cyls(bytes) (round_int(bytes/SECTOR_SIZE/cylinder_size)) for (j = 0; j < len-1 && (isdigit(response[j]) || response[j] == '.'); j++); if (toupper(response[j]) == 'K') { - num_sects = num_cyls(atof(response)*1024)*sectors*heads; + num_sects = num_cyls(atof(response)*K)*cylinder_size; } else if (toupper(response[j]) == 'M') { - num_sects = num_cyls(atof(response)*1024*1024)*sectors*heads; + num_sects = num_cyls(atof(response)*K*K)*cylinder_size; + } else if (toupper(response[j]) == 'G') { + num_sects = num_cyls(atof(response)*K*K*K)*cylinder_size; } else if (toupper(response[j]) == 'C') { - num_sects = round_int(atof(response))*sectors*heads; + num_sects = round_int(atof(response))*cylinder_size; } else if (toupper(response[j]) == 'S') { num_sects = round_int(atof(response)); } else { - num_sects = num_cyls(atof(response)*1024*1024)*sectors*heads; + num_sects = num_cyls(atof(response)*K*K)*cylinder_size; } } @@ -1278,9 +1376,9 @@ void new_part(int i) */ static struct MenuItem menuPlace[]= { - { 'b', "Beginning", "Add partition at beginning of free space" }, - { 'e', "End", "Add partition at end of free space" }, - { ESC, "Cancel", "Don't create a partition" }, + { 'b', N_("Beginning"), N_("Add partition at beginning of free space") }, + { 'e', N_("End"), N_("Add partition at end of free space") }, + { ESC, N_("Cancel"), N_("Don't create a partition") }, { 0, NULL, NULL } }; c = menuSimple( menuPlace, 0 ); @@ -1297,11 +1395,11 @@ void new_part(int i) * extended partition first. */ if ((ext = find_primary()) < 0) { - print_warning(NEED_EXT); + print_warning(_("No room to create the extended partition")); return; } (void) add_part(ext, DOS_EXTENDED, 0, first, last, - (first == 0 ? sectors : 0), 0); + (first == 0 ? sectors : 0), 0, &errmsg); first = ext_info.first_sector + ext_info.offset; } @@ -1312,14 +1410,76 @@ void new_part(int i) if (first == 0 || IS_LOGICAL(num)) offset = sectors; - (void) add_part(num, id, flags, first, last, offset, 0); + (void) add_part(num, id, flags, first, last, offset, 0, &errmsg); +} + +void get_kernel_geometry(void) +{ +#ifdef HDIO_GETGEO + struct hd_geometry geometry; + + if (!ioctl(fd, HDIO_GETGEO, &geometry)) { + kern_heads = geometry.heads; + kern_sectors = geometry.sectors; + } +#endif +} + +void get_partition_table_geometry(partition_table *bufp) +{ + struct partition *p; + int i,h,s,hh,ss; + int first = TRUE; + int bad = FALSE; + + if (bufp->p.magicflag[0] != PART_TABLE_FLAG0 || + bufp->p.magicflag[1] != PART_TABLE_FLAG1) + fatal(_("Bad signature on partition table"), 3); + + hh = ss = 0; + for (i=0; i<4; i++) { + p = &(bufp->p.part[i]); + if (p->sys_ind != 0) { + h = p->end_head + 1; + s = (p->end_sector & 077); + if (first) { + hh = h; + ss = s; + first = FALSE; + } else if (hh != h || ss != s) + bad = TRUE; + } + } + + if (!first && !bad) { + pt_heads = hh; + pt_sectors = ss; + } +} + +void decide_on_geometry(void) +{ + heads = (user_heads ? user_heads : + pt_heads ? pt_heads : + kern_heads ? kern_heads : 255); + sectors = (user_sectors ? user_sectors : + pt_sectors ? pt_sectors : + kern_sectors ? kern_sectors : 63); + cylinder_size = heads*sectors; + cylinders = actual_size/cylinder_size; + if (user_cylinders > 0 && user_cylinders <= 0x7fffffff/cylinder_size) + cylinders = user_cylinders; + + total_size = cylinder_size*cylinders; + if (total_size > actual_size) + print_warning(_("You specified more cylinders than fit on disk")); } void clear_p_info(void) { num_parts = 1; p_info[0].first_sector = 0; - p_info[0].last_sector = sectors*heads*cylinders - 1; + p_info[0].last_sector = total_size - 1; p_info[0].offset = 0; p_info[0].flags = 0; p_info[0].id = FREE_SPACE; @@ -1337,15 +1497,14 @@ void fill_p_info(void) { int pn, i, bs, bsz; struct partition *p; - struct hd_geometry geometry; partition_table buffer; partition_info tmp_ext = { 0, 0, 0, 0, FREE_SPACE, PRIMARY }; if ((fd = open(disk_device, O_RDWR)) < 0) { if ((fd = open(disk_device, O_RDONLY)) < 0) - fatal(BAD_OPEN, 2); + fatal(_("Cannot open disk drive"), 2); opentype = O_RDONLY; - print_warning(READONLY_WARN); + print_warning(_("Opened disk read-only - you have no permission to write")); if (curses_started) { refresh(); getch(); @@ -1365,23 +1524,23 @@ void fill_p_info(void) ioctl(fd, BLKFLSBUF); /* ignore errors */ /* e.g. Permission Denied */ - if (!ioctl(fd, HDIO_GETGEO, &geometry)) { - if (!heads) - heads = geometry.heads; - if (!sectors) - sectors = geometry.sectors; - if (!cylinders) - cylinders = geometry.cylinders; - } - - if (!heads || !sectors || !cylinders) - fatal(BAD_GEOMETRY, 3); /* probably a file or cdrom */ + if (ioctl(fd, BLKGETSIZE, &actual_size)) + fatal(_("Cannot get disk size"), 3); read_sector(buffer.c.b, 0); + get_kernel_geometry(); + + if (!zero_table || use_partition_table_geometry) + get_partition_table_geometry(& buffer); + + decide_on_geometry(); + clear_p_info(); if (!zero_table) { + char *errmsg = ""; + for (i = 0; i < 4; i++) { p = & buffer.p.part[i]; bs = get_start_sect(p); @@ -1389,11 +1548,13 @@ void fill_p_info(void) if (p->sys_ind > 0 && add_part(i, p->sys_ind, p->boot_ind, - ((bs <= sectors) ? 0 : bs), - bs + bsz - 1, - ((bs <= sectors) ? bs : 0), - 1)) { - fatal(BAD_PRIMARY, 4); + ((bs <= sectors) ? 0 : bs), bs + bsz - 1, + ((bs <= sectors) ? bs : 0), 1, &errmsg)) { + /* avoid snprintf - it does not exist on ancient systems */ + char *bad = _("Bad primary partition"); + char *msg = (char *) xmalloc(strlen(bad) + strlen(errmsg) + 30); + sprintf(msg, "%s %d: %s", bad, i, errmsg); + fatal(msg, 4); } if (is_extended(buffer.p.part[i].sys_ind)) tmp_ext = ext_info; @@ -1419,8 +1580,13 @@ void fill_p_info(void) if (add_part(i++, p->sys_ind, p->boot_ind, logical_sectors[logical-1], logical_sectors[logical-1] + bs + bsz - 1, - bs, 1)) - fatal(BAD_LOGICAL, 4); + bs, 1, &errmsg)) { + /* avoid snprintf */ + char *bad = _("Bad logical partition"); + char *msg = (char *) xmalloc(strlen(bad) + strlen(errmsg) + 30); + sprintf(msg, "%s %d: %s", bad, i-1, errmsg); + fatal(msg, 4); + } } for (pn = 0; @@ -1440,21 +1606,18 @@ void fill_p_info(void) void fill_part_table(struct partition *p, partition_info *pi) { - int sects; + int begin; p->boot_ind = pi->flags; p->sys_ind = pi->id; + begin = pi->first_sector + pi->offset; if (IS_LOGICAL(pi->num)) set_start_sect(p,pi->offset); else - set_start_sect(p,pi->first_sector + pi->offset); - set_nr_sects(p, pi->last_sector - (pi->first_sector+pi->offset) + 1); - sects = (((pi->first_sector+pi->offset)/(sectors*heads) > 1023) ? - heads*sectors*1024 - 1 : pi->first_sector+pi->offset); - set_hsc(p->head, p->sector, p->cyl, sects); - sects = ((pi->last_sector/(sectors*heads) > 1023) ? - heads*sectors*1024 - 1 : pi->last_sector); - set_hsc(p->end_head, p->end_sector, p->end_cyl, sects); + set_start_sect(p,begin); + set_nr_sects(p, pi->last_sector - begin + 1); + set_hsc_begin(p, begin); + set_hsc_end(p, pi->last_sector); } void fill_primary_table(partition_table *buffer) @@ -1479,7 +1642,7 @@ void fill_primary_table(partition_table *buffer) void fill_logical_table(partition_table *buffer, partition_info *pi) { struct partition *p; - int i, sects; + int i; for (i = 0; i < logical && pi->first_sector != logical_sectors[i]; i++); if (i == logical || buffer->p.magicflag[0] != PART_TABLE_FLAG0 @@ -1505,12 +1668,8 @@ void fill_logical_table(partition_table *buffer, partition_info *pi) p->sys_ind = DOS_EXTENDED; set_start_sect(p, pi->first_sector - ext_info.first_sector - ext_info.offset); set_nr_sects(p, pi->last_sector - pi->first_sector + 1); - sects = ((pi->first_sector/(sectors*heads) > 1023) ? - heads*sectors*1024 - 1 : pi->first_sector); - set_hsc(p->head, p->sector, p->cyl, sects); - sects = ((pi->last_sector/(sectors*heads) > 1023) ? - heads*sectors*1024 - 1 : pi->last_sector); - set_hsc(p->end_head, p->end_sector, p->end_cyl, sects); + set_hsc_begin(p, pi->first_sector); + set_hsc_end(p, pi->last_sector); } buffer->p.magicflag[0] = PART_TABLE_FLAG0; @@ -1526,7 +1685,7 @@ void write_part_table(void) char response[LINE_LENGTH]; if (opentype == O_RDONLY) { - print_warning(READONLY_WARN); + print_warning(_("Opened disk read-only - you have no permission to write")); refresh(); getch(); clear_warning(); @@ -1538,32 +1697,27 @@ void write_part_table(void) is_bdev = 1; if (is_bdev) { - print_warning(WRITE_WARN); + print_warning(_("Warning!! This may destroy data on your disk!")); while (!done) { mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X, - "Are you sure you want write the partition table " - "to disk? (yes or no): "); + _("Are you sure you want write the partition table " + "to disk? (yes or no): ")); len = get_string(response, LINE_LENGTH, NULL); clear_warning(); if (len == GS_ESCAPE) return; - else if (len == 2 && - toupper(response[0]) == 'N' && - toupper(response[1]) == 'O') { - print_warning(NO_WRITE); + else if (strcasecmp(response, _("no")) == 0) { + print_warning(_("Did not write partition table to disk")); return; - } else if (len == 3 && - toupper(response[0]) == 'Y' && - toupper(response[1]) == 'E' && - toupper(response[2]) == 'S') + } else if (strcasecmp(response, _("yes")) == 0) done = TRUE; else - print_warning(YES_NO); + print_warning(_("Please enter `yes' or `no'")); } clear_warning(); - print_warning(WRITING_PART); + print_warning(_("Writing partition table to disk...")); refresh(); } @@ -1588,11 +1742,11 @@ void write_part_table(void) clear_warning(); if (changed) - print_warning(YES_WRITE); + print_warning(_("Wrote partition table to disk")); else - print_warning(RRPART_FAILED); + print_warning(_("Wrote partition table, but re-read table failed. Reboot to update table.")); } else - print_warning(YES_WRITE); + print_warning(_("Wrote partition table to disk")); /* Check: unique bootable primary partition? */ ct = 0; @@ -1600,7 +1754,7 @@ void write_part_table(void) if (IS_PRIMARY(i) && p_info[i].flags == ACTIVE_FLAG) ct++; if (ct != 1) - print_warning(NOT_DOS_MBR_BOOTABLE); + print_warning(_("Not precisely one primary partition is bootable. DOS MBR cannot boot this.")); } void fp_printf(FILE *fp, char *format, ...) @@ -1658,7 +1812,7 @@ void print_raw_table(void) to_file = TRUE; } else { mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X, - "Enter filename or press RETURN to display on screen: "); + _("Enter filename or press RETURN to display on screen: ")); if ((to_file = get_string(fname, LINE_LENGTH, NULL)) < 0) return; @@ -1666,7 +1820,7 @@ void print_raw_table(void) if (to_file) { if ((fp = fopen(fname, "w")) == NULL) { char errstr[LINE_LENGTH]; - sprintf(errstr, PRINT_OPEN_ERR, fname); + sprintf(errstr, _("Cannot open file '%s'"), fname); print_warning(errstr); return; } @@ -1677,16 +1831,16 @@ void print_raw_table(void) } } - fp_printf(fp, "Disk Drive: %s\n", disk_device); + fp_printf(fp, _("Disk Drive: %s\n"), disk_device); - fp_printf(fp, "Sector 0:\n"); + fp_printf(fp, _("Sector 0:\n")); read_sector(buffer.c.b, 0); fill_primary_table(&buffer); print_file_buffer(fp, buffer.c.b); for (i = 0; i < num_parts; i++) if (IS_LOGICAL(p_info[i].num)) { - fp_printf(fp, "Sector %d:\n", p_info[i].first_sector); + fp_printf(fp, _("Sector %d:\n"), p_info[i].first_sector); read_sector(buffer.c.b, p_info[i].first_sector); fill_logical_table(&buffer, &(p_info[i])); print_file_buffer(fp, buffer.c.b); @@ -1706,27 +1860,27 @@ void print_p_info_entry(FILE *fp, partition_info *p) char part_str[40]; if (p->id == UNUSABLE) - fp_printf(fp, " None "); + fp_printf(fp, _(" None ")); else if (p->id == FREE_SPACE && p->num == PRI_OR_LOG) - fp_printf(fp, " Pri/Log"); + fp_printf(fp, _(" Pri/Log")); else if (p->id == FREE_SPACE && p->num == PRIMARY) - fp_printf(fp, " Primary"); + fp_printf(fp, _(" Primary")); else if (p->id == FREE_SPACE && p->num == LOGICAL) - fp_printf(fp, " Logical"); + fp_printf(fp, _(" Logical")); else fp_printf(fp, "%2d %-7.7s", p->num+1, - IS_LOGICAL(p->num) ? "Logical" : "Primary"); + IS_LOGICAL(p->num) ? _("Logical") : _("Primary")); fp_printf(fp, " "); fp_printf(fp, "%8d%c", p->first_sector, - ((p->first_sector/(sectors*heads)) != - ((float)p->first_sector/(sectors*heads)) ? + ((p->first_sector/cylinder_size) != + ((float)p->first_sector/cylinder_size) ? '*' : ' ')); fp_printf(fp, "%8d%c", p->last_sector, - (((p->last_sector+1)/(sectors*heads)) != - ((float)(p->last_sector+1)/(sectors*heads)) ? + (((p->last_sector+1)/cylinder_size) != + ((float)(p->last_sector+1)/cylinder_size) ? '*' : ' ')); fp_printf(fp, "%7d%c", p->offset, @@ -1738,29 +1892,29 @@ void print_p_info_entry(FILE *fp, partition_info *p) size = p->last_sector - p->first_sector + 1; fp_printf(fp, "%8d%c", size, - ((size/(sectors*heads)) != ((float)size/(sectors*heads)) ? + ((size/cylinder_size) != ((float)size/cylinder_size) ? '*' : ' ')); fp_printf(fp, " "); if (p->id == UNUSABLE) - sprintf(part_str, "%.17s", "Unusable"); + sprintf(part_str, "%.17s", _("Unusable")); else if (p->id == FREE_SPACE) - sprintf(part_str, "%.17s", "Free Space"); - else if (partition_type[p->id]) - sprintf(part_str, "%.17s (%02X)", partition_type[p->id], p->id); + sprintf(part_str, "%.17s", _("Free Space")); + else if (partition_type_name(p->id)) + sprintf(part_str, "%.17s (%02X)", partition_type_name(p->id), p->id); else - sprintf(part_str, "%.17s (%02X)", "Unknown", p->id); + sprintf(part_str, "%.17s (%02X)", _("Unknown"), p->id); fp_printf(fp, "%-22.22s", part_str); fp_printf(fp, " "); if (p->flags == ACTIVE_FLAG) - fp_printf(fp, "Boot (%02X)", p->flags); + fp_printf(fp, _("Boot (%02X)"), p->flags); else if (p->flags != 0) - fp_printf(fp, "Unknown (%02X)", p->flags); + fp_printf(fp, _("Unknown (%02X)"), p->flags); else - fp_printf(fp, "None (%02X)", p->flags); + fp_printf(fp, _("None (%02X)"), p->flags); fp_printf(fp, "\n"); } @@ -1776,7 +1930,7 @@ void print_p_info(void) to_file = TRUE; } else { mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X, - "Enter filename or press RETURN to display on screen: "); + _("Enter filename or press RETURN to display on screen: ")); if ((to_file = get_string(fname, LINE_LENGTH, NULL)) < 0) return; @@ -1784,7 +1938,7 @@ void print_p_info(void) if (to_file) { if ((fp = fopen(fname, "w")) == NULL) { char errstr[LINE_LENGTH]; - sprintf(errstr, PRINT_OPEN_ERR, fname); + sprintf(errstr, _("Cannot open file '%s'"), fname); print_warning(errstr); return; } @@ -1795,11 +1949,11 @@ void print_p_info(void) } } - fp_printf(fp, "Partition Table for %s\n", disk_device); + fp_printf(fp, _("Partition Table for %s\n"), disk_device); fp_printf(fp, "\n"); - fp_printf(fp, " First Last\n"); - fp_printf(fp, " # Type Sector Sector Offset Length Filesystem Type (ID) Flags\n"); - fp_printf(fp, "-- ------- -------- --------- ------ --------- ---------------------- ---------\n"); + fp_printf(fp, _(" First Last\n")); + fp_printf(fp, _(" # Type Sector Sector Offset Length Filesystem Type (ID) Flags\n")); + fp_printf(fp, _("-- ------- -------- --------- ------ --------- ---------------------- ---------\n")); for (i = 0; i < num_parts; i++) { if (pext && (p_info[i].first_sector >= ext_info.first_sector)) { @@ -1820,10 +1974,13 @@ void print_p_info(void) void print_part_entry(FILE *fp, int num, partition_info *pi) { int first = 0, start = 0, end = 0, size = 0; - int ss = 0, sh = 0, sc = 0; - int es = 0, eh = 0, ec = 0; + unsigned char ss, es, sh, eh; + int sc, ec; int flags = 0, id = 0; + ss = sh = es = eh = 0; + sc = ec = 0; + if (pi != NULL) { flags = pi->flags; id = pi->id; @@ -1836,20 +1993,9 @@ void print_part_entry(FILE *fp, int num, partition_info *pi) start = pi->first_sector + pi->offset; end = pi->last_sector; size = end - start + 1; - if ((start/(sectors*heads)) > 1023) - start = heads*sectors*1024 - 1; - if ((end/(sectors*heads)) > 1023) - end = heads*sectors*1024 - 1; - - ss = start % sectors + 1; - start /= sectors; - sh = start % heads; - sc = start / heads; - es = end % sectors + 1; - end /= sectors; - eh = end % heads; - ec = end / heads; + set_hsc0(&sh, &ss, &sc, start); + set_hsc0(&eh, &es, &ec, end); } fp_printf(fp, "%2d 0x%02X %4d %4d %4d 0x%02X %4d %4d %4d %8d %9d\n", @@ -1868,7 +2014,7 @@ void print_part_table(void) to_file = TRUE; } else { mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X, - "Enter filename or press RETURN to display on screen: "); + _("Enter filename or press RETURN to display on screen: ")); if ((to_file = get_string(fname, LINE_LENGTH, NULL)) < 0) return; @@ -1876,7 +2022,7 @@ void print_part_table(void) if (to_file) { if ((fp = fopen(fname, "w")) == NULL) { char errstr[LINE_LENGTH]; - sprintf(errstr, PRINT_OPEN_ERR, fname); + sprintf(errstr, _("Cannot open file '%s'"), fname); print_warning(errstr); return; } @@ -1887,11 +2033,11 @@ void print_part_table(void) } } - fp_printf(fp, "Partition Table for %s\n", disk_device); + fp_printf(fp, _("Partition Table for %s\n"), disk_device); fp_printf(fp, "\n"); - fp_printf(fp, " ---Starting--- ----Ending---- Start Number of\n"); - fp_printf(fp, " # Flags Head Sect Cyl ID Head Sect Cyl Sector Sectors\n"); - fp_printf(fp, "-- ----- ---- ---- ---- ---- ---- ---- ---- -------- ---------\n"); + fp_printf(fp, _(" ---Starting--- ----Ending---- Start Number of\n")); + fp_printf(fp, _(" # Flags Head Sect Cyl ID Head Sect Cyl Sector Sectors\n")); + fp_printf(fp, _("-- ----- ---- ---- ---- ---- ---- ---- ---- -------- ---------\n")); for (i = 0; i < 4; i++) { for (j = 0; @@ -1924,10 +2070,10 @@ void print_tables(void) static struct MenuItem menuFormat[]= { - { 'r', "Raw", "Print the table using raw data format" }, - { 's', "Sectors", "Print the table ordered by sectors" }, - { 't', "Table", "Just print the partition table" }, - { ESC, "Cancel", "Don't print the table" }, + { 'r', N_("Raw"), N_("Print the table using raw data format") }, + { 's', N_("Sectors"), N_("Print the table ordered by sectors") }, + { 't', N_("Table"), N_("Just print the partition table") }, + { ESC, N_("Cancel"), N_("Don't print the table") }, { 0, NULL, NULL } }; @@ -1952,51 +2098,50 @@ void print_tables(void) } #define END_OF_HELP "EOHS!" -#define NEW_HELP_SCREEN "SNHS!" void display_help() { char *help_text[] = { - "Help Screen for cfdisk " VERSION, + N_("Help Screen for cfdisk"), "", - "This is cfdisk, a curses based disk partitioning programs, which", - "allows you to create, delete and modify partitions on your hard", - "disk drive.", + N_("This is cfdisk, a curses based disk partitioning program, which"), + N_("allows you to create, delete and modify partitions on your hard"), + N_("disk drive."), "", - "Copyright (C) 1994-1998 Kevin E. Martin & aeb", + N_("Copyright (C) 1994-1999 Kevin E. Martin & aeb"), "", - "Command Meaning", - "------- -------", - " b Toggle bootable flag of the current partition", - " d Delete the current partition", - " g Change cylinders, heads, sectors-per-track parameters", - " WARNING: This option should only be used by people who", - " know what they are doing.", - " h Print this screen", - " m Maximize disk usage of the current partition", - " Note: This may make the partition incompatible with", - " DOS, OS/2, ...", - " n Create new partition from free space", - " p Print partition table to the screen or to a file", - " There are several different formats for the partition", - " that you can choose from:", - " r - Raw data (exactly what would be written to disk)", - " s - Table ordered by sectors", - " t - Table in raw format", - " q Quit program without writing partition table", - " t Change the filesystem type", - " u Change units of the partition size display", - " Rotates through Mb, sectors and cylinders", - " W Write partition table to disk (must enter upper case W)", - " Since this might destroy data on the disk, you must", - " either confirm or deny the write by entering `yes' or", - " `no'", - "Up Arrow Move cursor to the previous partition", - "Down Arrow Move cursor to the next partition", - "CTRL-L Redraws the screen", - " ? Print this screen", + N_("Command Meaning"), + N_("------- -------"), + N_(" b Toggle bootable flag of the current partition"), + N_(" d Delete the current partition"), + N_(" g Change cylinders, heads, sectors-per-track parameters"), + N_(" WARNING: This option should only be used by people who"), + N_(" know what they are doing."), + N_(" h Print this screen"), + N_(" m Maximize disk usage of the current partition"), + N_(" Note: This may make the partition incompatible with"), + N_(" DOS, OS/2, ..."), + N_(" n Create new partition from free space"), + N_(" p Print partition table to the screen or to a file"), + N_(" There are several different formats for the partition"), + N_(" that you can choose from:"), + N_(" r - Raw data (exactly what would be written to disk)"), + N_(" s - Table ordered by sectors"), + N_(" t - Table in raw format"), + N_(" q Quit program without writing partition table"), + N_(" t Change the filesystem type"), + N_(" u Change units of the partition size display"), + N_(" Rotates through MB, sectors and cylinders"), + N_(" W Write partition table to disk (must enter upper case W)"), + N_(" Since this might destroy data on the disk, you must"), + N_(" either confirm or deny the write by entering `yes' or"), + N_(" `no'"), + N_("Up Arrow Move cursor to the previous partition"), + N_("Down Arrow Move cursor to the next partition"), + N_("CTRL-L Redraws the screen"), + N_(" ? Print this screen"), "", - "Note: All of the commands can be entered with either upper or lower", - "case letters (except for Writes).", + N_("Note: All of the commands can be entered with either upper or lower"), + N_("case letters (except for Writes)."), END_OF_HELP }; @@ -2005,15 +2150,13 @@ void display_help() erase(); move(0, 0); - while (strcmp(help_text[cur_line], END_OF_HELP)) - if (!strcmp(help_text[cur_line], NEW_HELP_SCREEN)) { - menuContinue(); - erase(); - move(0, 0); - cur_line++; - } else - fp_printf(fp, "%s\n", help_text[cur_line++]); - + while (strcmp(help_text[cur_line], END_OF_HELP)) { + if (help_text[cur_line][0]) + fp_printf(fp, "%s\n", _(help_text[cur_line])); + else + fp_printf(fp, "\n"); + cur_line++; + } menuContinue(); } @@ -2023,15 +2166,15 @@ int change_geometry(void) int done = FALSE; char def[LINE_LENGTH]; char response[LINE_LENGTH]; - int tmp_val; + int tmp_val, max_cyls, i; while (!done) { static struct MenuItem menuGeometry[]= { - { 'c', "Cylinders", "Change cylinder geometry" }, - { 'h', "Heads", "Change head geometry" }, - { 's', "Sectors", "Change sector geometry" }, - { 'd', "Done", "Done with changing geometry" }, + { 'c', N_("Cylinders"), N_("Change cylinder geometry") }, + { 'h', N_("Heads"), N_("Change head geometry") }, + { 's', N_("Sectors"), N_("Change sector geometry") }, + { 'd', N_("Done"), N_("Done with changing geometry") }, { 0, NULL, NULL } }; move(COMMAND_LINE_Y, COMMAND_LINE_X); @@ -2042,42 +2185,47 @@ int change_geometry(void) switch (toupper( menuSimple(menuGeometry, 3) )) { case 'C': - sprintf(def, "%d", cylinders); + sprintf(def, "%ld", actual_size/cylinder_size); mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X, - "Enter the number of cylinders: "); - if (get_string(response, LINE_LENGTH, def) > 0) { + _("Enter the number of cylinders: ")); + i = get_string(response, LINE_LENGTH, def); + if (i == GS_DEFAULT) { + user_cylinders = actual_size/cylinder_size; + ret_val = TRUE; + } else if (i > 0) { tmp_val = atoi(response); - if (tmp_val > 0 && tmp_val <= MAX_CYLINDERS) { - cylinders = tmp_val; + max_cyls = 0x7fffffff / cylinder_size; + if (tmp_val > 0 && tmp_val <= max_cyls) { + user_cylinders = tmp_val; ret_val = TRUE; } else - print_warning(BAD_CYLINDERS); + print_warning(_("Illegal cylinders value")); } break; case 'H': sprintf(def, "%d", heads); mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X, - "Enter the number of heads: "); + _("Enter the number of heads: ")); if (get_string(response, LINE_LENGTH, def) > 0) { tmp_val = atoi(response); if (tmp_val > 0 && tmp_val <= MAX_HEADS) { - heads = tmp_val; + user_heads = tmp_val; ret_val = TRUE; } else - print_warning(BAD_HEADS); + print_warning(_("Illegal heads value")); } break; case 'S': sprintf(def, "%d", sectors); mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X, - "Enter the number of sectors per track: "); + _("Enter the number of sectors per track: ")); if (get_string(response, LINE_LENGTH, def) > 0) { tmp_val = atoi(response); if (tmp_val > 0 && tmp_val <= MAX_SECTORS) { - sectors = tmp_val; + user_sectors = tmp_val; ret_val = TRUE; } else - print_warning(BAD_SECTORS); + print_warning(_("Illegal sectors value")); } break; case ESC: @@ -2088,10 +2236,17 @@ int change_geometry(void) putchar(BELL); break; } + + if (ret_val) { + decide_on_geometry(); + draw_screen(); + } } if (ret_val) { - int disk_end = heads*sectors*cylinders-1; + int disk_end; + + disk_end = total_size-1; if (p_info[num_parts-1].last_sector > disk_end) { while (p_info[num_parts-1].first_sector > disk_end) { @@ -2130,34 +2285,50 @@ void change_id(int i) int num_types = 0; int num_across, num_down; int len, new_id = ((p_info[i].id == LINUX) ? LINUX_SWAP : LINUX); - int y_start, y_end; - int j, pos; + int y_start, y_end, row, row_min, row_max, row_offset, j, needmore; - for (num_types = 0, j = 1; j < NUM_PART_TYPES; j++) - if (partition_type[j]) - num_types++; + for (j = 1; i386_sys_types[j].name; j++) ; + num_types = j-1; /* do not count the Empty type */ num_across = COLS/COL_ID_WIDTH; num_down = (((float)num_types)/num_across + 1); y_start = COMMAND_LINE_Y - 1 - num_down; - if (y_start > DISK_TABLE_START+cur_part+4) - y_start = DISK_TABLE_START+cur_part+4; - y_end = y_start + num_down - 1; - - for (j = y_start - 1; j <= y_end + 1; j++) { - move(j, 0); - clrtoeol(); + if (y_start < 1) { + y_start = 1; + y_end = COMMAND_LINE_Y - 2; + } else { + if (y_start > DISK_TABLE_START+cur_part+4) + y_start = DISK_TABLE_START+cur_part+4; + y_end = y_start + num_down - 1; } - for (pos = 0, j = 1; j < NUM_PART_TYPES; j++) - if (partition_type[j]) { - move(y_start + pos % num_down, (pos/num_down)*COL_ID_WIDTH + 1); - printw("%02X %-16.16s", j, partition_type[j]); - pos++; + row_min = 1; + row_max = COMMAND_LINE_Y - 2; + row_offset = 0; + do { + for (j = y_start - 1; j <= y_end + 1; j++) { + move(j, 0); + clrtoeol(); } + needmore = 0; + for (j = 1; i386_sys_types[j].name; j++) { + row = y_start + (j-1) % num_down - row_offset; + if (row >= row_min && row <= row_max) { + move(row, ((j-1)/num_down)*COL_ID_WIDTH + 1); + printw("%02X %-20.20s", + i386_sys_types[j].type, + i386_sys_types[j].name); + } + if (row > row_max) + needmore = 1; + } + if (needmore) + menuContinue(); + row_offset += (row_max - row_min + 1); + } while(needmore); sprintf(def, "%02X", new_id); - mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X, "Enter filesystem type: "); + mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X, _("Enter filesystem type: ")); if ((len = get_string(id, 2, def)) <= 0 && len != GS_DEFAULT) return; @@ -2175,9 +2346,9 @@ void change_id(int i) } if (new_id == 0) - print_warning(ID_EMPTY); + print_warning(_("Cannot change FS Type to empty")); else if (is_extended(new_id)) - print_warning(ID_EXT); + print_warning(_("Cannot change FS Type to extended")); else p_info[i].id = new_id; } @@ -2187,6 +2358,7 @@ void draw_partition(int i) int size, j; int y = i + DISK_TABLE_START + 2 - (cur_part/NUM_ON_SCREEN)*NUM_ON_SCREEN; char *t; + double fsize; if (!arrow_cursor) { move(y, 0); @@ -2199,38 +2371,38 @@ void draw_partition(int i) "%s%d", my_basename(disk_device), p_info[i].num+1); if (p_info[i].flags) { if (p_info[i].flags == ACTIVE_FLAG) - mvaddstr(y, FLAGS_START, "Boot"); + mvaddstr(y, FLAGS_START, _("Boot")); else - mvprintw(y, FLAGS_START, "Unk(%02X)", p_info[i].flags); + mvprintw(y, FLAGS_START, _("Unk(%02X)"), p_info[i].flags); if (p_info[i].first_sector == 0 || IS_LOGICAL(p_info[i].num)) { if (p_info[i].offset != sectors) - addstr(", NC"); + addstr(_(", NC")); } else { if (p_info[i].offset != 0) - addstr(", NC"); + addstr(_(", NC")); } } else { if (p_info[i].first_sector == 0 || IS_LOGICAL(p_info[i].num)) { if (p_info[i].offset != sectors) - mvaddstr(y, FLAGS_START, "NC"); + mvaddstr(y, FLAGS_START, _("NC")); } else { if (p_info[i].offset != 0) - mvaddstr(y, FLAGS_START, "NC"); + mvaddstr(y, FLAGS_START, _("NC")); } } } mvaddstr(y, PTYPE_START, (p_info[i].id == UNUSABLE ? "" : - (IS_LOGICAL(p_info[i].num) ? "Logical" : - (p_info[i].num >= 0 ? "Primary" : - (p_info[i].num == PRI_OR_LOG ? "Pri/Log" : - (p_info[i].num == PRIMARY ? "Primary" : "Logical")))))); + (IS_LOGICAL(p_info[i].num) ? _("Logical") : + (p_info[i].num >= 0 ? _("Primary") : + (p_info[i].num == PRI_OR_LOG ? _("Pri/Log") : + (p_info[i].num == PRIMARY ? _("Primary") : _("Logical"))))))); t = partition_type_text(i); if (t) mvaddstr(y, FSTYPE_START, t); else - mvprintw(y, FSTYPE_START, "Unknown (%02X)", p_info[i].id); + mvprintw(y, FSTYPE_START, _("Unknown (%02X)"), p_info[i].id); if (p_info[i].volume_label[0]) { int l = strlen(p_info[i].volume_label); @@ -2240,15 +2412,17 @@ void draw_partition(int i) } size = p_info[i].last_sector - p_info[i].first_sector + 1; + fsize = (double) size * SECTOR_SIZE; if (display_units == SECTORS) mvprintw(y, SIZE_START, "%9d", size); else if (display_units == CYLINDERS) - mvprintw(y, SIZE_START, "%9d", size/(sectors*heads)); - else - mvprintw(y, SIZE_START, "%9.2f", ceiling(size/20.48)/100); - if (((size/(sectors*heads)) != ceiling(size/(sectors*(float)heads))) || - ((p_info[i].first_sector/(sectors*heads)) != - ceiling(p_info[i].first_sector/(sectors*heads)))) + mvprintw(y, SIZE_START, "%9d", size/cylinder_size); + else if (display_units == MEGABYTES) + mvprintw(y, SIZE_START, "%9.2f", ceiling((100*fsize)/(K*K))/100); + else if (display_units == GIGABYTES) + mvprintw(y, SIZE_START, "%9.2f", ceiling((100*fsize)/(K*K*K))/100); + if (size % cylinder_size != 0 || + p_info[i].first_sector % cylinder_size != 0) mvprintw(y, COLUMNS-1, "*"); } @@ -2279,7 +2453,7 @@ void draw_screen(void) int i; char *line; - line = (char *)malloc((COLS+1)*sizeof(char)); + line = (char *) xmalloc((COLS+1)*sizeof(char)); if (warning_last_time) { for (i = 0; i < COLS; i++) { @@ -2297,23 +2471,28 @@ void draw_screen(void) sprintf(line, "cfdisk %s", VERSION); mvaddstr(HEADER_START, (COLS-strlen(line))/2, line); - sprintf(line, "Disk Drive: %s", disk_device); + sprintf(line, _("Disk Drive: %s"), disk_device); mvaddstr(HEADER_START+2, (COLS-strlen(line))/2, line); - sprintf(line, "Heads: %d Sectors per Track: %d Cylinders: %d", - heads, sectors, cylinders); + { long long bytes = actual_size*(long long) SECTOR_SIZE; + sprintf(line, _("Size: %lld bytes"), bytes); } mvaddstr(HEADER_START+3, (COLS-strlen(line))/2, line); + sprintf(line, _("Heads: %d Sectors per Track: %d Cylinders: %d"), + heads, sectors, cylinders); + mvaddstr(HEADER_START+4, (COLS-strlen(line))/2, line); - mvaddstr(DISK_TABLE_START, NAME_START, "Name"); - mvaddstr(DISK_TABLE_START, FLAGS_START, "Flags"); - mvaddstr(DISK_TABLE_START, PTYPE_START-1, "Part Type"); - mvaddstr(DISK_TABLE_START, FSTYPE_START, "FS Type"); - mvaddstr(DISK_TABLE_START, LABEL_START+1, "[Label]"); + mvaddstr(DISK_TABLE_START, NAME_START, _("Name")); + mvaddstr(DISK_TABLE_START, FLAGS_START, _("Flags")); + mvaddstr(DISK_TABLE_START, PTYPE_START-1, _("Part Type")); + mvaddstr(DISK_TABLE_START, FSTYPE_START, _("FS Type")); + mvaddstr(DISK_TABLE_START, LABEL_START+1, _("[Label]")); if (display_units == SECTORS) - mvaddstr(DISK_TABLE_START, SIZE_START, " Sectors"); + mvaddstr(DISK_TABLE_START, SIZE_START, _(" Sectors")); else if (display_units == CYLINDERS) - mvaddstr(DISK_TABLE_START, SIZE_START, "Cylinders"); - else - mvaddstr(DISK_TABLE_START, SIZE_START, "Size (MB)"); + mvaddstr(DISK_TABLE_START, SIZE_START, _("Cylinders")); + else if (display_units == MEGABYTES) + mvaddstr(DISK_TABLE_START, SIZE_START, _("Size (MB)")); + else if (display_units == GIGABYTES) + mvaddstr(DISK_TABLE_START, SIZE_START, _("Size (GB)")); move(DISK_TABLE_START+1, 1); for (i = 1; i < COLS-1; i++) @@ -2368,17 +2547,17 @@ void do_curses_fdisk(void) static struct MenuItem menuMain[]= { - { 'b', "Bootable", "Toggle bootable flag of the current partition" }, - { 'd', "Delete", "Delete the current partition" }, - { 'g', "Geometry", "Change disk geometry (experts only)" }, - { 'h', "Help", "Print help screen" }, - { 'm', "Maximize", "Maximize disk usage of the current partition (experts only)" }, - { 'n', "New", "Create new partition from free space" }, - { 'p', "Print", "Print partition table to the screen or to a file" }, - { 'q', "Quit", "Quit program without writing partition table" }, - { 't', "Type", "Change the filesystem type (DOS, Linux, OS/2 and so on)" }, - { 'u', "Units", "Change units of the partition size display (MB, sect, cyl)" }, - { 'W', "Write", "Write partition table to disk (this might destroy data)" }, + { 'b', N_("Bootable"), N_("Toggle bootable flag of the current partition") }, + { 'd', N_("Delete"), N_("Delete the current partition") }, + { 'g', N_("Geometry"), N_("Change disk geometry (experts only)") }, + { 'h', N_("Help"), N_("Print help screen") }, + { 'm', N_("Maximize"), N_("Maximize disk usage of the current partition (experts only)") }, + { 'n', N_("New"), N_("Create new partition from free space") }, + { 'p', N_("Print"), N_("Print partition table to the screen or to a file") }, + { 'q', N_("Quit"), N_("Quit program without writing partition table") }, + { 't', N_("Type"), N_("Change the filesystem type (DOS, Linux, OS/2 and so on)") }, + { 'u', N_("Units"), N_("Change units of the partition size display (MB, sect, cyl)") }, + { 'W', N_("Write"), N_("Write partition table to disk (this might destroy data)") }, { 0, NULL, NULL } }; curses_started = 1; @@ -2424,7 +2603,7 @@ void do_curses_fdisk(void) if (p_info[cur_part].id > 0) p_info[cur_part].flags ^= 0x80; else - print_warning(NO_FLAGS); + print_warning(_("Cannot make this partition bootable")); break; case 'D': case 'd': @@ -2434,7 +2613,7 @@ void do_curses_fdisk(void) cur_part = num_parts - 1; draw_screen(); } else - print_warning(DEL_EMPTY); + print_warning(_("Cannot delete an empty partition")); break; case 'G': case 'g': @@ -2454,9 +2633,9 @@ void do_curses_fdisk(void) } else if (p_info[cur_part].offset != 0) p_info[cur_part].offset = 0; else - print_warning(MAX_UNMAXABLE); + print_warning(_("Cannot maximize this partition")); } else - print_warning(MAX_UNMAXABLE); + print_warning(_("Cannot maximize this partition")); break; case 'N': case 'n': @@ -2464,9 +2643,9 @@ void do_curses_fdisk(void) new_part(cur_part); draw_screen(); } else if (p_info[cur_part].id == UNUSABLE) - print_warning(ADD_UNUSABLE); + print_warning(_("This partition is unusable")); else - print_warning(ADD_EXISTS); + print_warning(_("This partition is already in use")); break; case 'P': case 'p': @@ -2483,16 +2662,18 @@ void do_curses_fdisk(void) change_id(cur_part); draw_screen(); } else - print_warning(TYPE_EMPTY); + print_warning(_("Cannot change the type of an empty partition")); break; case 'U': case 'u': - if (display_units == MEGABYTES) + if (display_units == GIGABYTES) + display_units = MEGABYTES; + else if (display_units == MEGABYTES) display_units = SECTORS; else if (display_units == SECTORS) display_units = CYLINDERS; else if (display_units == CYLINDERS) - display_units = MEGABYTES; + display_units = MEGABYTES; /* not yet GIGA */ draw_screen(); break; case 'W': @@ -2508,20 +2689,20 @@ void do_curses_fdisk(void) if (!draw_cursor(-1)) command = 0; else - print_warning(NO_MORE_PARTS); + print_warning(_("No more partitions")); break; case MENU_DOWN : /* Down arrow */ if (!draw_cursor(1)) command = 0; else - print_warning(NO_MORE_PARTS); + print_warning(_("No more partitions")); break; case REDRAWKEY: clear(); draw_screen(); break; default: - print_warning(BAD_COMMAND); + print_warning(_("Illegal command")); putchar(BELL); /* CTRL-G */ } } @@ -2531,24 +2712,28 @@ void do_curses_fdisk(void) void copyright(void) { - fprintf(stderr, "Copyright (C) 1994-1997 Kevin E. Martin & aeb\n"); + fprintf(stderr, _("Copyright (C) 1994-1999 Kevin E. Martin & aeb\n")); } void usage(char *prog_name) { - fprintf(stderr, "\nUsage:\n"); - fprintf(stderr, "Print version:\n"); - fprintf(stderr, "\t%s -v\n", prog_name); - fprintf(stderr, "Print partition table:\n"); - fprintf(stderr, "\t%s -P {r|s|t} [options] device\n", prog_name); - fprintf(stderr, "Interactive use:\n"); - fprintf(stderr, "\t%s [options] device\n", prog_name); - fprintf(stderr, " -Options: --a: Use arrow instead of highlighting; --z: Start with a zero partition table, instead of reading the pt from disk; --c C -h H -s S: Override the kernel's idea of the number of cylinders, - the number of heads and the number of sectors/track.\n\n"); + /* Unfortunately, xgettext does not handle multi-line strings */ + /* so, let's use explicit \n's instead */ + fprintf(stderr, _("\n" +"Usage:\n" +"Print version:\n" +" %s -v\n" +"Print partition table:\n" +" %s -P {r|s|t} [options] device\n" +"Interactive use:\n" +" %s [options] device\n" +"\n" +"Options:\n" +"-a: Use arrow instead of highlighting;\n" +"-z: Start with a zero partition table, instead of reading the pt from disk;\n" +"-c C -h H -s S: Override the kernel's idea of the number of cylinders,\n" +" the number of heads and the number of sectors/track.\n\n"), + prog_name, prog_name, prog_name); copyright(); } @@ -2559,31 +2744,36 @@ main(int argc, char **argv) int c; int i, len; - setlocale(LC_CTYPE, ""); + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); - while ((c = getopt(argc, argv, "ac:h:s:vzP:")) != EOF) + while ((c = getopt(argc, argv, "ac:gh:s:vzP:")) != EOF) switch (c) { case 'a': arrow_cursor = TRUE; break; case 'c': - cylinders = atoi(optarg); - if (cylinders <= 0 || cylinders > MAX_CYLINDERS) { - fprintf(stderr, "%s: %s\n", argv[0], BAD_CYLINDERS); + user_cylinders = cylinders = atoi(optarg); + if (cylinders <= 0) { + fprintf(stderr, "%s: %s\n", argv[0], _("Illegal cylinders value")); exit(1); } break; + case 'g': + use_partition_table_geometry = TRUE; + break; case 'h': - heads = atoi(optarg); + user_heads = heads = atoi(optarg); if (heads <= 0 || heads > MAX_HEADS) { - fprintf(stderr, "%s: %s\n", argv[0], BAD_HEADS); + fprintf(stderr, "%s: %s\n", argv[0], _("Illegal heads value")); exit(1); } break; case 's': - sectors = atoi(optarg); + user_sectors = sectors = atoi(optarg); if (sectors <= 0 || sectors > MAX_SECTORS) { - fprintf(stderr, "%s: %s\n", argv[0], BAD_SECTORS); + fprintf(stderr, "%s: %s\n", argv[0], _("Illegal sectors value")); exit(1); } break; diff --git a/fdisk/common.h b/fdisk/common.h new file mode 100644 index 000000000..d9fa4e8ec --- /dev/null +++ b/fdisk/common.h @@ -0,0 +1,8 @@ +/* common stuff for fdisk, cfdisk, sfdisk */ + +struct systypes { + unsigned char type; + char *name; +}; + +extern struct systypes i386_sys_types[]; diff --git a/fdisk/delpart.c b/fdisk/delpart.c new file mode 100644 index 000000000..8504c0223 --- /dev/null +++ b/fdisk/delpart.c @@ -0,0 +1,40 @@ +/* very primitive wrapper around the `delete partition' ioctl */ +#include <stdio.h> +#include <fcntl.h> +#include <stdlib.h> +#include <sys/ioctl.h> +#include <linux/blkpg.h> + +int +main(int argc, char **argv){ + int fd; + struct blkpg_ioctl_arg a; + struct blkpg_partition p; + + if (argc != 3) { + fprintf(stderr, + "usage: %s diskdevice partitionnr\n", + argv[0]); + exit(1); + } + if ((fd = open(argv[1], O_RDONLY)) < 0) { + perror(argv[1]); + exit(1); + } + p.pno = atoi(argv[2]); + p.start = 0; + p.length = 0; + p.devname[0] = 0; + p.volname[0] = 0; + a.op = BLKPG_DEL_PARTITION; + a.flags = 0; + a.datalen = sizeof(p); + a.data = &p; + + if (ioctl(fd, BLKPG, &a) == -1) { + perror("BLKPG"); + exit(1); + } + + return 0; +} diff --git a/fdisk/doc/CFdisk-Portuguese.html b/fdisk/doc/CFdisk-Portuguese.html new file mode 100644 index 000000000..6b699ee9b --- /dev/null +++ b/fdisk/doc/CFdisk-Portuguese.html @@ -0,0 +1,1704 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <meta name="Author" content="Gleydson Mazioli da Silva"> + <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win95; I) [Netscape]"> + <title>CFdisk-Portugues-HOWTO</title> +</head> +<body> + +<center><b><font size=+1>CFdisk-Portuguese Copyright (C) 1999 Gleydson +M. da Silva</font></b></center> + +<p><br> +<br> +<br> +<br> +<br> +<br> +<p> +<hr WIDTH="100%"> +<center> <i>Gleydson M. da Silva</i> - <b>gleydson@linuxbr.com.br</b> +<br>Versão: 1.68 +<br> +<hr WIDTH="100%"></center> + +<p><br> +<br> +<br> +<br> +<p><a NAME="Indice"></a><b><font size=+1>[ Indice ]</font></b> +<br> +<p><b><font size=+1>1</font></b> - <a href="#1">Introdução +ao CFdisk</a> +<br> <b>1.1</b> - <a href="#1.1">O que é uma partição +de disco</a> +<br> <b>1.2</b> - <a href="#1.2">O que é a Tabela de partição</a> +<br> <b>1.3</b> - <a href="#1.3">Introdução ao Particionamento +de Discos</a> +<br> <b>1.4</b> - <a href="#1.4">Identificadores utilizados neste +manual</a> +<br> <b>1.5</b> - <a href="#1.5">Identificação de discos +e partições no Sistema Linux</a> +<br> <b>1.6</b> - <a href="#1.6">Tipos de partições +de disco</a> +<br> <b>1.7</b> - <a href="#1.7">Observações sobre +o formato DOS 6.xx (FAT16)</a> +<p><b><font size=+1>2</font></b> - <a href="#2">Iniciando o programa CFdisk</a> +<br> <b>2.1</b> - <a href="#2.1">Opções de Linha de +comando</a> +<br> <b>2.2</b> - <a href="#2.2">Conhecendo a tela do CFdisk</a> +<br> <b>2.3</b> - <a href="#2.3">Descrição dos comandos</a> +<br> <b>2.3.1</b> - <a href="#2.3.1">Setas Acima/Abaixo +- Esquerda/Direita</a> +<br> <b>2.3.2</b> - <a href="#2.3.2"><CTRL>+<l></a> +<br> <b>2.3.3</b> - <a href="#2.3.3">Boot</a> +<br> <b>2.3.4</b> - <a href="#2.3.4">Delete</a> +<br> <b>2.3.5</b> - <a href="#2.3.5">Geometry</a> +<br> <b>2.3.6</b> - <a href="#2.3.6">Help</a> +<br> <b>2.3.7</b> - <a href="#2.3.7">Maximize</a> +<br> <b>2.3.8</b> - <a href="#2.3.8">New</a> +<br> <b>2.3.9</b> - <a href="#2.3.9">Print</a> +<br> <b>2.3.10</b> - <a href="#2.3.10">Quit</a> +<br> <b>2.3.11</b> - <a href="#2.3.11">Type</a> +<br> <b> 2.3.12</b> - <a href="#2.3.12">Units</a> +<br> <b>2.3.13</b> - <a href="#2.3.13">Write</a> +<p><b><font size=+1>3</font></b> - <a href="#3">Tipos de partições +compatíveis com o CFdisk</a> +<p><b><font size=+1>4</font></b> - <a href="#4">Direitos do Autor</a> +<p><b><font size=+1>5</font></b> - <a href="#5">Licenças e Garantias +sobre este documento</a> +<p><b><font size=+1>6</font></b> - <a href="#6">Notas sobre marcas registradas</a> +<p><font size=+1>7</font> - <a href="#7">Agradecimentos</a> +<br> +<hr WIDTH="100%"> +<br> +<br> +<br> +<br> +<br> +<center> +<p><a NAME="1"></a><u><font size=+1>1-) Introdução ao CFdisk</font></u></center> + +<p> CFdisk é um programa utilizado para fazer +o particionamento de discos, utilizando uma interface em modo texto. +<br>As grandes características deste programa, além de sua +interface de comunicação com o usuário e a enorme +quantidade de partições que manipula, é a grande facilidade +de utilização, o seu poder de manipulação de +partições e a sua precisão que fazem com que o usuário +tenha mais confiança durante o particionamento de disco. +<br> É recomendável a leitura deste texto, +mesmo que tenha uma noção sobre o particionamento de discos, +exceto para os <i>gurus</i> que já conhecem a fundo a forma de trabalho, +em geral, de programas deste tipo, pois o particionamento de disco <b>pode +destruir os seus arquivos e partições já existentes</b>, +se for usado de forma incorreta. +<br> O programa CFdisk pode ser utilizado em qualquer sistema operacional +que esteja de acordo com o padrão POSIX (Linux, UNIX, FreeBSD, HPUX, +etc). +<p> A versão do CFdisk utilizada nas explicações +deste manual é a <i>0.8</i>, mas isto não impede que este +manual seja utilizado com versões futuras ou anteriores deste programa. +As características principais do programa CFdisk e as explicações +sobre particionamento, são válidas para quaisquer versões +deste programa. +<br> +<p><b> Este documento é distribuído com a itenção +de ser útil ao seu utilizador, no entanto NÃO TEM NENHUMA +GARANTIA, EXPLÍCITAS OU IMPLÍCITAS , COMERCIAIS OU +DE ATENDIMENTO A UMA DETERMINADA FINALIDADE. Consulte a Licença +Pública Geral GNU para maiores detalhes.</b> +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<br> +<br> +<br> +<center> +<p><a NAME="1.1"></a><u><font size=+1>1.1-) Partição de Disco</font></u></center> + +<p> Uma <i>Partição de Disco</i> é +o local onde o sistema operacional armazena seu sistema de arquivos(arquivos, +diretórios, FAT, boot sector, etc). +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="1.2"></a><u><font size=+1>1.2-) Tabela de partição</font></u></center> + +<p> A <i>Tabela de partição</i> é +o local do disco rígido onde se localizam os dados sobre todas as +partições existentes no disco como o sistema de arquivos +utilizado, se ela é inicializável, a cabeça inicial/final, +setor inicial/final, cilindro inicial/final, número de setores ocupados +por ela no disco. +<br> +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="1.3"></a><u><font size=+1>1.3-) Introdução +ao particionamento de discos</font></u></center> + +<p> Particionar o disco rígido é dividir +ele em partes para armazenamento de arquivos e programas. As partições +criadas no disco podem ter o tamanho que desejar (desde que esteja dentro +da capacidade máxima do disco rígido). +<br> Uma partição não interfere +em outras partições do mesmo disco(é como se tivessemos +vários discos rígidos dentro de um), e nem em outros discos +rígidos(caso possuir mais que um disco rígido) instalado +em seu computador. +<br> Pode ser criada uma partição +única, que neste caso todo o disco rígido é usado +para armazenar os arquivos(que é o caso mais comum caso voce tenha +o DOS), ou várias partições, que podem ser usadas +pelo mesmo SO(Sistema Operacional) ou outros sistemas operacionais diferentes(um +exemplo de várias partições: se for usar o DOS e o +Linux no mesmo disco, os dois sistemas vão +<br>estar no mesmo disco mas um não interfere no outro). +<br><b>ATENÇÃO</b> : A OPERAÇÃO DE PARTICIONAMENTO +DE DISCOS PODE FAZER +<br> +COM QUE OS DADOS ARMAZENADOS EM SEU DISCO RÍGIDO SEJAM +<br> +PERDIDOS, SE FOR USADA INCORRETAMENTE. É SEMPRE +<br> +RECOMENDADO RETIRAR UMA CÓPIA DE SEGURANÇA DOS SEUS +<br> +ARQUIVOS EXISTENTES NO MICRO ANTES DE SE EXECUTAR UM +<br> +PROGRAMA DESTE TIPO, A NÃO SER QUE TENHA CONFIANÇA NO +<br> +QUE ESTA FAZENDO E QUE ENTENDEU AS EXPLICAÇÕES SOBRE A +<br> +IDENTIFICAÇÃO DE DISCOS RÍGIDOS E SUAS PARTIÇÕES +NO +<br> +SISTEMA. +<br> Neste manual voce aprenderá como deve particionar +seu disco rígido para a instalação do SO usando o +programa CFdisk. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="1.4"></a><u><font size=+1>1.4-) Algumas identificações +utilizadas neste manual para facilitar a</font></u> +<br><u><font size=+1>compreensão do texto</font></u></center> + +<p> Esta parte descreve algumas características +de organização deste manual e algumas identificações +que utilizei para facilitar o seu entendimento, e as explicações +que serão dadas. +<p> Explicação de nomes e comandos, sera +seguida da palavra "<b>onde:</b>" e abaixo dela as explicações +sobre os comandos, exemplo: +<p><b>onde:</b> +<br><i>nome a ser explicado1</i> : Descrição +<br><i>nome a ser explicado2</i> : Descrição +<br><i>nome a ser explicado3</i> : Descrição +<p>ou +<p><b>onde:</b> +<br><i>nome a ser explicado1</i> - Descrição +<br><i>nome a ser explicado2</i> - Descrição +<br><i>nome a ser explicado3</i> - Descrição +<br> +<p> Quando for feita alguma referência com tecla +do teclado, por exemplo, pressione <b>p</b> para listar as partições, +a letra sera colocada entre <> para que seja melhor entendida, por exemplo: +<p>pressione <d> para deletar uma partição... +<br>...pressione <Enter> para escolher a opção do menu. +<br>pressione <t> para listar os tipos de partições disponíveis... +<br> +<p> As linhas pontilhadas que aparecem na tela, veja +abaixo, +<br>---------------------------------------------------------------------------- +<br>---------------------------------------------------------------------------- +<br>servem para identificar que o que esta entre as linhas é um +exemplo de como +<br>será a resposta do comando para a tela de seu computador. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="1.5"></a><u><font size=+1>1.5-) Identificação +de discos e partições no Linux</font></u></center> + +<p> Antes de descrever como se utiliza o programa CFdisk, +é importante fazer algumas explicações sobre a identificação +das partições e unidades de disco no sistema Linux( e outros +*nix). +<br> Se voce for um usuário que já conhece +a interpretação de discos e partições neste +sistema, voce não precisará ler esta parte. +<br> No sistema operacional Linux, os dispositivos existentes +no computador (como impressoras, unidades de disquetes, discos rígidos, +monitor, placa de som, etc...) são identificados por um nome referente +a este dispositivo e colocado no diretório <b>/dev</b> (que é +utilizado para identificar os dispositivos ou periféricos existentes +no computador). +<br> A identificação dos discos rígidos +segue a seguinte forma: +<p> /dev/hda1 +<br> | | | +| +<br> | | | +|_Número que identifica a partição do disco rígido(<i>1=Primeira, +2=segunda</i>) +<br> | | | +<br> | | |_Letra +que identifica o disco rígido(<i>a=primeiro disco, b=segundo disco, +etc..</i>) +<br> | | +<br> | |_Sigla <i>hd</i> +- Significa que é um disco rígido <i>IDE</i>(Se tiver um +<i>sd</i> +significa <i>SCSI</i>) +<br> | +<br> |_ Identificação do diretório onde os dispositivos +do sistema são armazenados +<p><b>OBS</b>: As unidades de disco rígido <b>SCSI</b>, são +identificadas com as letras <b>sd</b> +<br> seguida pela letra +da unidade e número da partição e os discos <b>IDE</b> +são +<br> identificados por +<b>hd</b> +seguida pela letra da unidade de disco e o número +<br> da partição +do disco(como visto acima). +<p>Abaixo, algumas identificações de disco do sistema Linux: +<p>/dev/hda1 - Disco rígido IDE primário +principal - Primeira partição +<br>/dev/hda2 - Disco rígido IDE primário +principal - Segunda partição +<br>/dev/hda3 - Disco rígido IDE primário +principal - Terceira partição +<br>/dev/hdb1 - Disco rígido IDE primário +escravo - Primeira partição +<br>/dev/hdb2 - Disco rígido IDE primário +escravo - Segunda partição +<br>/dev/hdb3 - Disco rígido IDE primário +escravo - Terceira partição +<br>/dev/hdc1 - Disco rígido IDE secundário +principal - Primeira partição +<br>/dev/hdc2 - Disco rígido IDE secundário +principal - Segunda partição +<br>/dev/hdc3 - Disco rígido IDE secundário +principal - Terceira partição +<br>/dev/hdd1 - Disco rígido IDE secundário +escravo - Primeira partição +<br>/dev/hdd2 - Disco rígido IDE secundário +escravo - Segunda partição +<br>/dev/hdd3 - Disco rígido IDE secundário +escravo - Terceira partição +<br>/dev/sda1 - Primeiro disco rígido +SCSI - Primeira partição +<br>/dev/sda2 - Primeiro disco rígido +SCSI - Segunda partição +<br>/dev/sda3 - Primeiro disco rígido +SCSI - Terceira partição +<br>/dev/sdb1 - Segundo disco rígido +SCSI - Primeira partição +<br>/dev/sdb2 - Segundo disco rígido +SCSI - Segunda partição +<br>/dev/sdb3 - Segundo disco rígido +SCSI - Terceira partição +<p> No exemplo acima foram usadas 3 partições +por disco, mas podem existir mais partições no mesmo disco, +um exemplo é se o disco rígido possuir <b>partições +Lógicas</b>, que são identificadas no sistemas a partir de +<b>/dev/hdx5</b>. +<br> +<p> Abaixo um exemplo de como o Linux identifica as partições +em cada disco existente em seu computador: +<p>Vamos supor que eu tenha 2 discos rígidos: +<br>o 1ºdisco de <i>2GB</i> e o 2ºdisco de <i>1GB</i>(Giga +Byte ou 1.000 Megas!) +<p> No primeiro disco(de <i>2GB</i>), a primeira partição +é de <b>800MB</b> do tipo <b>FAT16</b>(DOS), a segunda partição +é de <b>1.2GB</b> do tipo <b>EXT2</b>(Linux)(1.2GB+800MB=2GB que +é a capacidade total do disco). Assim as partições +seriam identificadas da seguinte forma no Linux: +<p><i>/dev/hda </i> - Disco rígido Primário Principal +<br><i>/dev/hda1</i> - Primeira partição do primeiro disco +rígido (de <b>800MB</b> do tipo <b>DOS</b>) +<br><i>/dev/hda2</i> - Segunda partição do primeiro disco +rígido( de <b>1.2GB</b> do tipo <b>Linux</b>) +<p> Neste caso estariam disponíveis 800MB para +serem usados com o DOS e 1.2GB para o Linux. Por +exemplo, se voce particionar um disco rígido em duas partes e usar +as duas partições no DOS, ele reconhecerá as partições +como sendo <b>C:</b> e <b>D:</b>. +<p><b>Lembre-se</b>: Quando um disco é particionado, nenhuma partição +interfere na outra, repare que +<br> +quando voce particiona(divide) um disco, é como se tivesse +dois discos rígidos(o +<br> +único cuidado que voce deve tomar é com as cópias +de segurança, porque se der um +<br> +problema de parte eletrônica no disco rígido, por exemplo, +a sua placa controladora +<br> +queimar ou o cabeçote dele ir pro espaço, voce perderá +as suas 2 partições que estão +<br> +armazenadas nele. +<br> +<p>Voltando ao exemplo das classificações das partições +do disco, vamos para o segundo disco: +<p> No segundo disco(1GB), eu tenho uma partição +de <b>950MB</b> do tipo <b>FAT16</b>(DOS), que costumo usar para armazenar +arquivos temporários e cópias de segurança de meu +sistema, etc..., e outra de <b>50MB</b> SWAP(Partição de +memória virtual como descrevi acima)(950MB+50MB=1GB). Então +as partições deste disco seriam identificadas da seguinte +forma no Linux: +<p><i>/dev/hdb </i> - Disco rígido principal escravo +<br><i>/dev/hdb1</i> - Primeira partição do disco acima ( +de 950MB do tipo DOS) +<br><i>/dev/hdb2</i> - Segunda partição do disco acima ( +de 50MB do tipo SWAP) +<p> No disco acima, <b>950MB</b> estão disponíveis +para serem usados pelo <i>DOS</i> e <b>50 MB</b> pela memória virtual +(<i>SWAP</i>) do Linux. +<p> Note que se voce utiliza o <i>MS-DOS</i>, voce não +conseguirá ver as partições do <i>Linux</i> e <i>SWAP</i>, +porque são imcompatíveis com o formato aceito pelo <i>DOS</i> +(ele identificaria a primeira partição do primeiro disco(<b>800MB</b>) +como a unidade C: e a primeira partição do segundo disco(<b>950MB</b>) +como unidade D), mas o contrário não acontece; O <i>Linux</i> +tem total compatibilidade com a partição +<br><i>DOS FAT12, FAT16, FAT32, OS/2 HPFS,</i> e muitas outras. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="1.6"></a><u><font size=+1>1.6-) Tipos de partições +de discos</font></u></center> + +<p> As partições de disco são divididas +em tres tipos: <b>Primária, Extendida</b> e <b>Lógica</b>. +<br> Pode se ter, no máximo, <b>4</b> partições +<i>Primárias</i> +e <i>Extendidas</i> no mesmo disco (3 Primárias e 1 Extendida ou +4 partições Primárias em cada disco). +<br>A partição <i>Primária</i> permite o armazenamento +de arquivos e diretórios. Todos os computadores que possuem somente +a unidade <i>C: </i>(supondo que utilize o DOS), utilizam este tipo de +partição para armazenamento de arquivos e inicialização +do sistema operacional. +<br> Se for preciso criar mais que <i>4</i> partições +no mesmo disco, será necessário criar uma partição +<i>Extendida</i>. +A partição Extendida não pode ser utilizada para armazenar +arquivos. Ela é usada para a criação de outras partições, +dentro dela, que são chamadas de partições <i>Lógicas</i>. +<br> Uma partição <i>Extendida</i> podem +conter várias partições <i>Lógicas</i>. As +partições <i>Lógicas</i> podem armazenar arquivos +e diretórios(como as partições primárias). +<br> Um mesmo disco rígido pode armazenar mais +de 64 partições independentes uma das outras. +<p><b>LEMBRE-SE</b>: Os arquivos e diretórios podem ser armazenados +somente em partições de disco primárias ou lógicas, +a partição extendida não é usada para armazanamento +de arquivos e diretórios. +<p> Se possuir duas partições em seu computador +(<b>C:</b> e <b>D:</b> no DOS), e não estiver usando a partição +<b>D:</b>, +a instalação do Linux pode ser feita nesta partição +desde que ela tenha o espaço necessário para o sistema operacional +Linux, os programas que desejar instalar, mais a partição +SWAP. +<div align=right> +<br><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="1.7"></a><u><font size=+1>1.7-) Observações +sobre o formato DOS 6.XX(FAT 16)</font></u></center> + +<p> No formato <b>DOS 6.XX(FAT16)</b>, o primeiro +setor da área de dados da partição é utilizado +frequentemente pelo DOS para armazenamento de dados sobre a partição +de disco, e estes dados são usados pelo sistema para se ter maior +confiabilidade do que os dados armazenados na tabela de partição. +O sistema de arquivos DOS, faz o FDISK(do DOS) limpar os primeiros 512 +bytes da área de dados da partição sempre que uma +mudança de tamanho acontecer. +<br> O formatador do DOS(<b>format</b>) verifica +este primeiro setor toda vez que a upção <b>/U</b> (que é +utilizada para não salvar dados para se fazer a desformatação +do disco) foi utilizada. +<br> Isto é considerado uma FALHA no <b>Format</b>(do +DOS) e no <b>Fdisk</b>(do DOS). +<p> A opção abaixo deve ser utilizada +caso voce crie uma partição do DOS FAT16 com o CFdisk, que +faz com que os primeiros 512 bytes daquela partição sejam +"limpos", para manter a compatibilidade com o DOS. Utilize esta opção +dentro do Linux, após criar a partição com o CFdisk +e reiniciar o seu computador. Foi notado que esta opção só +funciona corretamente somente quando o Sistema Linux estiver instalado +em seu computador. Não me responsabilizo caso utiliza-la a partir +de um disquete de recuperação. +<p><b>dd if=/dev/zero of=/dev/hdx1 bs=512 count=1</b> +<p><b>onde:</b> +<br><i>hdx1</i> - É a identificação da unidade de +disco e a partição que foi criada pelo CFdisk utilizando +o +<br> sistema +de arquivos DOS que terá seu primeiro setor "limpo". +<br> +<p><b>OBS1</b>: Cuidado ao utilizar esta opção, um pequeno +descuido pode resultar na perda de dados do +<br> +seu disco rígido ou outras partição. +<br><b>OBS2</b>: Não utilize este comando com partições +que utilizam o sistema de arquivos <i>FAT32</i>(utilizada +<br> +nos sistemas operacionais Windows 95 OSR/2 e superiores) .Se esta opção +for utilizada +<br> +em um disco utlizando este sistema de arquivos, sua FAT será corrompida, +caso isto +<br> +acontecer, será necessária a re-formatação +da partição. +<br><b>OBS3</b>: É extremamente recomendado que se utilize o programa +de particionamento que +<br> acompanha +o seu sistema operacional. Por exemplo, se deseja criar uma partição +DOS +<br> 6.XX, +utilize o FDisk qua acompanha o DOS. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2"></a><u><font size=+1>2-) Iniciando o programa CFdisk</font></u></center> + +<p> Para entrar no programa CFdisk digite: +<p><i>cfdisk</i> <unidade> +<p><b>onde:</b> +<br><i>unidade</i> - é a unidade de disco que deseja utilizar para +fazer o particionamento. A unidade pode +<br> +ser: /dev/hda, /dev/hdb, /dev/hdc ..., /dev/sda, /dev/sdb...,etc +<p><b>NOTA:</b> Se voce não digitar a unidade, o cfdisk utilizará +a unidade <i>/dev/hda</i> como padrão. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.1"></a><u><font size=+1>2.1-) Opções de +linha de comando utilizadas com o CFdisk</font></u></center> + +<p> Opções de linha de comando fazem com que o programa +inicie de forma específica ou personalizada. As opções +devem ser digitadas após o nome do programa (cfdisk). +<p> <b>cfdisk</b> <<i>unidade</i>> +<<i> -avz</i> > < -<i>c cilindros </i>> < <i>-h cabeçotes +</i>> +<br> +< <i>-s setores_por trilha </i>> < <i>-P opt</i> > < <i>dispositivo</i> +> +<p><b>onde:</b> +<br><i>-a</i> Usa um cursor seta +ao invés de video reverso para destacar a +<br> partição +atual. +<br><i>-v</i> Mostra a versão +do programa e Coyright(Direitos Reservados). +<br><i>-z </i> Ignora a leitura +da tabela das partições existentes no disco +<br> ao iniciar o +CFdisk. +<p><i>-c</i> Número de Cilindros do disco +<br><i>-h</i> Número de Cabeçotes do disco +<br><i>-s</i> Setores por trilha existentes no disco. +<br><i>-P</i> <i>OPC</i> Mostra a tabela de partição +no formato especifico. +<br> <i>OPC</i> - +Pode ser: +<br> + +<i>r</i> - Mostra a tabela de partição em Formato RAW +<br> + +<i>s</i> - Mostra a tabela de partição em Format de Setores +<br> + +<i>t</i> - Mostra a tabela de partição classificada +pelo número da partição +<br> +Para maiores detalhes, veja <a href="#2.3.9">O comando Print <p></a>. +<p><b>OBS:</b> A utilização dos parâmetros -c -h -s, +substituirão os parâmetros da BIOS da placa, utilize +<br> estas opções +se sua bios não utilizar estes parâmetros ou se mostrar valores +incorretos. +<p> Após entrar o programa CFdisk, ele verificará +automaticamente o tamanho do Disco Rígido, se não conseguir, +o programa será terminado. +<br> Para resolver este problema, especifique o tamanho +do disco em cilindros, cabeças, e setores na linha de comando que +inicia o programa. Este problema geralmente acontece quando se tenta particionar +uma unidade de disco <i>SCSI</i> que esteja conectada a uma placa controladora +que não possui <i>BIOS</i>, e quando uma <i>BIOS</i> +mostra os valores da geometria do disco(tamanho) +<br>incorretamente. +<br> O próximo passo do CFdisk é fazer +a leitura das partições atuais do disco, se não conseguir, +o programa será terminado. O único motivo para o CFdisk mostrar +esta mensagem de erro, é se voce digitar parâmetros incorretos +para o tamanho do disco, caso tenha acontecido o problema +<br>descrito no paragrafo anterior. Verifique se os parâmetros foram +digitados incorretamente, se os parâmetros estiverem digitados corretamente +e mesmo assim o programa continua dando erro na leitura das partições, +utilize a opção <i>-z</i> na linha de comando do programa, +que faz com que ele ignore a leitura das partições existentes +no disco ao iniciar . +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.2"></a><u><font size=+1>2.2-) Conhecendo a Tela do CFdisk</font></u></center> + +<p> Após digitar CFdisk, será mostrada a tela +principal onde voce poderá acionar os comandos para manipulação +das partições de disco, e visualizar as partições +de disco atuais e outros dados. +<br>Abaixo o exemplo e explicações sobre esta tela. +<p>O disco utilizado para os exemplos é um disco de <b>5157 MB</b> +de Capacidade com: +<br>- <i>10672</i> Cilindros <i>15</i> Cabeças <i>63</i> +Setores (no modo <b>C/H/S</b>) +<br>- <i>627</i> Cilindros <i>255</i> Cabeças <i> +63</i> Setores (no modo <b>LBA</b>) +<br> A unidade de medida utilizada pelo CFdisk para mostrar +os parâmetros do disco será o mesmo configurado na BIOS, ou +seja, se estiver utilizando o disco com o modo de operação +em <i>LBA</i>, os valores de cilindros, cabeças e setores motrados +pelo CFdisk sera em <b>LBA</b>. +<br> +<p>--------------------------------------------------------------------------------------------------- +<center>CFdisk 0.8l +<br>Disk Drive: /dev/hda +<br>Heads:255 Sectores per track:63 Cylinders:627</center> +--------------------------------------------------------------------------------------------------- +<br>Name +Flags +Part Type FSType +[LABEL] +Size(MB) +<br>hda1 +Boot +Primary Win 95 FAT 32 +1953.12 +<br>hda5 +Logical DOS FAT 16 (BIG) GLEYDSON +172.58 +<br> +Pri/Log Free Space +2910.55 +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<p>[Bootable] [Delete] [Help] [Maximize] +[Print] +<br>[Quit] [Type] +[Units] [Write] +<br>---------------------------------------------------------------------------- +<br> No cabeçalho da tela, é mostrada +a versão do programa, a unidade de disco que será usada no +particionamento e os parâmetros de tamanho do disco(cabeçotes, +cilindros e setores). +<br>Abaixo do cabeçalho após a linha pontilhada, se encontra +a área das partições. +<p><b>onde:</b> +<br>- <i>Name</i> : é o nome da(s) partição(ões) +de Disco. +<br>- <i>Flags</i> : Se estiver marcada como BOOT, será +possível iniciar o sistema a partir desta partição +<br> +(quando não se utiliza um Boot Manager). Se estiver marcada como +NC (Não +<br> +compatível) significa que esta partição não +é compatível com o DOS, OS/2, etc. Para +<br> +maiores detalhes, veja <a href="#2.3.7">O comando Maximize <m></a>. +<br>- <i>Type</i> : O tipo da partição pode ser +Primária ou Lógica. Para espaço não particionado, +o +<br> +tipo da partição pode ser Primário/Log. +<br>- <i>FileSystems</i> : Tipo de Sistema de Arquivos que é usado +naquela partição. Se o sistema de +<br> +arquivos for desconhecido, ele será mostrado como um valor Hexadecimal. +Um +<br> +caso especial ocorre quando há Partições do Disco +Rígido que não podem ser +<br> +usadas ( porque toda a partição primária esta em uso). +Quando isto é detectado, o +<br> +tipo de FileSystems é mostrado como não usável(Unusable) +para criação de novas +<br> +partições. +<br>- Label : Nome de volume da partição de disco. +Os nomes de partições FAT32, não são +<br> +mostrados com esta versão do CFdisk. +<br>- Size : Mostra o tamanho que cada partição +ocupa no disco rígido em MegaBytes (por +<br> +padrão). +<br> +Também pode mostrar o tamanho ocupado por Setores ou Cilindros. +Se for mostrado +<br> +um asterisco (*) após o tamanho, isto diz que a partição +não esta alinhada com Cilindro. +<p> O espaço livre existente no disco para criação +de novas partições, é mostrado como uma outra partição, +com o FSType(<i>sistema de arquivos</i>) Free Space(<i>espaço Livre</i>). +<p><b>OBS:</b> As partições de disco Extendidas não +são mostradas na tela do CFdisk durante o +<br> particionamento, +mesmo assim, as partições lógicas que este tipo de +partição armazena, +<br> serão +mostradas a partir de hdx5 ou sdx5. +<p> No rodapé da tela, encontramos os comandos +utilizados pelo CFdisk para manipular as partições de disco. +Os comandos são mostrados entre Chaves []. +<br> Todos os comandos no rodapé da tela, são +aplicaveis somente para a partição que estiver destacada +com a barra(video reverso). Veja descrições dos comandos +do CFdisk para mais detalhes. +<br> Abaixo do rodapé da tela, é mostrada +a descrição do comando que estiver em destaque com o cursor +em video reverso. +<p> Veja abaixo a tradução da tela principal +do programa CFdisk: +<br>--------------------------------------------------------------------------------------------------- +<center>CFdisk 0.8l +<br>Unidade de Disco: /dev/hda +<br>Cabeças:255 Setores por trilha:63 Cilindros:627</center> +--------------------------------------------------------------------------------------------------- +<br>Nome Opções +Tipo Part. Tipo Sist. Arquivos +[VOLUME] Tamanho(MB) +<br>hda1 Boot +Primary Win +95 FAT 32 +1953.12 +<br>hda5 +Logical DOS FAT 16 (BIG) +GLEYDSON +172.58 +<br> +Pri/Log +Espaço Livre +2910.55 +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<p>[Inicializável] [Apagar] +[Ajuda] [Maximizar] [Imprimir] +<br>[Sair] +[Tipo] [Unidades][Gravar] +<br>---------------------------------------------------------------------------- +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.3"></a><u><font size=+1>2.3-) Descrição +dos comandos do CFdisk</font></u></center> + +<p> Os comandos do programa são utilizados criar +partições, entrar na ajuda do programa, alterar o tipo da +partição, apagar uma partição, etc. +<br> Pode ser utilizado Seta p/ Esquerda e Seta p/ direita +para se movimentar entre os comandos, quando o cursor estiver em cima do +comando que deseja executar, pressione <Enter>. +<br> Outro método que se pode utilizar para acionar +uma opção do CFdisk, é pressionando a primeira letra +de cada opção, automaticamente a opção é +executada(sem ter que pressionar <Enter>). Neste método, todos +os comandos aceitam letras maiúsculas e minúsculas, exceto +o comando Write(gravar partição) que é executado somente +se pressionar <W> maiúscula, para evitar +<br>gravações acidentais o disco. +<br> Quando estiver em um Sub-Menu e desejar retornar +ao menu principal, pressione a tecla <Esc>. +<div align=right> +<br><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.3.1"></a><u><font size=+1>2.3.1-) Setas Acima e Abaixo/ +Esquerda e Direita (Movimentação do Cursor)</font></u></center> + +<p> Setas Acima e Abaixo são utilizadas para se +movimentar entre as partições existentes no disco e espaço +livre, selecionando-a para que seja utilizada as opções do +CFdisk. +<br> Setas Esquerda e Direita são utilizadas para +selecionar entre as opções diponíveis do programa(que +serão explicadas abaixo). Para confirmar uma opção, +pressione <Enter>. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.3.2"></a><u><font size=+1>2.3.2-) <CTRL>+<l></font></u></center> + +<p> Este comando é utilizado para atualizar a tela manualmente +caso a atualização automática falhar, por exemplo, +quando uma partição for excluida, e continuar a ser mostrada +na tela. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.3.3"></a><u><font size=+1>2.3.3-) Boot <b></font></u></center> + +<p> Este comando permite escolher se a partição +Primária atual será utilizada para iniciar o sistema(BOOT). +Selecione esta opção para selecionar entre partição +inicializável ou não inializável. Quando uma partição +estiver marcada como inicializável, aparecerá a palavra BOOT +na coluna Flags(na tela principal do programa). +<p><b>OBS:</b> Não será necessário marcar a partição +Linux como inicializável, caso se esteja utilizando um +<br> Boot Manager(como +o <i>LILO</i>) para escolher qual sistema operacional sera utilizado para +<br> inicializar o sistema. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.3.4"></a><u><font size=+1>2.3.4-) Delete <d></font></u></center> + +<p> Este comando apaga a partição selecionada +do disco. Após apagar a partição, o espaço +ocupado por ela é convertido para espaço livre. +<br> A partição marcada atualmente como Free Space +ou como Unusable não pode ser apagada. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.3.5"></a><u><font size=+1>2.3.5-) Geometry <g></font></u></center> + +<p> Este comando não é mostrado no menu, pois +é utilizado para alterar o tamanho (Cilindros, Cabeças e +Setores do disco). Este comando só pode ser acionado se for pressionada +a tecla <g>. +<p><b>CUIDADO:</b> Esta opção é recomendada somente +para aqueles que sabem os riscos que o uso +<br> +desta opção pode fazer, e se a situação que +estão, requerem o seu uso. +<br> Uma situação que esta opção +é util, é se o BIOS do seu computador não mostrar +corretamente os parâmetros do disco(Cilindros, Cabeçotes ou +Setores), sendo necessário que se passe manualmente o tamanho do +disco para que seja feito o correto particionamento do disco. +<p><b>OBS:</b> Caso seu disco rígido for <i>SCSI</i> e placa controladora +dele não tiver BIOS, provavelmente o +<br> CFdisk não +será iniciado. Se este problema ocorrer, digite os parâmetros +do disco na linha +<br> de comando ao +iniciar o programa. Para maiores detalhes, veja opções de +linha de comando +<br> do CFdisk.. +<p>Após pressionar <g> será mostrada a seguinte tela: +<p>---------------------------------------------------------------------------------------------------- +<center>CFdisk 0.8l +<br>Disk Drive: /dev/hda +<br>Heads:255 Sectors:63 Cilinders:627</center> +---------------------------------------------------------------------------------------------------- +<br>Name Flags +Part Type File +System +[LABEL] Size(MB) +<p>hda1 Boot +Primary Win 95 FAT +32 +1953.12 +<br>hda5 +Logical DOS FAT 16 (BIG) +GLEYDSON 172.58 +<br> +Pri/Log +Espaço Livre +2910.55 +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<p>[ Cylinders] [Heads] [Sectors] [Done] +<p>---------------------------------------------------------------------------- +<br><b>onde:</b> +<br><i>Cylinders </i>: Altera o número de Cilindros do disco +atual durante o particionamento. +<br><i>Heads</i> : Altera o número +de Cabeças do disco atual durante o particionamento. +<br><i>Sectors</i> : Altera o número de +Setores do disco atual durante o particionamento. +<br><i>Done</i> : Quando finalizar +as alterações, tecle <d> ou selecione Done para +<br> +que o CFdisk modifique os valores de Cilindros, Cabeças e Setores +<br> +que utiliza para particionar o disco e retorne a tela anterior. +<br> +<p> Quando escolher algum parâmetro acima +para alteração(Cilindros, cabeçotes ou Setores do +disco), será vista uma tela como esta: +<br>---------------------------------------------------------------------------------------------------- +<center>CFdisk 0.8l +<br>Disk Drive: /dev/hda +<br>Heads:255 Sectors:63 Cilinders:627</center> +---------------------------------------------------------------------------------------------------- +<br>Name Flags +Part Type +File System +[LABEL] +Size(MB) +<p>hda1 +Boot +Primary +Win 95 FAT 32 +1953.12 +<br>hda5 +Logical DOS +FAT 16 (BIG) GLEYDSON +172.58 +<br> +Pri/Log +Espaço Livre +2910.55 +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<p>Enter the number of Cylinders: 627 +<p>---------------------------------------------------------------------------- +<br> O valor que aparece ao selecionar a opção, +é o valor que o disco esta utilizando atualmente (<i>cilindros</i>), +e será pedido que digite um valor para os Cilindros, que substituirá +os da BIOS durante a seção de particionamento. Para +sair desta tela sem alterar o valor, pressione <ESC>. A mesma tela e +explicação se aplicam para as alterações de +Cabeças e Setores. +<p><b>OBS:</b> Se por acaso digitar um valor incorretamente para o tamanho +do disco e não se lembrar +<br> mais do valor +antigo ou original, selecione a opção Done, e tecle +<q> para sair do CFdisk +<br> sem gravar as alterações +feitas para o disco, pois se continuar a utilizar o CFdisk com o +<br> tamanho do disco incorreto, +os dados existentes nele e até mesmo partições poderão +ser +<br> perdidos(as). +<p> Se aumentar o tamanho do disco, setores adicionais são +acrescentados no final do disco, e são mostrados como espaço +livre. +<br> Se diminuir o tamanho do disco, as partições +que estavam localizadas após o setor/cilindro que foi excluido(se +existir alguma), será apagada e a última partição(ou +espaço livre ao final do disco rígido), terá seu tamanho +alterado e terminará neste "novo" último setor do disco. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.3.6"></a><u><font size=+1>2.3.6-) Help <h> ou <?></font></u></center> + +<p> O comando Help mostra a tela de ajuda do programa, +que descreve as funções das teclas utilizadas pelo programa +e suas funções. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.3.7"></a><u><font size=+1>2.3.7-) Maximize <m></font></u></center> + +<p> Este comando aumenta a utilização de espaço +do disco na partição atual. Isto porque o <i>DOS</i>, <i>OS/2</i> +e outros sistemas operacionais utilizam o primeiro setor da primeira trilha +da partição do disco e em todas as <i>partições +Lógicas</i> para iniciar o sistema operacional, utilizando a segunda +trilha em diante daquela partição para fazer o armazenamento +de arquivos. Este espaço perdido entre o <i>segundo</i> e o <i>último</i> +Setor da primeira trilha da primeira cabeça, pode ser recuperado +com a utilizando este comando. +<br> Este comando faz com que a partição +se torne imcompatível com <i>DOS</i>, <i>OS/2</i> e outros Sistemas +Operacionais que utilizam este primeiro Setor do disco para iniciar o sistema +operacional. +<br> Se este comando for utilizado, será colocada uma +opção chamada <i>NC</i>(não compatível) em +Flags(na tela principal do CFdisk). +<br> Esta opção faz o uso máximo do disco +e a incompatibilidade com o <i>DOS/OS/2</i>, etc. O padrão quando +criando uma Partição, é criando Partições +compativeis com o <i>DOS, OS/2</i>, etc. +<p><b>OBS:</b> O Fdisk(versão 8 e superiores) e partições +formatadas com o sistema de arquivos <i>FAT32</i>, +<br> fazem a utilização +completa deste espaço entre o segundo e o último Setor da +primeira trilha +<br> do disco, eliminando +o desperdício de espaço. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.3.8"></a><u><font size=+1>2.3.8-) New <n></font></u></center> + +<p> O comando New<n>, cria uma nova partição +usando o espaço livre(FreeSpace) existente no disco. Após +escolher esta opção, o CFdisk perguntará se deseja +criar uma <i>partição Primária</i>, <i>Lógica</i> +ou <i>Cancelar</i> o comando. +<br> Escolhendo criar uma partição <i>Primária</i> +ou <i>Lógica</i>, o sistema perguntará o tamanho da partição +que deseja criar, por padrão, o CFdisk mostrará o espaço +livre total disponível no disco para a criação da +nova partição(em MegaBytes). Tecle <Enter> para criar +uma partição do tipo escolhido com este tamanho ou digite +um tamamho menor. O CFdisk permite que seja digitados valores em: +<br>- <i>MegaBytes</i>(M - o padrão do programa) +<br>- <i>KiloBytes</i>(K) +<br>- <i>Cilindros</i>(C) +<br>- <i>Setores</i>(S) +<br>Digitando-se o tamanho da partição seguida de uma das +letras acima. Se a letra não for digitada, +<br>o programa assumirá o tamanho que digitou em MegaBytes. +<p><b>OBS1:</b> Quando criar uma partição Lógica, +automaticamente será criada uma partição +<br> +Extendida, entre hdx1 e hdx4, e a partição Extendida não +é mostrada na tela de +<br> +particionamento de disco. Se desejar exibir a partição extendida, +execute o comando +<br> +PRINT <p> e escolha a opção <i>Sector</i> para verificar +qual é a identificação da <i>partição</i> +<br><i> +Extendida</i> no disco. Para maiores detalhes, veja o <a href="#2.3.9">comando +PRINT <p></a>. +<br><b>OBS2</b>: São permitidas, no máximo, 4 partições +<i>Primárias</i> +e <i>Extendidas</i>(3 <i>Primárias</i> e 1 +<br><i> +Extendida </i>ou 4 <i>partições Primárias</i> em cada +disco). O CFdisk calculará +<br> +automaticamente os valores das partições Lógicas caso +as primeiras 4 partições forem +<br> +ocupadas. +<p> O próximo passo, é a localização +da partição no espaço livre existente o disco. As +duas opções disponíveis são: +<br>- <i><u>Beginning</u></i> : A partição é colocada +a partir do inicio do espaço livre no disco, ocupando o espaço +<br> +livre de acordo com o seu tamanho (do início para o fim do espaço +livre ), este é o +<br> +padrão para a criação de novas partições +e o mais utilizado. Veja o exemplo, a +<br> +criação de uma partição de <b>30MB</b> em um +disco com <b>50MB</b> de espaço não +<br> +particionado, sendo que este disco já possui uma partição +de <b>120MB</b>(com espaço +<br> +total de <b>170MB</b>). +<p> +##################################MMMMMMMMMMMMMMMMMMMMMM +<br> +| +| +<br> +Partição existente(<b>120MB</b>) +Espaço Livre(<b>50MB</b>) +<br> +<p> +com a nova partição criada: +<p> ###################################################MMMMMMMMM +<br> +| +| +| +<br> +Partição existente(<b>120</b>MB) +Nova partição +Espaço +<br> +(<b>30</b>MB) +Livre +<p>-<i> <u>End </u></i> : A partição +é criada subtraindo-se o espaço livre total do disco pelo +tamanho da +<br> +partição que será criada, começando a +criar esta partição a partir do ponto que +<br> +resultou esta subtração. +<br> +Veja abaixo no exemplo, a partição que será criada +terá o tamanho de <b>30</b>MB e existe +<br> +no disco um espaço não particionado de <b>50</b>MB, com <b>120</b>MB +já ocupados por uma +<br> +partição existente: +<p> +##################################MMMMMMMMMMMMMMMMMMMMM +<br> +| +| +<br> +Partição existente(<b>120</b>MB) +Espaço Livre(<b>50</b>MB) +<br> +<p>com a nova partição criada (Selecionando a opção +End): +<p>##################################MMMMMMMMMM################# +<br> +| +| +| +<br> +Partição existente(<b>120</b>MB) +Espaço +Nova partição +<br> +Livre +(<b>30</b>MB) +<p> A partição que será criada utilizara +o espaço livre entre o último Setor do disco e o setor resultante +da subtração(<b>170</b>MB-<b>30</b>MB). Mesmo assim, a ordem +que será criada esta partição partição +será criada do Setor inicial(que é o resultado da subtração) +para o último Setor do disco. Existirá um espaço livre +de <b>20</b>MB entre a primeira partição (de <b>120</b>MB) +e a nova partição de <b>30</b>MB. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.3.9"></a><u><font size=+1>2.3.9-) Print <p></font></u></center> + +<p> Este comando mostra a tabela de partição +no formato selecionado na tela, ou permite que seja gravado um arquivo +no disco. Todas as partições são classificadas na +ordem que foram gravadas no disco. +<p>Os formatos aceitos para visualização de partições +são: +<p><u><i>RAW <r></i> </u>: Formato de dados do disco, mostra os setores +que serão gravados para o disco, caso +<br> +seja escolhido o comando WRITE <W>. O formato mostrado é exatamente +aquele +<br> +que será gravado para ao disco. +<br> Abaixo um exemplo +deste formato: +<br> -------------------------------------------------------------------- +<br> <i>Disk Drive: +/dev/hda</i> +<br> Sector 0: +<br> 0x000: EB 69 +4C 49 4C 4F 01 00 14 00 D7 02 00 00 00 00 +<br> 0x010: FB 1B +CF 36 74 D8 80 23 01 75 D8 80 23 01 73 D8 +<br> 0x020: 80 23 +01 01 77 01 77 D8 80 23 01 78 D8 80 23 01 +<br> 0x030: 64 D8 +80 23 01 65 D8 80 23 01 66 D8 80 23 01 67 +<br> 0x040: D8 80 +23 01 68 D8 80 23 01 69 D8 80 23 01 6A D8 +<br> 0x050: 80 23 +01 6B D8 80 23 01 00 00 00 00 00 00 00 00 +<br> 0x060: 00 00 +00 00 00 00 00 00 00 00 00 B8 C0 07 8E D8 +<br> 0x070: 8C 06 +66 00 89 36 64 00 89 1E 68 00 88 16 6A 00 +<br> 0x080: B8 00 +9A 8E C0 B9 00 01 29 F6 29 FF FC F3 A5 EA +<br> 0x090: 94 00 +00 9A FA 8E D8 8E C0 BC 00 B0 B8 00 90 8E +<br> 0x0A0: D0 FB +B0 0D E8 57 00 B0 0A E8 52 00 B0 4C E8 4D +<br> 0x0B0: 00 BE +30 00 BB 00 10 FC AD 89 C1 AD 89 C2 09 C8 +<br> 0x0C0: 74 20 +46 E8 43 00 72 06 81 C3 00 02 EB EA 50 B0 +<br> 0x0D0: 20 E8 +2A 00 58 88 E0 E8 12 00 31 C0 88 C2 CD 13 +<br> 0x0E0: EB CF +B0 49 E8 17 00 EA 00 00 00 9B 50 C0 E8 04 +<br> 0x0F0: E8 01 +00 58 24 0F 04 30 3C 3A 72 02 04 07 30 FF +<br> 0x100: B4 0E +CD 10 C3 5A 59 5B C3 F6 C2 40 74 52 80 E2 +<br> 0x110: BF 53 +51 52 B4 08 CD 13 72 EB 88 F3 5A 88 16 6D +<br> 0x120: 01 88 +F2 30 F6 88 F7 58 51 86 CD D0 C5 D0 C5 80 +<br> 0x130: E5 03 +89 0E 6B 01 59 83 E1 3F F7 F1 FE C2 88 16 +<br> 0x140: 6E 01 +31 D2 43 F7 F3 88 D6 8A 16 6D 01 3B 06 6B +<br> 0x150: 01 77 +13 86 C4 D0 C8 D0 C8 0A 06 6E 01 89 C1 5B +<br> 0x160: B8 01 +02 CD 13 C3 5B 31 C0 F9 C3 00 00 00 00 00 +<br> 0x170: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x180: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x190: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x1A0: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x1B0: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 80 01 +<br> 0x1C0: 01 00 +0B FE 3F 8F 3F 00 00 00 51 4C 23 00 00 00 +<br> 0x1D0: 41 D7 +83 FE BF 6F 17 75 73 00 59 81 25 00 00 00 +<br> 0x1E0: 01 98 +05 FE 7F D6 98 42 25 00 7F 32 4E 00 00 00 +<br> 0x1F0: 81 70 +82 FE BF 72 70 F6 98 00 43 BC 00 00 55 AA +<p> Sector 2441880: +<br> 0x000: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x010: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x020: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x030: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x040: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x050: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x060: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x070: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x080: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x090: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x0A0: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x0B0: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x0C0: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x0D0: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x0E0: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x0F0: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x100: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x110: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x120: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x130: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x140: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x150: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x160: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x170: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x180: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x190: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x1A0: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x1B0: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 01 +<br> 0x1C0: 01 98 +0B FE 7F D6 3F 00 00 00 40 32 4E 00 00 00 +<br> 0x1D0: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x1E0: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<br> 0x1F0: 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 55 AA +<br> ----------------------------------------------------------------- +<br> +A primeira tabela de partição mostrada é a Primária, +depois +<br> as tabelas de +partições ligadas com cada partição lógica. +Como +<br> no exemplo, +os dados são mostrados em bytes Hexadecimais(na +<br> primeira coluna) +seguidos de 16 bytes por linha. +<p><i><u>Sector <s></u></i>: Mostra a tabela de partição +classificada por setores. Esta +<br> opção +mostra o espaço não particionado no disco e a<i> partição</i> +<br><i> Extendida</i>, +que é mostrada antes das <i>partições Lógicas</i>. +<br> Abaixo um exemplo +deste formato: +<br> ------------------------------------------------------------------ +<br> Partition Table +for /dev/hda +<p> +First Last +<br> # Type +Sector Sector Offset +Length Filesystem Type (ID) Flags +<br> -- ------- +-------- --------- ------ --------- ---------------------- +--------- +<br> 1 Primary +0 2313359 +63 2313360 Win95 FAT32 (0B) Boot (80) +<br> +Logical 2313360 2441879 +0 128520 Free Space +None (00) +<br> 3 Primary +2441880 7566614 0 +5124735 Extended +(05) None (00) +<br> 5 Logical +2441880 7566614 63 5124735 +Win95 FAT32 (0B) None (00) +<br> 2 Primary +7566615 10024559 0 2457945 +Linux +(83) None (00) +<br> 4 Primary +10024560 10072754 0 +48195 Linux Swap (82) None +(00) +<br> ------------------------------------------------------------------------------------ +<br> <b>Onde</b>: +<br> <i>#</i> +- Identificação da partição no disco /dev/hda +<br> <i>Type</i> +- Tipo da partição(veja o exemplo) +<br> <i>First Sector</i> +- Primeiro Setor utilizado para o armazanamento da partição. +<br> <i>Last Sector</i> +- Último Setor utilizado para o armazenamento da partição. +<br> <i>Offset </i> +- +<br> <i> Lenght</i> +- Tamanho total da partição em setores (Last Sector - First +<br> +Sector). +<br> <i> FileSystem +Type (ID)</i> - Identificação do Sistema de Arquivos da partição, +seguido do seu +<br> +código hexadecimal no CFDisk. A <i>partição Extendida</i> +é identificada como +<br> +um sistema de arquivos com o código 05 (veja o exemplo). +<br> <i> Flags </i> +- Opções da partição +seguido de seu valor em hexadecimal. +<p><i><u>Table <t></u></i> : Mostra a tabela de partição +classificada pelo número da partição. +<br> +Esta opção deixa fora todo espaço livre e não +usado na partição. +<br> +Abaixo um exemplo deste formato. +<br> +---------------------------------------------------------------- +<br> +Partition Table for /dev/hda +<p> +---Starting--- ----Ending---- +Start Number of +<br> +# Flags Head Sect Cyl ID Head Sect Cyl +Sector Sectors +<br> +-- ----- ---- ---- ---- ---- ---- ---- +---- -------- --------- +<br> +1 0x80 1 1 +0 0x0B 254 63 143 +63 2313297 +<br> +2 0x00 0 1 +471 0x83 254 63 623 7566615 +2457945 +<br> +3 0x00 0 1 +152 0x05 254 63 470 2441880 +5124735 +<br> +4 0x00 0 1 +624 0x82 254 63 626 10024560 +48195 +<br> +5 0x00 1 1 +152 0x0B 254 63 470 +63 5124672 +<br> +------------------------------------------------------------------- +<br> <b>Onde</b>: +<br> <i>#</i> +- Número da partição de disco +<br> <i>Flags</i> +- As opções utilizadas com a partição (em +valor Hexadecimal). +<br> +O valor <b>0x80</b> equivale a BOOT. +<br> +O valor <b>0x00</b> equivale a nenhuma opção utilizada +naquela partição. +<br> <b>Starting</b> +<br> <i>Head</i> +- Cabeçote Inicial +<br> <i>Sector</i> +- Setor Inicial +<br> <i>Cyl</i> +- Cilindro Inicial +<br> <i>ID</i> +- Identificação do Sistema de arquivos(em hexadecimal, +conforme a +<br> +tabela do CFdisk). +<br> <b>Ending</b> +<br> <i>Head</i> +- Cabeçote Final +<br> <i>Sector</i> +- Setor Final +<br> <i>Cyl</i> +- Cilindro Final +<br> <i>Start +Sector</i> +- Setor inicial da partição +<br> <i>Number +of Sectors</i> - Número de setores ocupados pela partição. +<p> Se a partição não inicia ou +não termina em um cilindro limite do disco ou se o seu tamanho não +é divisível pelo tamanho do cilindro, um <b>*</b> é +será mostrado após o setor não alinhado. Este problema +normalmente ocorre quando a partição é criada por +um Sistema operacional em que o limite da partição não +é alinhada com o cilindro ou que utiliza a contagem do tamanho do +disco +<br>de forma diferente. +<br> A tabela de partição somente tem 10 +bits disponível para identificar o cilindro inicial e final. Assim, +quando o setor inicial absoluto é um cilindro maior que <b>1023</b>(<i>final +do disco</i>), o valor máximo para a cabeça inicial, setor +e cilindro são definidos. Este metodo é usado pelo <i>OS/2</i>, +e +<br>e corrige os problemas associados com <i>OS/2</i> caso o Fdisk regrava +a tabela de partição quanto ela não esta neste formato. +<br> Desde então <i>Linux</i> e <i>OS/2</i> utilizam +esta contagem de setores absolutos, os valores na cabeça inicial +e final, Setor e Cilindro não são usadas. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.3.10"></a><u><font size=+1>2.3.10-) Quit <q></font></u></center> + +<p> Esta opção faz com que o CFdisk +abandonar todas as alterações e retornar para o Aviso de +comando. Quando esta opção é escolhida, o programa +retorna deixando o disco como estava antes de se iniciar o particionamento. +<br> Se escolher esta opção o CFdisk +abandonará o particionamento de disco e voltará para a linha +de comandos imediatamente. Se <i>alterar/criar/excluir</i> alguma partição +de disco e escolher esta opção, o programa emitirá +um Beep indicando que alguma alteração feita no disco foi +abandonada. +<p><b>OBS</b>: Esta opção é útil caso tenha +se cometido algum engano durante o particionamento do disco, +<br> como apagar +por uma partição que contém arquivos, alterar o tamanho +do disco(geometria), +<br> etc. Lembre-se +que tudo o que fez será abandonado, durante o particionamento, se +escolher +<br> esta opção. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.3.11"></a><u><font size=+1>2.3.11-) Type <t></font></u></center> + +<p> Comando usado para alterar o tipo do sistema +de arquivos utilizado pela partição. As partições, +quando criadas, recebem o sistema de arquivos <b>Linux Native</b>(ou simplesmente +Linux - <i>tipo 83</i>). O CFdisk pode criar, manipular, excluir, uma grande +variedade de Sistemas de arquivos para os mais diversos tipos de sistemas +operacionais existentes, veja o final deste manual para ver as partições +compatíveis com este programa. +<br> Para alterar o tipo do sistema de arquivos (<i>File System</i>) +utilizado pela partição, tecle <t>, e digite o valor de +acordo com a lista de partições disponíveis no programa. +<br> Por exemplo, para mudar a partição do tipo +Linux para Linux Swap, selecione esta partição, e tecle <t>, +e digite o número <i>82</i>(que corresponde a <b>Linux Native</b>) +e tecle <Enter>, e a partição terá seu sistema +de arquivos alterado. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.3.12"></a><u><font size=+1>2.3.12-) Units <u></font></u></center> + +<p> A função deste comando é +alterar as unidades de medida do tamanho da partição que +é mostrado na tela, por padrão, ele é mostrado em +MegaBytes. +<br> As unidades de medida do tamanho da partição +são em MegaBytes, Cilindros e Setores ocupados pela partição +de disco. +<br>Abaixo um exemplo da mudança da unidade de medida para Cilindros. +<br>---------------------------------------------------------------------------------------------------- +<center>CFdisk 0.8l +<br>Disk Drive: /dev/hda +<br>Heads:255 Sectors:63 Cilinders:627</center> +---------------------------------------------------------------------------------------------------- +<br>Name +Flags +Part Type FSType +[LABEL] Cilinders +<br>hda1 +Boot +Primary Win 95 FAT 32 +249 +<br>hda5 +Logical DOS FAT 16 (BIG) GLEYDSON +22 +<br> +Pri/Log Free +Space +371 +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<p>[Bootable] [Delete] [Help] [Maximize] +[Print] +<br>[Quit] [Type] +[Units] [Write] +<br>---------------------------------------------------------------------------------------------------- +<br> Será mostrada a quantidade de cilindros que a partição +ocupa no disco ao invés do espaço em MB. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="2.3.13"></a><u><font size=+1>2.3.13-) Write <W></font></u></center> + +<p> Este comando grava todas as tabelas de +partições criadas/modificadas e excluidas para o disco. Só +é aceita a tecla <W> em maiúscula para gravação +da partição de disco, por motivos de segurança para +que não seja feita a gravação acidental das partições +enquando estiver utilizando o programa. Para quem utiliza as setas do teclado, +o método é o mesmo que as outras opções. +<br> Após selecionar esta opção, +o CFdisk perguntará se confirma a gravação das partições +para o disco. +<br>Para gravar a partição, digite "<i>yes</i>" e tecle <Enter>. +<br>Para cancelar o comando, pressione <Esc> ou digite "<i>no</i>" e +tecle <Enter>. +<p> Após confirmar com "<i>yes</i>", o CFdisk +gravará a tabela de partição no disco e fara o Kernel +re-ler a tabela de partição do disco, para se evitar reiniciar +o sistema para utilizar a nova tabela de partição. +<br> A tentativa de re-leitura da tabela de partição +pode falhar. Para solucionar este problema, é preciso reiniciar +o computador, quando o computador é reiniciado, o sistema operacional +faz uma nova leitura das tabelas de partições existentes +no disco, fazendo com que sejam reconhecidas +<br>corretamente. +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="3"></a><u><font size=+1>3-) Tipos de partições +compatíveis com o CFdisk</font></u></center> + +<p> Abaixo uma listagem das partições compatíveis +com o programa <i>CFdisk</i> e seus respectivos códigos H<i>exadecimais</i>, +para consulta técnica ou utilização durante o particionamento +de disco. +<p><b><u>Código</u></b> <b><u>Nome</u></b> +<br>01 - DOS FAT12 +<br>02 - Xenix root +<br>03 - Xenix usr +<br>04 - DOS FAT16 (<32MB) +<br>05 - Extendida +<br>06 - DOS FAT16 (>=32MB) +<br>07 - OS/2 HPFS ou NTFS +<br>08 - AIX +<br>09 - AIX inicializável +<br>0A - OS/2 Boot Manager +<br>0B - Windows 95 FAT32 +<br>0C - Windows 95 FAT32(LBA) +<br>0E - Windows 95 FAT16(LBA) +<br>0F - Windows 95 Extendida +<br>11 - DOS FAT12 oculta +<br>12 - DOS FAT16 oculta +<br>16 - DOS FAT16 oculta +<br>17 - HPFS OS/2 oculta +<br>40 - Venix 80286 +<br>51 - Novell +<br>52 - Microport +<br>63 - GNU Hurd +<br>64 - Novell Netware +286 +<br>65 - Novell Netware +386 +<br>75 - PC/IX +<br>80 - Minix Antigo +<br>81 - Linux / Minix +<br>82 - Linux Swap +<br>83 - Linux Nativa +<br>85 - Linux Extendida +<br>93 - Amoeba +<br>94 - Amoeba BBT +<br>A5 - BSD/386 +<br>A6 - Open BSD +<br>A7 - NextStep +<br>B7 - BSDI Sistema de +Arquivos +<br>B8 - BSDI Swap +<br>C7 - Syrinx +<br>DB - CP/M +<br>E1 - DOS access +<br>E3 - DOS R/O +<br>F2 - DOS secundária +<br>FF - BBT +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="4"></a><u><font size=+1>4- ) Direitos Autorais</font></u></center> + +<p> Este documento foi desenvolvido com base +em minha experiência e conhecimento em discos e partições, +mediante pesquisa em alguns documentos como os How-TO do Linux e verificando +as principais dúvidas de usuários durante a utilização +de particionadores de disco, tendo como objetivo levar o conhecimento sobre +discos, partições e utilização deste programa, +atendendo tanto usuários iniciantes como avançados e como +contribuição para a comunidade Linux em geral. +<center> +<p>Gleydson M. da Silva (<i>gleydson_s@yahoo.com</i> e <i>gleydson@linuxbr.com.br</i>)</center> + +<p> Qualquer dúvida, sugestão ou reclamação +podem ser mandadas para um dos E-Mail's Acima. Conto com sua contribuição +para a melhoria deste Manual. +<p><b> Autorizo a reprodução Total ou parcial +deste texto para que seja utilizado para fins educativos, autoaprendizado, +colocação em Home pages e qualquer outra forma de distribuição +não comercial do documento desde que sejam mantidos os meus créditos +pela pesquisa e elaboração deste documento de acordo com +os termos da GNU (veja abaixo <a href="#6">Licenças e Garantias +sobre este documento</a>).</b> +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="5"></a><u><font size=+1>5- ) Licenças e Garantias +sobre este documento</font></u></center> + +<p>CFdisk-Portuguese copyright (C) 1999 Gleydson M. da Silva +<p> Este documento é de livre distribuição, +que pode ser copiado e distribuído sob os termos da Licença +Pública Geral GNU, conforme publicada pela Free Software Foundation, +versão 2 da licença ou (a critério do autor) qualquer +versão posterior. +<p><b> Este documento é distribuído com a itenção +de ser útil ao seu utilizador, no entanto NÃO TEM NENHUMA +GARANTIA, EXPLÍCITAS OU IMPLÍCITAS , COMERCIAIS OU +DE ATENDIMENTO A UMA DETERMINADA FINALIDADE. Consulte a Licença +Pública Geral GNU para maiores detalhes.</b> +<p><i>gleydson_s@yahoo.com</i> +<br><i>gleydson@linuxbr.com.br</i> +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="6"></a><u><font size=+1>6- ) Nota sobre Marcas Registradas</font></u></center> + +<p>Os programas mencionados neste manual são de propriedade dos +seus respectivos donos: +<p>MS-DOS, Windows 3.1x, Windows 9x, Windows NT são de propriedade +da Microsoft. +<br>OS/2 e OS/2 Warp são de propriedade da IBM +<div align=right><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<center> +<p><br><a NAME="7"></a><u><font size=+1>7- ) Agradecimentos</font></u></center> + +<p>Agradeço a todas as pessoas que me mandam correções, +comentários, críticas e elogios sobre este documento, pois +através destas mensagens, estão contribuindo para a melhoria +deste projeto. +<p><b>Agradecimentos especiais a:</b> +<p><b>Eduardo Marcel Macan</b> <i><macan@thecore.com.br></i> - Pelo +apoio e interesse na divulgação +<br> +deste projeto e outros documentos relacionados com a tradução +e divulgação de +<br> +documentos do Linux no Brasil. +<br><b>Jorge Godoy</b> <i><jorge@bestway.com.br></i> - Pela revisão +deste documento e primeiras orientações +<br> +para a conversão deste para SGML. +<br><b>Adam di Carlo</b> <i><adam@onshore.com></i> - Que me deu apoio +na colocação deste +<br> +documento na documentação da distribuição +Debian. +<p>E a voce pelo enteresse em conhecer mais sobre o Linux. +<div align=right> +<br><i><a href="#Indice">Voltar ao Indice</a></i></div> + +<br> +<p><EOF> +</body> +</html> diff --git a/fdisk/doc/CFdisk-Portuguese.txt b/fdisk/doc/CFdisk-Portuguese.txt new file mode 100644 index 000000000..99981c4df --- /dev/null +++ b/fdisk/doc/CFdisk-Portuguese.txt @@ -0,0 +1,1236 @@ + CFdisk-Portuguese Copyright (C) 1999 Gleydson M. da Silva + + + + + + + + Gleydson M. da Silva - gleydson@linuxbr.com.br + Versão: 1.68 + + + + + + + +[ Indice ] + +1 - Introdução ao CFdisk + 1.1 - O que é uma partição de disco + 1.2 - O que é a tabela de partição + 1.3 - Introdução ao Particionamento de Discos + 1.4 - Identificadores utilizados neste manual + 1.5 - Identificação de discos e partições no Sistema Linux + 1.6 - Tipos de partições de disco + 1.7 - Observações sobre o formato DOS 6.xx(FAT16) + +2 - Iniciando o programa CFdisk + 2.1 - Opções de Linha de comando + 2.2 - Conhecendo a tela do CFdisk + 2.3 - Descrição dos comandos + 2.3.1 - Setas Acima/Abaixo - Esquerda/Direita + 2.3.2 - <CTRL>+<l> + 2.3.3 - Boot + 2.3.4 - Delete + 2.3.5 - Geometry + 2.3.6 - Help + 2.3.7 - Maximize + 2.3.8 - New + 2.3.9 - Print + 2.3.10 - Quit + 2.3.11 - Type + 2.3.12 - Units + 2.3.13 - Write + +3 - Tipos de partições compatíveis com o CFdisk + +4 - Direitos Autorais + +5 - Licenças e Garantias sobre este documento + +6 - Notas sobre marcas registradas + +7 - Agradecimentos + + + + + + + + + + + +1-) Introdução ao CFdisk + +CFdisk é um programa utilizado para fazer o particionamento de discos, +utilizando uma interface em modo texto. + +A grande características deste programa, além de sua interface de comunicação +com o usuário e a enorme quantidade de partições que manipula, é a grande +facilidade de operação, o seu poder de manipulação de partições e a sua +precisão que fazem com que o usuário tenha mais confiança durante o +particionamento de disco. + +É recomendável a leitura deste texto, mesmo que tenha uma noção sobre o +particionamento de discos, exceto para os gurus que já conhecem a fundo a +forma de trabalho, em geral, de programas deste tipo, pois o particionamento +de disco pode destruir os seus arquivos e partições já existentes, se for +usado de forma incorreta. + +O programa CFdisk pode ser utilizado em qualquer sistema operacional que +esteja de acordo com o padrão POSIX (Linux, UNIX, FreeBSD, HPUX, etc). + +A versão do CFdisk utilizada nas explicações deste manual é a 0.8, mas +isto não impede que este manual seja utilizado com versões futuras ou +anteriores deste programa. As características principais +do programa CFdisk e as explicações sobre particionamento, são válidas para +quaisquer versões deste programa. + +Este documento é distribuído com a itenção de ser útil ao seu utilizador, +no entanto NÃO TEM NENHUMA GARANTIA, EXPLÍCITAS OU IMPLÍCITAS , COMERCIAIS +OU DE ATENDIMENTO A UMA DETERMINADA FINALIDADE. Consulte a Licença Pública +Geral GNU para maiores detalhes. + + +1.1-) Partição de Disco + +Uma partição de disco é o local onde o sistema operacional armazena seu +sistema de arquivos(arquivos, diretórios, FAT, boot sector, etc). + + + +1.2-) Tabela de partição + +A Tabela de partição é o local do disco rígido onde se localizam os dados sobre +todas as partições existentes no disco como o sistema de arquivos utilizado, se +ela é inicializável, a cabeça inicial/final, setor inicial/final, cilindro +inicial/final, número de setores ocupados por ela no disco. + + +1.3-) Introdução ao particionamento de discos + +Particionar o disco rígido é dividir ele em partes para armazenamento +de arquivos e programas. As partições criadas no disco podem ter o tamanho +que desejar (desde que esteja dentro da capacidade máxima do disco rígido). + +Uma partição não interfere em outras partições do mesmo disco(é como +se tivessemos vários discos rígidos dentro de um), e nem em outros discos +rígidos(caso possuir mais que um disco rígido instalado em seu computador). + +Pode ser criada uma partição única, que neste caso todo o disco rígido +é usado para armazenar os arquivos(que é o caso mais comum caso voce tenha +o DOS), ou várias partições, que podem ser usadas pelo mesmo SO(Sistema +Operacional) ou outros sistemas operacionais diferentes(um exemplo de várias +partições: se for usar o DOS e o Linux no mesmo disco, os dois sistemas vão +estar no mesmo disco mas um não interfere no outro). + +ATENÇÃO : A OPERAÇÃO DE PARTICIONAMENTO DE DISCOS PODE FAZER COM QUE OS DADOS + ARMAZENADOS EM SEU DISCO RÍGIDO SEJAM PERDIDOS, SE FOR USADA + INCORRETAMENTE. É SEMPRE RECOMENDADO RETIRAR UMA CÓPIA DE SEGURANÇA + DOS SEUS ARQUIVOS EXISTENTES NO MICRO ANTES DE SE EXECUTAR UM + PROGRAMA DESTE TIPO, A NÃO SER QUE TENHA CONFIANÇA NO QUE ESTA + FAZENDO E QUE ENTENDEU AS EXPLICAÇÕES SOBRE A IDENTIFICAÇÃO DE + DISCOS RÍGIDOS E SUAS PARTIÇÕES NO SISTEMA. + +Neste manual voce aprenderá como deve particionar seu disco rígido para +a instalação do SO usando o programa CFdisk. + + +1.4-) Algumas identificações utilizadas neste manual para facilitar a + compreensão do texto + +Esta parte descreve algumas características de organização deste manual e +algumas identificações que utilizei para facilitar o seu entendimento, e as +explicações que serão dadas. + +Explicação de nomes e comandos, sera seguida da palavra "onde:" e abaixo +dela as explicações sobre os comandos, exemplo: + +onde: +nome a ser explicado1 : Descrição +nome a ser explicado2 : Descrição +nome a ser explicado3 : Descrição + +ou + +onde: +nome a ser explicado1 - Descrição +nome a ser explicado2 - Descrição +nome a ser explicado3 - Descrição + + +Quando for feita alguma referência com tecla do teclado, por exemplo, +pressione p para listar as partições, a letra sera colocada entre <> para +que seja melhor entendida: + +pressione <d> para deletar uma partição... +...pressione <Enter> para escolher a opção do menu. +pressione <t> para listar os tipos de partições disponíveis... + + + As linhas pontilhadas que aparecem na tela, veja abaixo, +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +servem para identificar que o que esta entre as linhas é um exemplo de como +será a resposta do comando para a tela de seu computador. + + + +1.5-) Identificação de discos e partições no Linux + +Antes de descrever como se utiliza o programa CFdisk, é importante fazer +algumas explicações sobre a identificação das partições e unidades de disco +no sistema Linux( e outros *nix). + +Se voce for um usuário que já conhece a interpretação de discos e partições +neste sistema, voce não precisará ler esta parte. + +No sistema operacional Linux, os dispositivos existentes no computador +(como impressoras, unidades de disquetes, discos rígidos, monitor, placa de +som, etc...) são identificados por um nome referente a este dispositivo e +colocado no diretório /dev (que é utilizado para identificar os dispositivos +ou periféricos existentes no computador). + + A identificação dos discos rígidos segue a seguinte forma: + + /dev/hda1 + | | || + | | ||_Número que identifica a partição do disco rígido(1=Primeira, 2=segunda) + | | | + | | |_Letra que identifica o disco rígido(a=primeiro disco, b=segundo disco, etc..) + | | + | |_Sigla HD - Significa que é um disco rígido IDE(Se tiver um SD significa SCSI) + | + |_ Identificação do diretório onde os dispositivos do sistema são armazenados + +OBS: As unidades de disco rígido SCSI, são identificadas com as letras SD + seguida pela letra da unidade e número da partição e os discos IDE são + identificados por HD seguida pela letra da unidade de disco e o número + da partição do disco(como visto acima). + +Abaixo, algumas identificações de disco do sistema Linux: + +/dev/hda1 - Disco rígido IDE primário principal - Primeira partição +/dev/hda2 - Disco rígido IDE primário principal - Segunda partição +/dev/hda3 - Disco rígido IDE primário principal - Terceira partição +/dev/hdb1 - Disco rígido IDE primário escravo - Primeira partição +/dev/hdb2 - Disco rígido IDE primário escravo - Segunda partição +/dev/hdb3 - Disco rígido IDE primário escravo - Terceira partição +/dev/hdc1 - Disco rígido IDE secundário principal - Primeira partição +/dev/hdc2 - Disco rígido IDE secundário principal - Segunda partição +/dev/hdc3 - Disco rígido IDE secundário principal - Terceira partição +/dev/hdd1 - Disco rígido IDE secundário escravo - Primeira partição +/dev/hdd2 - Disco rígido IDE secundário escravo - Segunda partição +/dev/hdd3 - Disco rígido IDE secundário escravo - Terceira partição +/dev/sda1 - Primeiro disco rígido SCSI - Primeira partição +/dev/sda2 - Primeiro disco rígido SCSI - Segunda partição +/dev/sda3 - Primeiro disco rígido SCSI - Terceira partição +/dev/sdb1 - Segundo disco rígido SCSI - Primeira partição +/dev/sdb2 - Segundo disco rígido SCSI - Segunda partição +/dev/sdb3 - Segundo disco rígido SCSI - Terceira partição + +No exemplo acima foram usadas 3 partições por disco, mas podem existir mais +partições no mesmo disco, um exemplo é se o disco rígido possuir partições +Lógicas, que são identificadas no sistemas a partir de /dev/hdx5. + + + +Abaixo um exemplo de como o Linux identifica as partições em cada disco +existente em seu computador: + +Vamos supor que eu tenha 2 discos rígidos: +o 1ºdisco de 2GB e o 2ºdisco de 1GB(Giga Byte ou 1.000 Megas!) + +No primeiro disco(de 2GB), a primeira partição é de 800MB do tipo +FAT16(DOS), a segunda partição é de 1.2GB do tipo EXT2(Linux)(1.2GB+800MB=2GB +que é a capacidade total do disco). Então as partições seriam identificadas +da seguinte forma no Linux: + +/dev/hda - Disco rígido Primário Principal +/dev/hda1 - Primeira partição do primeiro disco rígido (de 800MB do tipo DOS) +/dev/hda2 - Segunda partição do primeiro disco rígido( de 1.2GB do tipo Linux) + +Neste caso estariam disponíveis 800MB para serem usados com o DOS e +1.2GB para o Linux. + +Por exemplo, se voce particionar um disco rígido em duas partes e usar +as duas partições no DOS, ele reconhecerá as partições como sendo C: e D:. + +Lembre-se: Quando um disco é particionado, nenhuma partição interfere + na outra, repare que quando voce particiona(divide) um disco, + é como se tivesse dois discos rígidos(o único cuidado que + voce deve tomar é com as cópias de segurança, porque se der + um problema de parte eletrônica no disco rígido, por exemplo, + a sua placa controladora queimar ou o cabeçote dele ir pro + espaço, voce perderá as suas 2 partições que estão armazenadas + nele. + + +Voltando ao exemplo das classificações das partições do disco, vamos +para o segundo disco: + +No segundo disco(1GB), eu tenho uma partição de 950MB do tipo FAT16(DOS), +que costumo usar para armazenar arquivos temporários e cópias de segurança +de meu sistema, etc..., e outra de 50MB SWAP(Partição de memória virtual +como descrevi acima)(950MB+50MB=1GB). Então as partições deste disco seriam +identificadas da seguinte forma no Linux: + +/dev/hdb - Disco rígido principal escravo +/dev/hdb1 - Primeira partição do disco acima ( de 950MB do tipo DOS) +/dev/hdb2 - Segunda partição do disco acima ( de 50MB do tipo SWAP) + +No disco acima, 950MB estão disponíveis para serem usados pelo DOS e +50 MB pela memória virtual (SWAP) do Linux. + +Note que se voce utiliza o MS-DOS, voce não conseguirá ver as partições +do Linux e SWAP, porque são imcompatíveis com o formato aceito pelo DOS (ele +identificaria a primeira partição do primeiro disco(800MB) como a unidade C: +e a primeira partição do segundo disco(950MB) como unidade D), mas o +contrário não acontece; O Linux tem total compatibilidade com a partição +DOS FAT12, FAT16, FAT32, OS/2 HPFS, e muitas outras. + + + +1.6-)Tipos de partições de discos + +As partições de disco são divididas em tres tipos: Primária, Extendida +e Lógica. +Pode se ter, no máximo, 4 partições Primárias e Extendidas no mesmo disco +(3 Primárias e 1 Extendida ou 4 partições Primárias em cada disco). +A partição Primária permite o armazenamento de arquivos e diretórios. + +Todos os computadores que possuem somente a unidade C(supondo que utilize +o DOS), utilizam este tipo de partição para armazenamento de arquivos e +inicialização do sistema operacional. + +Se for preciso criar mais que 4 partições no mesmo disco, será necessário +criar uma partição Extendida. A partição Extendida não pode ser utilizada +para armazenar arquivos. Ela é usada para a criação de outras partições, +dentro dela, que são chamadas de partições Lógicas. + +Uma partição extendida podem conter várias partições Lógicas. As partições +Lógicas podem armazenar arquivos e diretórios(como as partições primárias). + +Um mesmo disco rígido pode armazenar mais de 64 partições independentes +uma das outras. + +LEMBRE-SE: Os arquivos e diretórios podem ser armazenados somente em + partições de disco primárias ou lógicas, a partição extendida não + é usada para armazanamento de arquivos e diretórios. + +Se possuir duas partições em seu computador (C: e D: no DOS), e não +estiver usando a partição D:, a instalação pode ser feita nesta partição +desde que ela tenha o espaço necessário para o sistema operacional Linux, +os programas que desejar instalar, mais a partição SWAP. + + + +1.7-) Observações sobre o formato DOS 6.XX(FAT 16) + +No formato DOS 6.XX(FAT16), o primeiro setor da área de dados da partição +é utilizado frequentemente pelo DOS para armazenamento de dados sobre a +partição de disco, e estes dados são usados pelo sistema para se ter maior +confiabilidade do que os dados armazenados na tabela de partição. O sistema +de arquivos DOS, faz o FDISK(do DOS) limpar os primeiros 512 bytes da área +de dados da partição sempre que uma mudança de tamanho acontecer. + +O formatador do DOS(format) verifica este primeiro setor toda vez que +a upção /U (que é utilizada para não salvar dados para se fazer a desformatação +do disco) é utilizada. + +Isto é considerado uma FALHA no Format(do DOS) e no Fdisk(do DOS). +A opção abaixo deve ser utilizada caso voce crie uma partição do DOS FAT16 +com o CFdisk, que faz com que os primeiros 512 bytes daquela partição +sejam "limpos", para manter a compatibilidade com o DOS. Utilize esta opção +dentro do Linux, após criar a partição com o CFdisk e reiniciar o seu +computador. Foi notado que esta opção só funciona corretamente somente quando +o Sistema Linux estiver instalado em seu computador. Não me responsabilizo +caso utiliza-la a partir de um disquete de recuperação. + +dd if=/dev/zero of=/dev/hdx1 bs=512 count=1 + +onde: +hdx1 - É a identificação da unidade de disco e a partição que foi criada + pelo CFdisk utilizando o sistema de arquivos DOS que terá seu + primeiro setor "limpo". + + +OBS1: Cuidado ao utilizar esta opção, um pequeno descuido pode resultar na + perda de dados do seu disco rígido ou outras partição. + +OBS2: Não utilize este comando com partições que utilizam o sistema de arquivos + FAT32(utilizada nos sistemas operacionais Windows 95 OSR/2 e superiores) + se for utilizada em um disco com este sistema, sua FAT será corrompida, + se isto acontecer, será necessária a re-formatação da partição. + +OBS3: É extremamente recomendado que se utilize o programa de particionamento + que acompanha o seu sistema operacional. Por exemplo, se deseja criar + uma partição DOS 6.XX, utilize o FDisk qua acompanha o DOS. + + + +2-) Iniciando o programa CFdisk + +Para entrar no programa CFdisk digite: +cfdisk <unidade> + +onde: +unidade - é a unidade de disco que deseja utilizar para fazer o particionamento + a unidade pode ser: /dev/hda, /dev/hdb, /dev/hdc ..., /dev/sda, + /dev/sdb...,etc + +NOTA: Se voce não digitar a unidade, o cfdisk utilizará a unidade /dev/hda + como padrão. + + + +2.1-) Opções de linha de comando utilizadas com o CFdisk + +Opções de linha de comando fazem com que o programa inicie de forma +específica ou personalizada. As opções devem ser digitadas após o nome do +programa (cfdisk). + + cfdisk <unidade> < -avz > < -c cilindros > < -h cabeçotes > + < -s setores_por trilha > < -P opt > < dispositivo > + +onde: +-a Usa um cursor seta ao invés de video reverso para destacar a + partição atual. +-v Mostra a versão do programa e Coyright(Direitos Reservados). +-z Ignora a leitura da tabela das partições existentes no disco + ao iniciar o CFdisk. + +-c Número de Cilindros do disco +-h Número de Cabeçotes do disco +-s Setores por trilha existentes no disco. +-P OPC Mostra a tabela de partição no formato especifico. + OPC - Pode ser: r - Mostra a tabela de partição em Formato RAW + s - Mostra a tabela de partição em Format de Setores + t - Mostra a tabela de partição classificada por + setores + Para maiores detalhes, veja O comando Print <p>. + +OBS: A utilização dos parâmetros -c -h -s, substituirão os parâmetros da BIOS + da placa, utilize estas opções se sua bios não utilizar estes parâmetros + ou se mostrar valores incorretos. + +Após entrar o programa CFdisk, ele verificará automaticamente o +tamanho do Disco Rígido, se não conseguir, o programa será terminado. +Para resolver este problema, especifique o tamanho do disco em cilindros, +cabeças, e setores na linha de comando que inicia o programa. +Este problema geralmente acontece quando se tenta particionar uma unidade de +disco SCSI que esteja conectada a uma placa controladora que não possui BIOS, +e quando uma BIOS mostra os valores da geometria do disco(tamanho) +incorretamente. + +O próximo passo do CFdisk é fazer a leitura das partições atuais do +disco, se não conseguir, o programa será terminado. O único motivo para o +CFdisk mostrar esta mensagem de erro, é se voce digitar parâmetros +incorretos para o tamanho do disco, caso tenha acontecido o problema +descrito no paragrafo anterior. Verifique se os parâmetros foram digitados +incorretamente, se os parâmetros estiverem digitados corretamente e mesmo +assim o programa continua dando erro na leitura das partições, utilize a +opção -z na linha de comando do programa, que faz com que ele ignore a +leitura das partições existentes no disco ao iniciar. + + + +2.2-) Conhecendo a Tela do CFdisk + +Após digitar CFdisk, será mostrada a tela principal onde voce poderá +acionar os comandos para manipulação das partições de disco, e visualizar +as partições de disco atuais e outros dados. Abaixo o exemplo e explicações +sobre esta tela. + +O disco utilizado para os exemplos é um disco de 5157 MB de Capacidade com: +- 10672 Cilindros 15 Cabeças 63 Setores (no modo C/H/S) +- 627 Cilindros 255 Cabeças 63 Setores (no modo LBA) + + A unidade de medida utilizada pelo CFdisk para mostrar os parâmetros do +disco será o mesmo configurado na BIOS, ou seja, se estiver utilizando o +disco com o modo de operação em LBA, os valores de cilindros, cabeças e +setores motrados pelo CFdisk sera em LBA. + + +---------------------------------------------------------------------------- + CFdisk 0.8l + + Disk Drive: /dev/hda + Heads:255 Sectores per track:63 Cylinders:627 +----------------------------------------------------------------------------- +Name Flags Part Type FSType [LABEL] Size(MB) +hda1 Boot Primary Win 95 FAT 32 1953.12 +hda5 Logical DOS FAT 16 (BIG) GLEYDSON 172.58 + Pri/Log Free Space 2910.55 + + + + + + + + + + +[Bootable] [Delete] [Help] [Maximize] [Print] +[Quit] [Type] [Units] [Write] +---------------------------------------------------------------------------- +No cabeçalho da tela, é mostrada a versão do programa, a unidade de disco +que será usada no particionamento e os parâmetros de tamanho do disco(cabeçotes, +cilindros e setores). +Abaixo do cabeçalho após a linha pontilhada, se encontra a área das partições. + +onde: +- Name : é o nome da(s) partição(ões) de Disco. +- Flags : Se estiver marcada como BOOT, será possível iniciar o sistema + a partir desta partição(quando não se utiliza um Boot Manager). + Se estiver marcada como NC (Não compatível) significa que esta + partição não é compatível com o DOS, OS/2, etc. Para maiores + detalhes, veja O comando Maximize <m>. +- Type : O tipo da partição pode ser Primária ou Lógica. Para espaço não + utilizado no Disco, o tipo da partição pode ser Primário/Log. +- FileSystems : Tipo de Sistema de Arquivos que é usado naquela partição. + Se o sistema de arquivos for desconhecido, ele será mostrado como + um valor Hexadecimal. + Um caso especial ocorre quando há Partições do Disco Rígido que + não podem ser usadas ( porque toda a partição primária esta em uso). + Quando isto é detectado, o tipo de FileSystems é mostrado como não + usável(Unusable) para criação de novas partições. +- Label : Nome de volume da partição de disco. Os nomes de partições FAT32, + não são mostrados com esta versão do CFdisk. +- Size : Mostra o tamanho que cada partição ocupa no disco rígido em + MegaBytes (por padrão). Também pode mostrar o tamanho ocupado por + Setores ou Cilindros. Se for mostrado um asterisco (*) após o + tamanho, isto diz que a partição não esta alinhada com Cilindro. + + +O espaço livre existente no disco para criação de novas partições, é +mostrado como uma outra partição, com o FSType(sistema de arquivos) Free +Space(espaço Livre). + +OBS: As partições de disco Extendidas não são mostradas na tela do CFdisk + durante o particionamento, mesmo assim, as partições lógicas que este + tipo de partição armazena, serão mostradas. + +No rodapé da tela, encontramos os comandos utilizados pelo CFdisk para +manipular as partições de disco. Os comandos são mostrados entre Chaves []. + +Todos os comandos no rodapé da tela, são aplicaveis somente para a +partição que estiver destacada com a barra(video reverso). Veja descrições +dos comandos do CFdisk para mais detalhes. + +Abaixo do rodapé da tela, é mostrada a descrição do comando que estiver +em destaque com o cursor em video reverso. + + Veja abaixo a tradução da tela principal do programa CFdisk: +---------------------------------------------------------------------------- + CFdisk 0.8l + + Unidade de Disco: /dev/hda + Cabeças:255 Setores por trilha:63 Cilindros:627 +----------------------------------------------------------------------------- +Nome Opções Tipo Part. Tipo Sist. Arquivos [VOLUME] Tamanho(MB) +hda1 Boot Primary Win 95 FAT 32 1953.12 +hda5 Logical DOS FAT 16 (BIG) GLEYDSON 172.58 + Pri/Log Espaço Livre 2910.55 + + + + + + + + + + +[Inicializável] [Apagar] [Ajuda] [Maximizar] [Imprimir] +[Sair] [Tipo] [Unidades][Gravar] +---------------------------------------------------------------------------- + + + +2.3-) Descrição dos comandos do CFdisk + +Os comandos do programa são utilizados criar partições, entrar na ajuda do +programa, alterar o tipo da partição, apagar uma partição, etc. + +Pode ser utilizado Seta p/ Esquerda e Seta p/ direita para se movimentar +entre os comandos, quando o cursor estiver em cima do comando que deseja +executar, pressione <Enter>. + +Outro método que se pode utilizar para acionar uma opção do CFdisk, é +pressionando a primeira letra de cada opção, automaticamente a opção é +executada(sem ter que pressionar <Enter>). Neste método, todos os comandos +aceitam letras maiúsculas e minúsculas, exceto o comando Write(gravar +partição) que é executado somente se pressionar <W> maiúscula, para evitar +gravações acidentais o disco. + +Quando estiver em um Sub-Menu e desejar retornar ao menu principal, +pressione a tecla <Esc>. + + + +2.3.1-) Setas Acima e Abaixo/ Esquerda e Direita (Movimentação do Cursor) + +Setas Acima e Abaixo são utilizadas para se movimentar entre as partições +existentes no disco e espaço livre, selecionando-a para que seja utilizada +as opções do CFdisk. + +Setas Esquerda e Direita são utilizadas para selecionar entre as opções +diponíveis do programa(que serão explicadas abaixo). Para confirmar uma +opção, pressione <Enter>. + + + +2.3.2-) O comando <CTRL>+<l> + +Este comando é utilizado para atualizar a tela manualmente caso a +atualização automática falhar, por exemplo, quando uma partição for +excluida, e continuar a ser mostrada na tela. + + + +2.3.3-) O comando Boot <b> + +Este comando permite escolher se a partição Primária atual será utilizada +para iniciar o sistema(BOOT). Selecione esta opção para selecionar entre +partição inicializável ou não inializável. Quando uma partição estiver +marcada como inicializável, aparecerá a palavra BOOT na coluna Flags(na tela +principal do programa). + +OBS: Não será necessário marcar a partição Linux como inicializável, caso se + esteja utilizando um Boot Manager para escolher qual sistema operacional + sera utilizado para inicializar o sistema. + + + +2.3.4-) O comando Delete <d> + +Este comando apaga a partição selecionada do disco. Após apagar a partição, +o espaço ocupado por ela é convertido para espaço livre. +A partição marcada atualmente como Free Space ou como Unusable não pode +ser apagada. + + + +2.3.5-) O comando Geometry <g> + +Este comando não é mostrado no menu, pois é utilizado para alterar o +tamanho (Cilindros, Cabeças e Setores do disco). Este comando só pode +ser acionado se for pressionada a tecla <g>. + +ALERTA: Esta opção é recomendada somente para aqueles que sabem os riscos + que o uso desta opção pode fazer, e se a situação que estão, requerem + o seu uso. + +Uma situação que esta opção é util, é se o BIOS do seu computador não +mostrar corretamente os parâmetros do disco(Cilindros, Cabeçotes ou Setores), +sendo necessário que se passe manualmente o tamanho do disco para que seja +feito o correto particionamento do disco. + +OBS: Caso seu disco rígido for SCSI e placa controladora dele não tiver BIOS, + provavelmente o CFdisk não será iniciado. Se este problema ocorrer, + digite os parâmetros do disco na linha de comando ao iniciar o programa. + Para maiores detalhes, veja opções de linha de comando do CFdisk. + +Após pressionar <g> será mostrada a seguinte tela: + +---------------------------------------------------------------------------- + CFdisk 0.8l + + Disk Drive: /dev/hda + Heads:255 Sectors:63 Cilinders:627 +----------------------------------------------------------------------------- +Name Flags Part Type File System [LABEL] Size(MB) +hda1 Boot Primary Win 95 FAT 32 1953.12 +hda5 Logical DOS FAT 16 (BIG) GLEYDSON 172.58 + Pri/Log Espaço Livre 2910.55 + + + + + + + + + +[ Cylinders] [Heads] [Sectors] [Done] + +---------------------------------------------------------------------------- +onde: +Cylinders: Altera o número de Cilindros do disco atual durante o particionamento. +Heads : Altera o número de Cabeças do disco atual durante o particionamento. +Sectors : Altera o número de Setores do disco atual durante o particionamento. +Done : Quando finalizar as alterações, tecle <d> ou selecione Done para + que o CFdisk modifique os valores de Cilindros, Cabeças e Setores + que utiliza para particionar o disco e retorne a tela anterior. + + + Quando escolher algum parâmetro acima para alteração(Cilindros, cabeçotes +ou Setores do disco), será vista uma tela como esta: +---------------------------------------------------------------------------- + CFdisk 0.8l + + Unidade de Disco: /dev/hda + Cabeças:255 Setores por trilha:63 Cilindros:627 +----------------------------------------------------------------------------- +Nome Opções Tipo Part. Tipo Sist. Arquivos [VOLUME] Tamanho(MB) +hda1 Boot Primary Win 95 FAT 32 1953.12 +hda5 Logical DOS FAT 16 (BIG) GLEYDSON 172.58 + Pri/Log Espaço Livre 2910.55 + + + + + + + + + +Enter the number of Cylinders: 627 + +---------------------------------------------------------------------------- +O valor que aparece ao selecionar a opção, é o valor que o disco esta +utilizando atualmente(cilindros), e será pedido que digite um valor para os +Cilindros, que substituirá os da BIOS durante a seção de particionamento. +Para sair desta tela sem alterar o valor, pressione <ESC>. A mesma tela e +explicação se aplicam para as alterações de Cabeças e Setores. + +OBS: Se por acaso digitar um valor incorretamente para o tamanho do disco e + não se lembrar mais do valor antigo ou original, selecione a opção Done, e + tecle <q> para sair do CFdisk sem gravar as alterações feitas para o + disco, pois se continuar a utilizar o CFdisk com o tamanho do disco + incorreto, os dados existentes nele e até mesmo partições poderão ser + perdidos(as). + +Se aumentar o tamanho do disco, setores adicionais são acrescentados no +final do disco, e são mostrados como espaço livre. +Se diminuir o tamanho do disco, as partições que estavam localizadas após +o setor/cilindro que foi excluido(se existir alguma), será apagada e a +última partição(ou espaço livre ao final do disco rígido), terá seu +tamanho alterado e terminará neste "novo" último setor do disco. + + + +2.3.6-) O comando Help <h> ou <?> + +O comando Help mostra a tela de ajuda do programa, que descreve as funções +das teclas utilizadas pelo programa e suas funções. + + + +2.3.7-) O comando Maximize <m> + +Este comando aumenta a utilização de espaço do disco na partição atual. +Isto porque o DOS, OS/2 e outros sistemas operacionais utilizam o primeiro +setor da primeira trilha da partição do disco e em todas as partições Lógicas +para iniciar o sistema operacional, utilizando a segunda trilha em diante +daquela partição para fazer o armazenamento de arquivos. Este espaço perdido +entre o segundo e o último Setor da primeira trilha da primeira cabeça, pode +ser recuperado com a utilizando este comando. + +Este comando faz com que a partição se torne imcompatível com DOS, OS/2 +e outros Sistemas Operacionais que utilizam este primeiro Setor do disco +para iniciar o sistema operacional. + +Se este comando for utilizado, será colocada uma opção chamada NC(não +compatível) em Flags(na tela principal do CFdisk). + +Esta opção faz o uso máximo do disco e a incompatibilidade com o DOS/OS/2, +etc. O padrão quando criando uma Partição, é criando Partições compativeis +com o DOS, OS/2, etc. + +OBS: O Fdisk(8) e partições formatadas com o sistema de arquivos FAT32, fazem + a utilização completa deste espaço entre o segundo e o último Setor da + primeira trilha do disco, eliminando o desperdício de espaço. + + + +2.3.8-) O comando New <n> + +O comando New<n>, cria uma nova partição usando o espaço livre(FreeSpace) +existente no disco. Após escolher esta opção, o CFdisk perguntará se deseja +criar uma partição Primária, Lógica ou Cancelar o comando. + +Escolhendo criar uma partição Primária ou Lógica, o sistema perguntará o +tamanho da partição que deseja criar, por padrão, o CFdisk mostrará o espaço +livre total disponível no disco para a criação da nova partição(em MegaBytes). +Tecle <Enter> para criar uma partição do tipo escolhido com este tamanho ou +digite um tamamho menor. O CFdisk permite que seja digitados valores em: + +- MegaBytes(M - o padrão do programa) +- KiloBytes(K) +- Cilindros(C) +- Setores(S) + +Digitando-se o tamanho da partição seguida de uma das letras acima. Se a +letra não for digitada, o programa assumirá o tamanho que digitou em MegaBytes. + +OBS1: Quando criar uma partição Lógica, automaticamente será criada uma + partição extendida, entre hdx1 e hdx4, e a partição Extendida não é + mostrada na tela de particionamento de disco. Se desejar exibir a + partição extendida, execute o comando PRINT <p> e escolha a opção + Sector para verificar qual é a identificação da partição Extendida + no disco. Para maiores detalhes, veja o comando PRINT <p>. + +OBS2: São permitidas, no máximo, 4 partições Primárias e Extendidas(3 Primárias + e 1 Extendida ou 4 partições Primárias em cada disco). O CFdisk + calculará automaticamente os valores das partições lógicas caso + as primeiras 4 partições forem ocupadas. + +O próximo passo, é a localização da partição no espaço livre existente no +disco. As duas opções disponíveis são: + +- Beginning : A partição é colocada a partir do inicio do espaço livre no + disco, ocupando o espaço livre de acordo com o seu tamanho + (do início para o fim do espaço livre ), este é o padrão para + a criação de novas partições e o mais utilizado. Veja o exemplo, + a criação de uma partição de 30MB em um disco com 50MB de + espaço não particionado, sendo que este disco já possui uma + partição de 120MB(com espaço total de 170MB) + + ##################################MMMMMMMMMMMMMMMMMMMMMMMMMM + | | + Partição existente(120MB) Espaço Livre(50MB) + + + com a nova partição criada: + + ###################################################MMMMMMMMM + | | | + Partição existente(120MB) Nova partição Espaço + (30MB) Livre + +- End : A partição é criada subtraindo-se o espaço livre total do disco + pelo tamanho da partição que será criada, começando a criar + esta partição a partir do ponto que resultou esta subtração. + Veja abaixo no exemplo, a partição que será criada terá o + tamanho de 30MB e existe no disco um espaço não particionado + de 50MB, com 120MB já ocupados por uma partição existente: + + ##################################MMMMMMMMMMMMMMMMMMMMMMMMMM + | | + Partição existente(120MB) Espaço Livre(50MB) + + + com a nova partição criada (Selecionando a opção End): + + ##################################MMMMMMMMMM################# + | | | + Partição existente(120MB) Espaço Nova partição + Livre (30MB) + + A partição que será criada utilizara o espaço livre entre o + último Setor do disco e o setor resultante da subtração(170MB-30MB). + Mesmo assim, a ordem que será criada esta partição partição + será criada do Setor inicial(que é o resultado da subtração) + para o último Setor do disco. Existirá um espaço livre de 20MB + entre a primeira partição (de 120MB) e a nova partição de 30MB. + + + +2.3.9-) O comando Print <p> + +Este comando mostra a tabela de partição no formato selecionado na tela, +ou permite que seja gravado um arquivo no disco. Todas as partições são +classificadas na ordem que foram gravadas no disco. + +Os formatos aceitos para visualização de partições são: + +RAW <r> : Formato de dados do disco, mostra os setores que serão gravados + para o disco, caso seja escolhido o comando WRITE <W>. O formato + mostrado é exatamente aquele que será gravado para ao disco. + Abaixo um exemplo deste formato: + -------------------------------------------------------------------- + Disk Drive: /dev/hda + Sector 0: + 0x000: EB 69 4C 49 4C 4F 01 00 14 00 D7 02 00 00 00 00 + 0x010: FB 1B CF 36 74 D8 80 23 01 75 D8 80 23 01 73 D8 + 0x020: 80 23 01 01 77 01 77 D8 80 23 01 78 D8 80 23 01 + 0x030: 64 D8 80 23 01 65 D8 80 23 01 66 D8 80 23 01 67 + 0x040: D8 80 23 01 68 D8 80 23 01 69 D8 80 23 01 6A D8 + 0x050: 80 23 01 6B D8 80 23 01 00 00 00 00 00 00 00 00 + 0x060: 00 00 00 00 00 00 00 00 00 00 00 B8 C0 07 8E D8 + 0x070: 8C 06 66 00 89 36 64 00 89 1E 68 00 88 16 6A 00 + 0x080: B8 00 9A 8E C0 B9 00 01 29 F6 29 FF FC F3 A5 EA + 0x090: 94 00 00 9A FA 8E D8 8E C0 BC 00 B0 B8 00 90 8E + 0x0A0: D0 FB B0 0D E8 57 00 B0 0A E8 52 00 B0 4C E8 4D + 0x0B0: 00 BE 30 00 BB 00 10 FC AD 89 C1 AD 89 C2 09 C8 + 0x0C0: 74 20 46 E8 43 00 72 06 81 C3 00 02 EB EA 50 B0 + 0x0D0: 20 E8 2A 00 58 88 E0 E8 12 00 31 C0 88 C2 CD 13 + 0x0E0: EB CF B0 49 E8 17 00 EA 00 00 00 9B 50 C0 E8 04 + 0x0F0: E8 01 00 58 24 0F 04 30 3C 3A 72 02 04 07 30 FF + 0x100: B4 0E CD 10 C3 5A 59 5B C3 F6 C2 40 74 52 80 E2 + 0x110: BF 53 51 52 B4 08 CD 13 72 EB 88 F3 5A 88 16 6D + 0x120: 01 88 F2 30 F6 88 F7 58 51 86 CD D0 C5 D0 C5 80 + 0x130: E5 03 89 0E 6B 01 59 83 E1 3F F7 F1 FE C2 88 16 + 0x140: 6E 01 31 D2 43 F7 F3 88 D6 8A 16 6D 01 3B 06 6B + 0x150: 01 77 13 86 C4 D0 C8 D0 C8 0A 06 6E 01 89 C1 5B + 0x160: B8 01 02 CD 13 C3 5B 31 C0 F9 C3 00 00 00 00 00 + 0x170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x1A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x1B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 01 + 0x1C0: 01 00 0B FE 3F 8F 3F 00 00 00 51 4C 23 00 00 00 + 0x1D0: 41 D7 83 FE BF 6F 17 75 73 00 59 81 25 00 00 00 + 0x1E0: 01 98 05 FE 7F D6 98 42 25 00 7F 32 4E 00 00 00 + 0x1F0: 81 70 82 FE BF 72 70 F6 98 00 43 BC 00 00 55 AA + + Sector 2441880: + 0x000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x0A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x0B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x0C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x0D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x0E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x0F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x1A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x1B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 + 0x1C0: 01 98 0B FE 7F D6 3F 00 00 00 40 32 4E 00 00 00 + 0x1D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x1E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 0x1F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA + ----------------------------------------------------------------- + A primeira tabela de partição mostrada é a Primária, depois + as tabelas de partições ligadas com cada partição lógica. Como + no exemplo, os dados são mostrados em bytes Hexadecimais(na + primeira coluna) seguidos de 16 bytes por linha. + +Sector <s>: Mostra a tabela de partição classificada por setores. Esta + opção mostra o espaço não particionado no disco e a partição + Extendida, que é mostrada antes das partições Lógicas. + Abaixo um exemplo deste formato: + ------------------------------------------------------------------ + Partition Table for /dev/hda + + First Last + # Type Sector Sector Offset Length Filesystem Type (ID) Flags + -- ------- -------- --------- ------ --------- ---------------------- --------- + 1 Primary 0 2313359 63 2313360 Win95 FAT32 (0B) Boot (80) + Logical 2313360 2441879 0 128520 Free Space None (00) + 3 Primary 2441880 7566614 0 5124735 Extended (05) None (00) + 5 Logical 2441880 7566614 63 5124735 Win95 FAT32 (0B) None (00) + 2 Primary 7566615 10024559 0 2457945 Linux (83) None (00) + 4 Primary 10024560 10072754 0 48195 Linux Swap (82) None (00) + ------------------------------------------------------------------ + + onde: + # - Identificação da partição no disco /dev/hda + Type - Tipo da partição(veja o exemplo) + First Sector - Primeiro Setor utilizado para o armazanamento da partição. + Last Sector - Último Setor utilizado para o armazenamento da partição. + Offset - + Lenght - Tamanho total da partição em setores (Last Sector - First + Sector). + FileSystem Type (ID) - Identificação do Sistema de Arquivos da partição, + seguido do seu código hexadecimal no CFDisk. A partição + Extendida é identificada como um sistema de arquivos + com o código 05 (veja o exemplo). + Flags - Opções da partição seguido de seu valor em + hexadecimal. + +Table <t> : Mostra a tabela de partição classificada pelo número da partição. + Esta opção deixa fora todo espaço livre e não usado na partição. + Abaixo um exemplo deste formato. + ---------------------------------------------------------------- + Partition Table for /dev/hda + + ---Starting--- ----Ending---- Start Number of + # Flags Head Sect Cyl ID Head Sect Cyl Sector Sectors + -- ----- ---- ---- ---- ---- ---- ---- ---- -------- --------- + 1 0x80 1 1 0 0x0B 254 63 143 63 2313297 + 2 0x00 0 1 471 0x83 254 63 623 7566615 2457945 + 3 0x00 0 1 152 0x05 254 63 470 2441880 5124735 + 4 0x00 0 1 624 0x82 254 63 626 10024560 48195 + 5 0x00 1 1 152 0x0B 254 63 470 63 5124672 + --------------------------------------------------------------- + + onde: + # - Número da partição de disco + Flags - As opções utilizadas com a partição (em + valor Hexadecimal). + O valor 0x80 equivale a BOOT. + O valor 0x00 equivale a nenhuma opção + utilizada naquela partição. + Starting + Head - Cabeçote Inicial + Sector - Setor Inicial + Cyl - Cilindro Inicial + ID - Identificação do Sistema de arquivos(em + hexadecimal, conforme a tabela do CFdisk). + Ending + Head - Cabeçote Final + Sector - Setor Final + Cyl - Cilindro Final + Start Sector - Setor inicial da partição + Number of Sectors - Número de setores ocupados pela partição. + +Se a partição não inicia ou não termina em um cilindro limite do disco +ou se o seu tamanho não é divisível pelo tamanho do cilindro, um * é será +mostrado após o setor não alinhado. Este problema normalmente ocorre quando +a partição é criada por um Sistema operacional em que o limite da partição +não é alinhada com o cilindro ou que utiliza a contagem do tamanho do disco +de forma diferente. + + A tabela de partição somente tem 10 bits disponível para identificar o +cilindro inicial e final. Assim, quando o setor inicial absoluto é um +cilindro maior que 1023(final do disco), o valor máximo para a cabeça +inicial, setor e cilindro são mostrados. Este metodo é usado pelo OS/2, e +e corrige os problemas associados com OS/2 caso o Fdisk regrava a tabela de +partição quanto ela não esta neste formato. + +Desde então Linux e OS/2 utilizam esta contagem de setores absolutos, os +valores na cabeça inicial e final, Setor e Cilindro não são usadas. + + + +2.3.10-) O comando quit <q> + +Esta opção faz com que o CFdisk abandonar todas as alterações e +retornar para o Aviso de comando. Quando esta opção é escolhida, o programa +retorna deixando o disco como estava antes de se iniciar o particionamento. + +Se escolher esta opção o CFdisk abandonará o particionamento de disco +e voltará para a linha de comandos imediatamente. Se alterar/criar/excluir +alguma partição de disco e escolher esta opção, o programa emitirá um Beep +indicando que alguma alteração feita no disco foi abandonada. + +OBS: Esta opção é útil caso tenha se cometido algum engano durante o + particionamento do disco, como apagar por uma partição que contém + arquivos, alterar o tamanho do disco(geometria), etc. Lembre-se que + tudo o que fez será abandonado, durante o particionamento, se escolher + esta opção. + + + +2.3.11-) O comando type <t> + +Comando usado para alterar o tipo do sistema de arquivos utilizado +pela partição. As partições, quando criadas, recebem o sistema de arquivos +Linux Native(ou simplesmente Linux - tipo 83). O CFdisk pode criar, manipular, +excluir, uma grande variedade de Sistemas de arquivos para os mais diversos +tipos de sistemas operacionais existentes, veja o final deste manual para +ver as partições compatíveis com este programa. + +Para alterar o tipo do sistema de arquivos (File System) utilizado pela +partição, tecle <t>, e digite o valor de acordo com a lista de partições +disponíveis no programa. + +Por exemplo, para mudar a partição do tipo Linux para Linux Swap, selecione +esta partição, e tecle <t>, e digite o número 82(que corresponde a Linux +Native) e tecle <Enter>, e a partição terá seu sistema de arquivos alterado. + + + +2.3.12-) O comando units <u> + +A função deste comando é alterar as unidades de medida do tamanho da +partição que é mostrado na tela, por padrão, ele é mostrado em MegaBytes. +As unidades de medida do tamanho da partição são em MegaBytes, Cilindros e +Setores ocupados pela partição de disco. +Abaixo um exemplo da mudança da unidade de medida para Cilindros. +---------------------------------------------------------------------------- + CFdisk 0.8l + + Disk Drive: /dev/hda + Heads:255 Sectores per track:63 Cylinders:627 +----------------------------------------------------------------------------- +Name Flags Part Type FSType [LABEL] Cilinders +hda1 Boot Primary Win 95 FAT 32 249 +hda5 Logical DOS FAT 16 (BIG) GLEYDSON 22 + Pri/Log Free Space 371 + + + + + + + + + + +[Bootable] [Delete] [Help] [Maximize] [Print] +[Quit] [Type] [Units] [Write] +---------------------------------------------------------------------------- +Será mostrada a quantidade de cilindros que a partição ocupa no disco ao +invés do espaço em MB. + + + +2.3.13-) O comando Write <W> + +Este comando grava todas as tabelas de partições criadas/modificadas e +excluidas para o disco. Só é aceita a tecla <W> em maiúscula para gravação +da partição de disco, por motivos de segurança para que não seja feita a +gravação acidental das partições enquando estiver utilizando o programa. +Para quem utiliza as setas do teclado, o método é o mesmo que as outras +opções. + +Após selecionar esta opção, o CFdisk perguntará se confirma a gravação +das partições para o disco. + +Para gravar a partição, digite "yes" e tecle <Enter>. +Para cancelar o comando, pressione <Esc> ou digite "no" e tecle <Enter>. + +Após confirmar com "yes", o CFdisk gravará a tabela de partição no disco +e fara o Kernel re-ler a tabela de partição do disco, para se evitar +reiniciar o sistema para utilizar a nova tabela de partição. + +A tentativa de re-leitura da tabela de partição pode falhar. Para +solucionar este problema, é preciso reiniciar o computador, quando o +computador é reiniciado, o sistema operacional faz uma nova leitura das +tabelas de partições existentes no disco, fazendo com que sejam reconhecidas +corretamente. + + + +3-) Tipos de partições compatíveis com o CFdisk + +Abaixo uma listagem das partições compatíveis com o programa CFdisk e +seus respectivos códigos Hexadecimais, para consulta técnica ou utilização +durante o particionamento de disco. + +Código Nome +01 - DOS FAT12 +02 - Xenix root +03 - Xenix usr +04 - DOS FAT16 (<32MB) +05 - Extendida +06 - DOS FAT16 (>=32MB) +07 - OS/2 HPFS ou NTFS +08 - AIX +09 - AIX inicializável +0A - OS/2 Boot Manager +0B - Windows 95 FAT32 +0C - Windows 95 FAT32(LBA) +0E - Windows 95 FAT16(LBA) +0F - Windows 95 Extendida +11 - DOS FAT12 oculta +12 - DOS FAT16 oculta +16 - DOS FAT16 oculta +17 - HPFS OS/2 oculta +40 - Venix 80286 +51 - Novell +52 - Microport +63 - GNU Hurd +64 - Novell Netware 286 +65 - Novell Netware 386 +75 - PC/IX +80 - Minix Antigo +81 - Linux / Minix +82 - Linux Swap +83 - Linux Nativa +85 - Linux Extendida +93 - Amoeba +94 - Amoeba BBT +A5 - BSD/386 +A6 - Open BSD +A7 - NextStep +B7 - BSDI Sistema de Arquivos +B8 - BSDI Swap +C7 - Syrinx +DB - CP/M +E1 - DOS access +E3 - DOS R/O +F2 - DOS secundária +FF - BBT + + + + +4- ) Direitos Autorais + +Este documento foi desenvolvido com base em minha experiência e conhecimento em +discos e partições, e mediante pesquisa em alguns documentos como os How-TO do +Linux tendo como objetivo a contribuição para a comunidade Linux em geral. + +Gleydson M. da Silva (gleydson_s@yahoo.com ou gleydson@linuxbr.com.br) + +Qualquer dúvida, sugestão ou reclamação podem ser mandadas para um dos +E-Mail's Acima. Conto com sua contribuição para a melhoria deste Manual. + +Autorizo a reprodução Total ou parcial deste texto para que seja utilizado para +fins educativos, autoaprendizado, colocação em Home pages e qualquer outra +forma de distribuição não comercial do documento desde que sejam mantidos os +meus créditos pela pesquisa e desenvolvimento deste documento de acordo com os +termos da GNU (veja abaixo). + + + + +5- ) Licenças e Garantias sobre este documento + + +CFdisk-Portuguese Copyright (C) 1999 Gleydson M. da Silva + +Este é um documento de livre distribuição, que pode ser copiado e +distribuído sob os termos da Licença Pública Geral GNU, conforme publicada +pela Free Software Foundation, versão 2 da licença ou (a critério do autor) +qualquer versão posterior. + +Este documento é distribuído com a itenção de ser útil ao seu utilizador, +no entanto NÃO TEM NENHUMA GARANTIA, EXPLÍCITAS OU IMPLÍCITAS , COMERCIAIS +OU DE ATENDIMENTO A UMA DETERMINADA FINALIDADE. Consulte a Licença Pública +Geral GNU para maiores detalhes. + +gleydson_s@yahoo.com +gleydson@linuxbr.com.br + + + +6- )Nota sobre Marcas Registradas + +Os programas mencionados neste manual são de propriedade dos seus respectivos +donos: + +MS-DOS, Windows 3.1x, Windows 9x, Windows NT são de propriedade da Microsoft. +OS/2 e OS/2 Warp são de propriedade da IBM + + +7- ) Agradecimentos + +Agradeço a todas as pessoas que me mandam correções, comentários, críticas, +elogios, dúvidas sobre este documento, pois através destas mensagens, estão +contribuindo para a melhoria deste projeto e me icentivando em sua continuação. + + +Agradecimentos especiais a: + +Eduardo Marcel Macan <macan@thecore.com.br> - Pelo apoio e interesse na + divulgação deste projeto e outros documentos relacionados com a + tradução e divulgação de documentos sobre o Linux no Brasil. + +Jorge Godoy <jorge@bestway.com.br> - Pela revisão deste documento e primeiras + orientações para a conversão deste para SGML. + +Adam di Carlo <adam@onshore.com> - Que me deu apoio na colocação deste documento + na documentação da distribuição Debian. + +E a voce pelo interesse em conhecer mais sobre o Linux. + + +<EOF>
\ No newline at end of file diff --git a/fdisk/doc/Fdisk-Portuguese.html b/fdisk/doc/Fdisk-Portuguese.html new file mode 100644 index 000000000..fdf29b809 --- /dev/null +++ b/fdisk/doc/Fdisk-Portuguese.html @@ -0,0 +1,1118 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <meta name="Author" content="Gleydson Silva"> + <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win95; I) [Netscape]"> + <title>Fdisk-Portugues-HOWTO</title> +</head> +<body> + +<center><b><font size=+1>Fdisk-Portugues-HOWTO Copyright (C) 1999 Gleydson +M. da Silva</font></b> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<p> +<hr WIDTH="100%"> +<br><b>Gleydson M. da Silva</b><i> - gleydson@linuxbr.com.br</i> +<br><b>Versão 1.3</b></center> + +<hr WIDTH="100%"> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<center> +<p><a NAME="Indice"></a><b><u><font size=+2>Índice</font></u></b></center> + +<p><b><font size=+1>1</font></b> -<a href="#1"> Introdução +ao Fdisk</a> +<br> <b>1.1</b> - <a href="#1.1">O que é uma Partição +de Disco</a> +<br> <b>1.2</b> - <a href="#1.2">A Tabela de Partição</a> +<br> <b>1.3</b> - <a href="#1.3">Introdução ao Particionamento +de discos</a> +<br> <b>1.4</b> - <a href="#1.4">Identificações utilizadas +neste documento</a> +<br> <b>1.5</b> - <a href="#1.5">Identificação de discos +e partições no Linux</a> +<br> <b>1.6</b> - <a href="#1.6">Tipos de partições +de disco</a> +<br> <b>1.7</b>-) <a href="#1.7">Observações sobre +o formato DOS 6.XX(FAT 16)</a> +<p><b><font size=+1>2</font></b> - <a href="#2">Iniciando o programa Fdisk</a> +<br> <b>2.1</b> - <a href="#2.1">Opções de Linha de +comando</a> +<br> <b>2.2</b> - <a href="#2.2">Comandos do Fdisk</a> +<p><b><font size=+1>3</font></b> - <a href="#3">Manipulando partições +no disco rígido</a> +<br> <b>3.1</b> - <a href="#3.1">Listando partições +existentes no disco</a> +<br> <b>3.2</b> - <a href="#3.2">Criando partições +de disco</a> +<br> <b>3.3</b> - <a href="#3.3">Mudando o tipo da partição</a> +<br> <b>3.4</b> - <a href="#3.4">Excluindo uma partição +de disco</a> +<br> <b>3.5</b> - <a href="#3.5">Gravando partições +alteradas para o disco</a> +<br> <b>3.6</b> - <a href="#3.6">Abandonando o programa sem gravar +alterações para o disco</a> +<br> <b>3.7</b> - <a href="#3.7">Alternando entre partição +inicializável/não inicializável</a> +<br> <b>3.8</b> -<a href="#3.8"> Escolhendo a unidade para +mostrar o tamanho ocupado pela partição</a> +<p><b><font size=+1>4</font></b> - <a href="#4">Tipos de partições +reconhecidas pelo Fdisk</a> +<p><b><font size=+1>5</font></b> - <a href="#5">Direitos Autorais</a> +<p><b><font size=+1>6</font></b> - <a href="#6">Licenças e Garantias +sobre este documento</a> +<p><b><font size=+1>7</font></b> - <a href="#7">Marcas Registradas</a> +<p><font size=+1>8</font> - <a href="#8">Agradecimentos</a> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<br> +<center> +<p><a NAME="1"></a><u><font size=+1>1-) Introdução ao Fdisk</font></u></center> + +<p> Fdisk é um programa utilizado para o particionamento +de discos rígidos <i>IDE</i> e <i>SCSI</i>. A versão +do programa Fdisk descrita neste manual é a <i>2.8</i> +<p><b>ATENÇÃO</b>: ESTE MANUAL TEM COMO OBJETIVO A EXPLICAÇÃO +DE +<br> +FUNCIONAMENTO E UTILIZAÇÃO DO FDISK DO LINUX (NÃO +O +<br> +FDISK DO DOS), MESMO QUE VOCE SEJA UM USUÁRIO DO DOS, +<br> +RECOMENDO QUE LEIA ESTE MANUAL COMO UMA REFERÊNCIA +<br> +TÉCNICA E PARA SEU APRENDIZADO. +<p><b> Este documento é distribuído com +a itenção de ser útil ao seu utilizador, no entanto +NÃO TEM NENHUMA GARANTIA, EXPLÍCITAS OU IMPLÍCITAS +, COMERCIAIS OU DE ATENDIMENTO A UMA DETERMINADA FINALIDADE. Consulte a +Licença Pública Geral (GNU) para maiores detalhes.</b> +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="1.1"></a><u><font size=+1>1.1-) Partição de Disco</font></u></center> + +<p> Uma <i>partição de disco</i> é +o local onde o sistema operacional armazena seu sistema de arquivos(<i>arquivos, +diretórios, FAT, boot sector, etc</i>). +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="1.2"></a><u><font size=+1>1.2-) Tabela de partição</font></u></center> + +<p> A <i>Tabela de partição</i> é +o local do disco rígido onde se localizam os dados sobre todas as +partições existentes no disco como o sistema de arquivos +utilizado, se ela é inicializável, a cabeça inicial/final, +setor inicial/final, cilindro inicial/final, número de setores ocupados +por ela no disco. +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="1.3"></a><u><font size=+1>1.3-) Introdução ao +particionamento de discos</font></u></center> + +<p> Particionar o disco rígido é dividir +ele em partes para armazenamento de arquivos e programas. As partições +criadas no disco podem ter o tamanho que desejar (desde que esteja dentro +da capacidade máxima do disco rígido). +<br> Uma partição não interfere +em outras partições do mesmo disco(é como se tivessemos +vários discos rígidos dentro de um). +<br> Em um disco rígido, pode ser criada uma partição +única, que neste caso todo o disco rígido é +usado para armazenar os arquivos(que é o caso mais comum caso voce +tenha o DOS), ou várias partições, que podem ser usadas +pelo mesmo SO(Sistema Operacional) ou outros sistemas operacionais diferentes(um +exemplo de várias partições, é se voce for +usar o DOS e o Linux no mesmo disco, os dois +<br>sistemas vão estar no mesmo disco mas um não interfere +no outro). +<br> Este manual tem a itenção de explicar +o funcionamento do programa fdisk (fdisk do Linux não do DOS!). +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="1.4"></a><u><font size=+1>1.4-) Algumas identificações +utilizadas neste manual para facilitar a compreensão do texto</font></u></center> + +<p> Esta parte descreve algumas características +de organização deste manual e algumas identificações +que adotei para facilitar o seu entendimento, e as explicações +que serão dadas. +<p> Explicação de nomes e comandos, será +seguida da palavra "<b>onde</b>" e abaixo dela as explicações +sobre os comandos, exemplo: +<p><b>onde</b>: +<br><i>nome a ser explicado1</i> : Descrição +<br><i>nome a ser explicado2</i> : Descrição +<br><i>nome a ser explicado3</i> : Descrição +<p>ou +<p><b>onde</b>: +<br><i>nome a ser explicado1</i> - Descrição +<br><i>nome a ser explicado2</i> - Descrição +<br><i>nome a ser explicado3</i> - Descrição +<br> +<p> Quando for feita alguma referência com tecla +do teclado, por exemplo, pressione p para listar as partições, +a letra sera colocada entre <> para facilitar a interpretação: +<br>pressione <p> para listar as partições +<br>após isto pressione <Enter> para confirmar +<br>pressione <l> para listar os tipos de partições disponíveis +<br> +<p> As linhas pontilhadas que aparecem na tela, veja +abaixo, +<br>---------------------------------------------------------------------------- +<br>---------------------------------------------------------------------------- +<br>servem para identificar que o que esta entre as linhas é um +exemplo de como +<br>será a resposta do comando para a tela de seu computador. +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="1.5"></a><u><font size=+1>1.5-) Identificação +de discos e partições no Linux</font></u></center> + +<p> Antes de descrever como se utiliza o programa fdisk, +é importante fazer algumas explicações sobre a identificação +das partições e unidades de disco no sistema Linux( e outros +*nix). Se voce for um usuário que já conhece a interpretação +de discos e partições neste sistema, voce não precisará +ler esta parte. +<br> No sistema operacional Linux, os dispositivos existentes +no computador (como impressoras, unidades de disquetes, discos rígidos, +monitor, placa de som, etc...) são identificados por um nome referente +a este dispositivo e colocado no diretório /dev (que é utilizado +para identificar dispositivos ou periféricos existentes no computador). +<br> A identificação dos discos rígidos +segue a seguinte forma: +<p> /dev/hda1 +<br> | | | +| +<br> | | | +|_Número que identifica a partição do disco rígido(<i>1=Primeira, +2=segunda</i>) +<br> | | | +<br> | | |_Letra +que identifica o disco rígido(<i>a=primeiro disco, b=segundo disco, +etc..</i>) +<br> | | +<br> | |_Sigla HD - Significa +que é um disco rígido IDE(<i>Se tiver um SD significa SCSI</i>) +<br> | +<br> |_ Identificação do diretório onde os dispositivos +do sistema são armazenados +<p><b>OBS</b>: As unidades de disco rígido <i>SCSI</i>, são +identificadas com as letras <i>sd</i> seguida pela letra da +<br> unidade e número +da partição e os discos <i>IDE</i> são identificados +por <i>hd</i> seguida pela letra da +<br> unidade de disco e +o número da partição do disco(como visto acima). +<p>Abaixo, algumas identificações de disco do sistema Linux: +<p><i>/dev/hda1</i> - Disco rígido +IDE primário principal - Primeira partição +<br><i>/dev/hda2 </i> - Disco rígido +IDE primário principal - Segunda partição +<br><i>/dev/hda3</i> - Disco rígido +IDE primário principal - Terceira partição +<br><i>/dev/hdb1</i> - Disco rígido +IDE primário escravo - Primeira partição +<br><i>/dev/hdb2</i> - Disco rígido +IDE primário escravo - Segunda partição +<br><i>/dev/hdb3</i> - Disco rígido +IDE primário escravo - Terceira partição +<br><i>/dev/hdc1</i> - Disco rígido +IDE secundário principal - Primeira partição +<br><i>/dev/hdc2</i> - Disco rígido +IDE secundário principal - Segunda partição +<br><i>/dev/hdc3</i> - Disco rígido +IDE secundário principal - Terceira partição +<br><i>/dev/hdd1</i> - Disco rígido +IDE secundário escravo - Primeira partição +<br><i>/dev/hdd2</i> - Disco rígido +IDE secundário escravo - Segunda partição +<br><i>/dev/hdd3</i> - Disco rígido +IDE secundário escravo - Terceira partição +<br><i>/dev/sda1</i> - Primeiro disco rígido +SCSI - Primeira partição +<br><i>/dev/sda2</i> - Primeiro disco rígido +SCSI - Segunda partição +<br><i>/dev/sda3</i> - Primeiro disco rígido +SCSI - Terceira partição +<br><i>/dev/sdb1</i> - Segundo disco rígido +SCSI - Primeira partição +<br><i>/dev/sdb2</i> - Segundo disco rígido +SCSI - Segunda partição +<br><i>/dev/sdb3</i> - Segundo disco rígido +SCSI - Terceira partição +<p> No exemplo acima foram usadas 3 partições +por disco, mas podem existir mais partições no mesmo disco, +um exemplo é se o disco rígido possuir <i>partições +Lógicas</i>, que são identificadas no sistemas a partir de +/dev/hdx5 em diante. +<p> Abaixo um exemplo de como o Linux identifica as partições +em cada disco existente em seu computador: +<p>Vamos supor que eu tenha 2 discos rígidos: +<br>o <i>1ºdisco de 2GB</i> e o <i>2ºdisco de 1GB </i>(Giga +Byte ou 1.000 Megas) +<p> No primeiro disco(<i>de 2GB</i>), a primeira partição +é de <i>800MB</i> do tipo FAT16(<i>DOS</i>), a segunda partição +é de <i>1.2GB</i> do tipo EXT2(<i>Linux</i>)(<i>1.2GB+800MB=2GB</i> +que é a capacidade total do disco). Então as partições +seriam identificadas da seguinte forma no Linux: +<p><i>/dev/hda</i> - Disco rígido Primário Principal +<br><i>/dev/hda1</i> - Primeira partição do primeiro disco +rígido (de 800MB do tipo DOS) +<br><i>/dev/hda2</i> - Segunda partição do primeiro disco +rígido( de 1.2GB do tipo Linux) +<p> Neste caso estariam disponíveis <i>800MB</i> +para serem usados com o DOS e <i>1.2GB</i> para o Linux. +<br> Por exemplo, se voce particionar um disco rígido +em duas partes e usar as duas partições no DOS, ele reconhecerá +as partições como sendo C: e D:. +<p><b>Lembre-se</b>: Quando um disco é particionado, uma partição +não interfere nas outras, repare que +<br> +quando voce particiona(divide) um disco, é como se tivesse dois +discos rígidos(o +<br> +único cuidado que voce deve tomar é com as cópias +de segurança, porque se der um +<br> +problema de parte eletrônica no disco rígido, por exemplo, +a sua placa controladora +<br> +queimar ou o cabeçote dele ir pro espaço, serão perdidas +as suas 2 partições que +<br> +estão armazenadas nele. +<br> +<p>Voltando ao exemplo das classificações das partições +do disco, vamos para o segundo disco: +<p> No segundo disco(<i>1GB</i>), eu tenho uma partição +de <i>950MB</i> do tipo FAT16(<i>DOS</i>), que costumo usar para armazenar +arquivos temporários e cópias de segurança de meu +computador, etc..., e outra de 50MB <i>SWAP</i>(Partição +de memória virtual como descrevi acima)(<i>950MB+50MB=1GB</i>). +Então as partições deste disco seriam identificadas +da seguinte forma no Linux: +<p><i>/dev/hdb</i> - Disco rígido principal escravo +<br><i>/dev/hdb1</i> - Primeira partição do disco acima ( +de 950MB do tipo DOS) +<br><i>/dev/hdb2</i> - Segunda partição do disco acima ( +de 50MB do tipo SWAP) +<p> No disco acima, <i>950MB</i> estão disponíveis +para serem usados pelo DOS e <i>50 MB</i> pela memória virtual (<i>SWAP</i>) +do Linux. +<p> Note que se voce utiliza o MS-DOS, não será +possível conseguirá ver as partições do Linux +e SWAP, porque são imcompatíveis com o formato aceito pelo +DOS (ele identificaria a primeira partição do primeiro disco(800MB) +como a unidade C: e a primeira partição do segundo disco(950MB) +como unidade D), mas o contrário não acontece; O Linux tem +total compatibilidade com a partição DOS FAT12, FAT16, FAT32, +OS/2 HPFS, e muitas outras. +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="1.6"></a><u><font size=+1>1.6-) Tipos de partições +de discos</font></u></center> + +<p> As partições de disco são divididas +em tres tipos: <i>Primária, Extendida </i>e<i> Lógica</i>. +<p> Pode se ter no máximo quatro partições +primárias e extendidas no mesmo disco. A <i>partição +Primária</i> permite o armazenamento de arquivos e diretórios. +<br>Todos os computadores que possuem somente a unidade C(supondo que voce +use o DOS), usam este tipo de partição para armazenamento +de arquivos e inicialização do sistema operacional. +<br> Se for preciso criar mais que 4 partições +no mesmo disco, será necessário +<br>criar uma <i>partição Extendida</i>. A <i>partição +Extendida</i> não pode ser utilizada para armazenar arquivos. +Ela é usada para a criação de outras partições, +dentro dela, que são chamadas de <i>partições Lógicas</i>. +<br> Uma <i>partição extendida</i> podem +conter várias <i>partições Lógicas</i>. As +partições Lógicas podem armazenar arquivos e diretórios(como +as partições primárias). +<br> Um mesmo disco rígido pode armazenar mais +de 64 partições independentes uma das outras. +<p><b>OBS</b>: Os arquivos e diretórios podem ser armazenados somente +em partições de disco <i>Primárias</i> ou <i>Lógicas</i>, +a partição <i>Extendida</i> não é usada para +armazanamento de arquivos e diretórios. +<p> Se possuir duas partições em +seu computador (C: e D: no DOS), e não estiver usando a partição +D:, a instalação pode ser feita nesta partição +desde que ela tenha o espaço necessário para o sistema operacional +Linux, os programas que desejar instalar, mais a partição +SWAP. +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="1.7"></a><u><font size=+1>1.7-) Observações sobre +o formato DOS 6.XX(FAT 16)</font></u></center> + +<p> No formato DOS 6.XX(<i>FAT16</i>), o primeiro +setor da área de dados da partição é utilizado +frequentemente pelo DOS para armazenamento de dados sobre a partição +de disco, e estes dados são usados pelo sistema para se ter maior +confiabilidade do que os dados armazenados na tabela de partição. +O sistema de arquivos DOS, faz o FDISK(do <i>DOS</i>) limpar os primeiros +512 bytes da área de dados da partição sempre que +uma mudança de tamanho acontecer. +<br> O formatador do DOS(<i>format</i>) verifica +este primeiro setor toda vez que a upção <i>/U</i> (que é +utilizada para não salvar dados para se fazer a desformatação +do disco) é utilizada. +<br> Isto é considerado uma FALHA no Format(do +<i>DOS</i>) +e no Fdisk(do <i>DOS</i>). +<br>A opção abaixo deve ser utilizada caso voce crie uma +partição do <i>DOS FAT16</i> com o Fdisk, que faz com que +os primeiros 512 bytes daquela partição sejam "limpos", para +manter a compatibilidade com o DOS. Utilize esta opção dentro +do Linux, após criar a partição com o Fdisk e reiniciar +o seu +<br>computador. Foi notado que esta opção só funciona +corretamente somente quando o Sistema Linux estiver instalado em seu computador. +Não me responsabilizo caso utiliza-la a partir de um disquete de +recuperação. +<p><b>dd if=/dev/zero of=/dev/hdx1 bs=512 count=1</b> +<p><b>onde</b>: +<br><i>hdx1</i> - É a identificação da unidade de +disco e a partição que foi criada pelo Fdisk utilizando +o sistema de arquivos DOS que terá seu primeiro setor "limpo". +<p><b>OBS1</b>: Cuidado ao utilizar esta opção, um pequeno +descuido pode resultar na perda de dados do +<br> +seu disco rígido ou outras partição. +<br><b>OBS2</b>: Não utilize este comando com partições +que utilizam o sistema de arquivos <i>FAT32</i> +<br> +(utilizada nos sistemas operacionais <i>Windows 95 OSR/2</i> e superiores) +se for utilizada em +<br> +um disco com este sistema, sua FAT será corrompida, se isto +acontecer, será necessária a +<br> +re-formatação da partição. +<br><b>OBS3</b>: É extremamente recomendado que se utilize o programa +de particionamento que +<br> +acompanha o seu sistema operacional para a criação da partição. +Por exemplo, se deseja +<br> +criar uma partição DOS 6.XX, utilize o FDisk qua acompanha +o DOS. +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="2"></a><u><font size=+1>2-) Iniciando o programa Fdisk</font></u></center> + +<p>Para iniciar o programa fdisk(Linux)digite: +<p><i>fdisk</i> [unidade] +<p><b>Onde</b>: +<br><i>unidade</i> - deve ser a unidade de disco rígido no padrão +Linux(<i> /dev/hda, /dev/hdb, /dev/sda,</i> +<br><i> +/dev/sdb, etc... </i>). Se voce tem apenas 1 disco rígido +IDE, use <i>/dev/hda</i>, para fazer o +<br> +fdisk trabalhar com este disco ou digite fdisk sem especificar a unidade. +Se possuir 1 +<br> +disco SCSI, use /dev/sda +<p> Se unidade não for especificada, o programa fdisk usará +<i>/dev/hda</i> +como unidade de disco padrão. +<p><b>ATENÇÃO</b> : A OPERAÇÃO DE PARTICIONAMENTO +DE DISCOS PODE FAZER COM +<br> +QUE OS DADOS ARMAZENADOS EM SEU DISCO RÍGIDO SEJAM +<br> +PERDIDOS, SE FOR USADA INCORRETAMENTE. É SEMPRE +<br> +RECOMENDADO RETIRAR UMA CÓPIA DE SEGURANÇA DOS SEUS +<br> +ARQUIVOS EXISTENTES NO MICRO ANTES DE SE EXECUTAR UM +<br> +PROGRAMA DESTE TIPO, A NÃO SER QUE TENHA CONFIANÇA NO +<br> +QUE ESTA FAZENDO E QUE ENTENDEU AS EXPLICAÇÕES SOBRE A +<br> +IDENTIFICAÇÃO DE DISCOS RÍGIDOS E SUAS +PARTIÇÕES NO +<br> +SISTEMA. +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="2.1"></a><u><font size=+1>2.1-) Opções de linha +de comando</font></u></center> + +<p> Com a utilização de opções +de linha de comando, voce pode fazer com que o programa inicie de uma forma +específica, ou personalizada. +<p><b>fdisk</b> [<i>-b</i>] [<i>-u</i>] [<i>unidade</i>] - +Opções aceitas para o particionamento. +<br><b>fdisk</b> [<i>-l</i>] [<i>-b</i>] [<i>-u</i>] +- Opções aceitas para listar as partições atuais. +<br><b>fdisk</b> [<i>-s</i>] [<i>unidade</i>] +- Opção aceita para mostrar o Tamanho da partição +<br><b>fdisk</b> [<i>-v</i>] +- Versão do programa +<p><b>Onde</b>: +<br><i>-b</i> : Faz com que o fdisk mostre na tela a coluna <i>BEGIN</i> +quando utilizar a opção <p> durante o +<br> particionamento do disco ou com +a opção -l quando se for listar as partições +na linha de +<br> comando. +<br> <b>OBS</b>: Esta opção +é geralmente desnecessária, porque seu valor equivale ao +valor da coluna +<br> +START. +<br><i>-u</i> : Muda a unidade de medida padrão para Setores. +Se esta opção for usada na linha de +<br> comando para se fazer o particionamento +de disco, após pressionar <p>, o programa mostrará +<br> na tela o inicio e o fim da partição +em Setores ao invés de utilizar cilindros para a listagem. +<br> Se for utilizada em conjunto com a opção +-l, a unidade de medida do Inicio e Fim da partição +<br> será listada Setores ao invés +de cilindros. +<br><i>-l</i> : Lista as partições existentes no disco, +sem entrar no programa fdisk, ou alterar qualquer +<br> partição. Esta opção +é equivalente a entrar no programa fdisk e pressionar <p>, mas +ela +<br> somente lista as partições +sem entrar no programa. +<br><i>-s</i> : Mostra o tamanho de uma partição de +disco. A única diferença desta para as outras opções, +é +<br> que se deve especificar a unidade mais +a partição que deseja ver o tamanho, por exemplo, +<br> digitando-se: +<br> <i>fdisk -s /dev/hda1</i> +<br> voce visualizará o tamanho total +da partição de disco hda1. +<br><i>-v</i> : Mostra a versão do programa fdisk que esta +utilizando. +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="2.2"></a><u><font size=+1>2.2-) Comandos do fdisk.</font></u></center> + +<p> O fdisk do Linux manipula as partições +de seu disco através de comandos digitados no teclado. Cada letra +digitada corresponde a um comando diferente no fdisk. Estes comandos serão +utilizados após iniciar o programa. +<br> Aqui vai a lista de comandos disponíveis +no fdisk, recomendo que anote em um papel, ou imprima esta parte do texto( +ou todo o documento) para que possa consultar estas opções +durante o particionamento do seu disco rígido. +<p><i>a</i> - Seleciona entre partição inicializável +e não inicializável. +<br><i>b</i> - Edita um volume de disco BSD(não usada em computadores +com DOS) +<br><i>d</i> - Apaga uma tabela de partição (Delete) +<br><i>l</i> - Lista os tipos de partições disponíveis +(List) +<br><i>m</i> - Ajuda +<br><i>n</i> - Cria uma nova tabela de partição (New) +<br><i>p</i> - Mostra a tabela de partição atual (Print) +<br><i>q</i> - sai do fdisk sem gravar as alterações +no disco (quit) +<br><i>t</i> - Muda o tipo da partição (Type) +<br><i>u</i> - Altera as unidades de medidas que são mostradas +na tela +<br><i>v</i> - Verifica a tabela de partição (verify) +<br><i>w</i> - grava as alterações feitas para o disco e +sai do fdisk (write) +<br><i>x</i> - Comandos especiais do programa(somente para usuários +experientes) +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="3"></a><u><font size=+1>3-) Manipulando partições +no disco rígido</font></u></center> + +<p> Agora vamos começar realmente a trabalhar +com o fdisk, os textos que foram colocados acima, foi para que voce entendesse +o que é o particionamento de um disco rígido e para que soubesse +a diferença entre partição e um disco rígido,(já +vi muitas pessoas falarem de partição como se fosse disco +rígido...) +<br> Abaixo uma explicação passo-a-passo +de como particionar um disco usando +<br>o fdisk e seus comandos. +<p><b>ATENÇÃO</b>: O disco rígido usado no particionamento +é um exemplo. Ele não deve ser usado por +<br> +voce para fazer o particionamento de seu disco, uma vez que a capacidade +e outros +<br> +parâmetros do disco rígido variam de um para o outro. Este +exemplo serve apenas +<br> +para que voce entenda como o fdisk funciona, o que faz cada um de seus +comandos +<br> +e a fazer o cálculo do tamanho das partições. +<p> A tradução das mensagens que aparecem em +Ingles nos exemplos que vou colocar logo abaixo, e a ajuda do programa, +não foram feitas porque aparecem exatamente como estão quando +fizer o particionamento de seu disco, e não conheço nenhuma +versão do fdisk(Linux) em português (caso alguém conheça +uma versão deste programa em português, favor entrar em contato +comigo para que eu possa atualizar este documento, meu endereço +de E-mail esta no final do documento). +<br> Somente vou explicar o que significa cada mensagem +que aparece no fdisk +<br>através de uma comparação. +<p>No exemplo eu vou usar um disco de <i>1.08GB</i>. Este disco possui +<i>630</i> +cilindros, <i>16</i> cabeças, e <i>21</i> setores por trilha( <i>emmodo +LBA</i>). +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="3.1"></a><u><font size=+1>3.1-) Listando partições +existentes no disco</font></u></center> + +<p> Primeiro digite <i>fdisk /dev/hda</i> (supondo que +este seja o disco principal), se a unidade de disco não for digitada, +o fdisk usará /dev/hda como padrão. Após voce digitar +este comando, o fdisk procura por partições existentes, seus +tamanhos e outras características(geometria do disco) que serão +utilizadas para se fazer o cálculo de partições. +<br> Quando entrar no programa, digite a letra <p> +para que o programa mostre as tabelas de partição existentes +no disco rígido. +<p>A tela que aparece é a seguinte: +<p>---------------------------------------------------------------------------------------------------- +<br>Command (m for help): p +<br>Disk /dev/hda: 16 heads, 21 sectors, 630 cylinders +<br>Units = cylinders of 630*512 bytes +<p> Device Boot Begin +Start End Blocks Id +System +<br> /dev/hda1 * +1 1 +117 204800 6 DOS 16-bits >=32M +<p>Command (m for help): +<br>----------------------------------------------------------------------------------------------------- +<br> +<p>Abaixo uma tradução desta tela: +<br>----------------------------------------------------------------------------------------------------- +<br>Commando (m para ajuda): <p> +<br>Disco /dev/hda: 16 cabeças, 21 setores, 630 cilindros +<br>Unidades = cilindros de 630*512 bytes +<p>Dispositivo Partida Começa Inicio +Fim Blocos Identif. Sistema +<br>/dev/hda1 * +1 1 117 +204800 6 DOS 16-bits +>=32M +<p>Comando (m para ajuda): +<br>---------------------------------------------------------------------------------------------------- +<p><b>Onde</b>: +<br><i>Device</i> : É a identificação da partição +de disco. +<br><i>Boot</i> : Se estiver com "*", se a partição +pode ser usada para BOOT. +<br><i>Begin</i> : Cilindro inicial da partição +de disco +<br><i>Start</i> : Cilindro inicial da partição +de disco +<br><i>End</i> : Cilindro Final da +partição do disco +<br><i>Blocks </i> : Quantidade de blocos ocupados pela partição +de disco. No Linux, um +<br> +Bloco equivale a 1024 bytes(1KB) +<br><i>ID</i> : Tipo da +partição (conforme a lista de partições existentes +quando é +<br> +pressionada a letra <L>. +<br><i>System</i> : Descrição do sistema de arquivos que +é usado na partição de disco. +<p> Como vemos acima, o disco rígido possui uma +partição do tipo <i>DOS- FAT16 </i>ocupando <i>200MB</i> +de espaço em disco (200000 Blocos multiplicados por 1024). +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="3.2"></a><u><font size=+1>3.2-) Criando uma partição +de Disco</font></u></center> + +<p> Para criar uma partição de disco, pressionamos +a letra <n>. Neste exemplo vamos criar uma partição do +tipo<b> Linux EXT2</b>(Nativa) com o tamanho de <i>820MB</i>, esta partição +é a que conterá todo o sistema de arquivos Linux e seus programas, +veja o exemplo: +<p>----------------------------------------------------------------------------------------------------- +<br>Command ( m for help): <n> +<br> e extended +<br> p primary partition (1-4) +<br><p> +<br>Partition number (1-4): <2> +<br>First cylinder(118-630): <118> +<br>Last cylinder or +size or +sizeK or +sizeM (118-630): <+820M> +<br>----------------------------------------------------------------------------------------------------- +<br> O fdisk perguntará se deseja criar uma partição +extendida ou primária. Crie uma partição primária +para o sistema de arquivos do Linux, ou uma partição extendida +caso voce ja tenha 3 partições primárias criadas em +seu disco, conforme foi visto acima. +<br> Como pode ter notado no exemplo acima, como já +existia a partição 1, digitamos o número 2 para que +fosse criada uma segunda partição, se a partição +número 2 já existisse, seria digitado o número 3 para +criar uma terceira partição, assim por diante. +<br> Após escolher o tipo de partição +que será criada, voce deverá especificar o cilindro inicial +da partição de disco. No exemplo acima, o valor do cilindro +inicial é de 118. Utilize sempre o valor do cilindro inicial sugerido +pelo fdisk, a não ser que se queira deixar um espaço entre +uma partição antiga e a nova partição para +a criação de uma partição menor ou por outros +motivos. +<br> O último passo é especificar +onde terminará a partição de disco. É permitida +a utilização de Cilindros, bytes, Kbytes e Mbytes para marcar +o final da partição de disco (veja detalhes abaixo). +<p><b>LEMBRE-SE</b>: Em um mesmo disco rígido podem existir até +4 partições primárias (contando com +<br> +a partição Extendida). +<p><b>Onde</b>: +<br> <i>Partition number</i> : Número da partição +que vai ser criada, como já temos uma partição +no +<br> +disco, digitamos o número 2 para dizer ao fdisk que queremos criar +uma +<br> +segunda partição primária. Neste exemplo, voce acabou +de criar a +<br> +partição /dev/hda2. +<br> <i> First cylinder</i> : Primeiro cilindro +disponível após o último cilindro usado pela partição +1. Neste +<br> +caso usamos o cilindro 118 até o cilindro final(Last Cylinder). +O valor deve ser +<br> +digitado em cilindros. +<br><i> Last cylinder or +size or +sizeK or +sizeM</i> +: Aqui voce pode especificar o final da partição de +<br> +disco. +<br> +Os seguintes valores podem ser usados para marcar o final da partição +de +<br> +disco: +<p> +597 +- É o valor equivalente a partição de 820MB +(em cilindros) +<br> ++820000000 - É o valor equivalente a partição +de 820MB (em bytes) +<br> ++820000K - É o valor equivalente a partição +de 820MB (em Kbytes) +<br> ++820M - É +o valor equivalente a partição de 820MB (em Mbytes) +<p> Recomendo que especifique o valor em <i>MB</i> ou +<i>KB</i> +por não exigir o cálculo do espaço do disco usado +em cada cilindro, e por ser um dos mais utilizados e mais práticos. +Especificando o valor em <i>bytes, Kbytes</i> ou <i>Mbytes</i>, o fdisk +se encarregará de converter o tamanho digitado para um valor de +cilindro final. +<br> Se digitar um número acima do espaço +disponível no disco(ou cilindro diponível), será mostrada +uma mensagem de erro dizendo que a partição não pode +ser criada. +<p><b>OBS</b>: Caso seja criada uma partição DOS FAT16, deverá +ser utilizado o comando +<br> <b>dd if=/dev/zero of=/dev/hdx1 bs=512 count=1</b> +<br> para que a partição criada seja +compatível com o formato utilizado pelo +<br> DOS. Para maiores detalhes veja <a href="#1.7">Observações +sobre o formato DOS 6.XX</a> +<br> +<p> Para verificar as partições existentes +no disco tecle <p> +<br>----------------------------------------------------------------------------------------------------- +<br>Command (m for help): p +<br>Disk /dev/hda: 16 heads, 21 sectors, 630 cylinders +<br>Units = cylinders of 630*512 bytes +<p> Device Boot Begin Start End +Blocks Id System +<br>/dev/hda1 * 1 +1 117 204800 6 +DOS 16-bits >=32M +<br>/dev/hda2 118 +118 597 839680 83 +Linux Native +<p>Command (m for help): +<br>----------------------------------------------------------------------------------------------------- +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<br> +<center> +<p><a NAME="3.3"></a><u><font size=+1>3.3-) Mudando o tipo de uma partição</font></u></center> + +<p> O tipo da partição é a identificação +de qual sistema de arquvios que ela pertence e na qual possuem características +próprias e diferentes de outros sistemas de arquivos. +<br> Tecle <t> para trocar o tipo de partição +usado no disco. +<br>Pressione a tecla <l> se desejar ver os tipos de partições +compatíveis com o programa fdisk. +<br> Veja o exemplo de como trocar o tipo da partição +de Linux Native (<i>tipo 83</i>) para Linux Swap (<i>tipo 82</i>). +<br>----------------------------------------------------------------------------------------------------- +<br> Command (m for help): <t> +<br> Partition number (1-4): <3> +<br> Hex code (type L to list codes): <82> +<br>----------------------------------------------------------------------------------------------------- +<br> Agora a partição em /dev/hda3 é +do tipo Linux SWAP(tipo 82). +<br> +<p>Pressione a tecla <p> para verificar a partição /dev/hda3: +<br>----------------------------------------------------------------------------------------------------- +<br>Command (m for help): p +<br>Disk /dev/hda: 16 heads, 21 sectors, 630 cylinders +<br>Units = cylinders of 630*512 bytes +<p> Device Boot Begin Start End +Blocks Id System +<br>/dev/hda1 * 1 +1 117 204800 6 +DOS 16-bits >=32M +<br>/dev/hda2 118 +118 597 839680 83 +Linux Native +<br>/dev/hda3 598 +598 630 61440 83 +Linux SWAP +<p>Command (m for help): +<br>----------------------------------------------------------------------------------------------------- +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="3.4"></a><u><font size=+1>3.4-) Excluindo uma partição +de Disco</font></u></center> + +<p> Para excluir uma partição, pressione +a tecla <d>, será mostrada a seguinte tela: +<br>---------------------------------------------------------------------------------------------------- +<br>Command (m for help):<d> +<br>Partition number(1-4): 3 +<p>Command(m for help): +<br>---------------------------------------------------------------------------------------------------- +<br> Com o comando acima, a partição número +3 (SWAP) foi excluida,. O espaço ocupado pela partição +3 é novamente liberado para que voce possa utilizar para criar outra +(ou outras) partições de disco. +<p><b>ATENÇÃO</b>: TENHA MUITO CUIDADE COM O DA OPÇÃO +<D>(Delete) DO FDISK. +<br> +Caso se tenha apagado acidentalmente alguma partição que +contém dados, pressione +<br> +a tecla <q> para sair do fdisk sem gravar o que fez. Neste caso, será +necessário +<br> +refazer todo o particionamento do disco. Não pressione a tecla +<w> se voce excluiu +<br> +alguma partição que utiliza, porque todo o que foi feito +no fdisk será gravado, +<br> +inclusive a partição excluida acidentalmente, sem a possibilidade +de recupera-la. +<p>para verificar se a partição foi excluida pressionamos +<p>: +<br>----------------------------------------------------------------------------------------------------- +<br>Command (m for help): p +<br>Disk /dev/hda: 16 heads, 21 sectors, 630 cylinders +<br>Units = cylinders of 630*512 bytes +<p> Device Boot Begin Start End +Blocks Id System +<br>/dev/hda1 * 1 +1 117 204800 6 +DOS 16-bits >=32M +<br>/dev/hda2 118 +118 597 839680 83 +Linux Native +<br>Command (m for help): +<br>---------------------------------------------------------------------------------------------------- +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="3.5"></a><u><font size=+1>3.5-) Gravando partições +alteradas para o disco</font></u></center> + +<p> Para gravar as alterações feitas +na(s) partições para o disco após fazer o particionamento, +pressione a tecla <w>, esta opção faz a saida do fdisk +gravando todas as alterações que fez durante o uso do programa +fdisk(partições criadas, alteradas, excluidas). +<br> Enquando voce trabalha no fdisk criando partições, +modificando tamanhos, excluindo partições, nada do que faz +é gravado para o disco automaticamente (por motivos de segurança +contra perda de alguma partição já existente). +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="3.6"></a><u><font size=+1>3.6-) Abandonando o particionamento +de disco sem gravar as alterações</font></u></center> + +<p> Para sair do fdisk sem gravar as alterações +para o disco pressione <q>. Esta opção de sair do fdisk +sem gravar as alterações(abandona o programa), é bastante +útil caso tenha apagado acidentalmente uma partição +que contenha arquivos e programas importantes armazenados nela. +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="3.7"></a><u><font size=+1>3.7-) Alternando entre partição +inicializável e não inicializável</font></u></center> + +<p> Partição inicializável +é aquela em que o sistema pode dar a partida(boot) no computador. +Pressione a tecla <a> para alterar o tipo da partição +entre inicializável e não inicalizável. +<br><b>OBS</b>: O Linux pode iniciar mesmo que a partição +que esta instalado esteja marcada como não +<br> inicializável, +utilizando um boot manager(gerenciador de inicialização) +como o LILO(Linux +<br> Loader) ou o +LoadLin no DOS. +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="3.8"></a><u><font size=+1>3.8-) Alterando a unidade de medida +do tamanho ocupado pela partição</font></u></center> + +<p> Para alterar de uma unidade de medida para outra, +pressione a tecla <u>. A unidade de medida da partição, +é o valor com que será mostrado o tamanho que a partição +ocupa no disco toda a vez que se pressiona a tecla <p>, para mostrar +as partições na tela, durante o particionamento de disco +ou quando se utilizar a opção -l na linha de comando, para +listar as partições de disco. +<p>As unidades de medida disponíveis são: +<br><i>Cilindros</i> : Este é o padrão do sistema, corresponde +ao local onde começa e +<br> +aonde termina a partição, em cilindros. +<br><i>Setores</i> : corresponde ao local onde começa +e aonde termina a partição, em +<br> +Setores. +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<br> +<center> +<p><a NAME="4"></a><u><font size=+1>4-) Outros tipos de partições +disponíveis no fdisk(para referência técnica)</font></u></center> + +<p> Abaixo, segue a listagem dos tipos de partições +compatíveis com esta versão do fdisk, que pode servir de +guia durante o processo de particionamento, e para que conheça a +compatibilidade deste programa com os diversos tipos de partições +que suporte. +<p><b>OBS1</b>: Recomendo que voce use o programa de particionamento que +acompanha seu sistema +<br> +operacional para a criação de seu sistema de arquivos, por +exemplo: +<br> +- Para criar uma partição DOS, utilize o Fdisk que acompanha +o DOS. +<br> +- Para criar uma partição Linux, utilize o Fdisk que acompanha +o Linux. +<br> +<p><b><u>Tipo</u> <u>Descrição</u></b> +<p>0 Vazio +<br>1 DOS FAT 12 +<br>2 Xenix root +<br>3 Xenix /usr +<br>4 DOS 16-bits<32MB +<br>5 Extendida DOS +<br>6 DOS 16-bits >=32MB +<br>7 OS/2 HPFS +<br>8 AIX +<br>9 AIX inicializável +<br>a OS/2 Boot Manager +<br>40 Venix 80286 +<br>51 Novell +<br>52 Microport +<br>63 GNU hurd +<br>64 Novell Netware 286 +<br>65 Novell Netware 386 +<br>75 PC/IX +<br>80 OLD Minix +<br>81 Linux Minix +<br>82 Linux SWAP +<br>83 Linux Native +<br>85 Linux Extendida +<br>93 Amoeba +<br>94 Amoeba BBT +<br>a5 BSD/386 +<br>a6 Open BSD +<br>a7 NextStep +<br>b7 BSDI File System +<br>b8 BSDI Swap +<br>c7 Syrinx +<br>db CP/M +<br>e1 DOS access +<br>e3 DOS R/O +<br>f2 Dos Secundária +<br>ff BBT +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="5"></a><u><font size=+1>5-) Direitos Autorais</font></u></center> + +<p> Este documento foi desenvolvido +com base em minha experiência e conhecimento em discos e partições, +mediante pesquisa em alguns documentos como os How-TO do Linux e verificando +as principais dúvidas de usuários durante a utilização +de particionadores de disco, tendo como objetivo levar o conhecimento sobre +discos, partições e utilização deste programa, +atendendo tanto usuários iniciantes como avançados e como +contribuição para a comunidade Linux em geral. +<br> +<br> +<br> +<br> +<center> +<p>Gleydson M. da Silva (<i>gleydson_s@yahoo.com</i> e <i>gleydson@linuxbr.com.br</i>)</center> + +<p> Qualquer dúvida, sugestão ou reclamação +podem ser mandadas para um dos E-Mail's Acima. Conto com sua contribuição +para a melhoria deste Manual. +<center> +<p><b> Autorizo a reprodução Total ou parcial +deste texto para que seja utilizado para fins educativos, autoaprendizado, +colocação em Home pages e qualquer outra forma de distribuição +não comercial do documento desde que sejam mantidos os meus créditos +pela pesquisa e elaboração deste documento de acordo com +os termos da GNU (veja abaixo <a href="#6">Licenças e Garantias +sobre este documento</a>).</b></center> + +<div align=right> +<br><a href="#Indice">Volta ao Índice</a></div> + +<center><a NAME="6"></a><font size=+1>6- ) Licenças e garantias +sobre este documento</font></center> + +<p><b>Fdisk-Portugues-HOWTO Copyright (C) 1999 Gleydson M. da Silva</b> +<p> Este é um documento de livre distribuição, +que pode ser copiado e distribuído sob os termos da Licença +Pública Geral GNU, conforme publicada pela Free Software Foundation, +versão 2 da licença ou (a critério do autor) qualquer +versão posterior. +<br><b> Este documento é distribuído com a itenção +de ser útil ao seu utilizador, no entanto NÃO TEM NENHUMA +GARANTIA, EXPLÍCITAS OU IMPLÍCITAS , COMERCIAIS OU +DE ATENDIMENTO A UMA DETERMINADA FINALIDADE. Consulte a Licença +Pública Geral GNU para maiores detalhes.</b> +<p><i>gleydson_s@yahoo.com</i> +<br><i>gleydson@linuxbr.com.br</i> +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<br> +<center> +<p><a NAME="7"></a><font size=+1>7- ) Marcas Registradas</font></center> + +<p>Os programas e referências mencionados neste manual são +de propriedade dos seus respectivos donos: +<p>MS-DOS, Windows 3.1x, Windows 9x, Windows NT são de propriedade +da Microsoft. +<br>OS/2 e OS/2 Warp são de propriedade da IBM +<div align=right><a href="#Indice">Volta ao Índice</a></div> + +<center><a NAME="8"></a><font size=+1>8- ) Agradecimentos</font></center> + +<p>Agradeço a todas as pessoas que me mandam correções, +comentários, críticas, elogios, dúvidas sobre este +documento, pois através destas mensagens, estão contribuindo +para a melhoria deste projeto e me icentivando em sua continuação. +<div align=right> +<br><a href="#Indice">Volta ao Índice</a></div> +<EOF> +</body> +</html> diff --git a/fdisk/doc/Fdisk-Portuguese.txt b/fdisk/doc/Fdisk-Portuguese.txt new file mode 100644 index 000000000..fbf0dcf87 --- /dev/null +++ b/fdisk/doc/Fdisk-Portuguese.txt @@ -0,0 +1,855 @@ + Fdisk-Portuguese Copyright (C) 1999 Gleydson M. da Silva + + + + + + + + + + Gleydson M. da Silva - gleydson@linuxbr.com.br + Versão 1.3 + + + + + + + + + +[ Índice ] + +1 - Introdução ao Fdisk + 1.1 - O que é uma Partição de Disco + 1.2 - A tabela de partição + 1.3 - Introdução ao Particionamento de discos + 1.4 - Identificações utilizadas neste documento + 1.5 - Identificação de discos e partições no Linux + 1.6 - Tipos de partições de disco + 1.7-) Observações sobre o formato DOS 6.XX(FAT 16) + +2 - Iniciando o programa Fdisk + 2.1 - Opções de Linha de comando + 2.2 - Comandos do Fdisk + +3 - Manipulando partições no disco rígido + 3.1 - Listando partições existentes no disco + 3.2 - Criando partições de disco + 3.3 - Mudando o tipo da partição + 3.4 - Excluindo uma partição de disco + 3.5 - Gravando partições alteradas para o disco + 3.6 - Abandonando o programa sem gravar alterações para o disco + 3.7 - Alternando entre partição inicializável/não inicializável + 3.8 - Escolhendo a unidade para mostrar o tamanho ocupado pela partição + +4 - Tipos de partições reconhecídas pelo Fdisk + +5 - Direitos Autorais + +6 - Licenças e Garantias sobre este documento + +7 - Marcas Registradas + +8 - Agradecimentos + + + + + + + + + + + + + +1-) Introdução ao Fdisk + + Fdisk é um programa utilizado para fazer o particionamento de discos rígidos +IDE e SCSI. + A versão do programa Fdisk descrita neste manual é a 2.8 +ATENÇÃO: ESTE MANUAL TEM COMO OBJETIVO A EXPLICAÇÃO DE FUNCIONAMENTO E + UTILIZAÇÃO DO FDISK DO LINUX (NÃO O FDISK DO DOS), MESMO QUE + SEJA UM USUÁRIO DO DOS, EU RECOMENDO QUE LEIA ESTE MANUAL + COMO UMA REFERÊNCIA TÉCNICA E PARA SEU APRENDIZADO. + + Este documento é distribuído com a itenção de ser útil ao seu utilizador, +no entanto NÃO TEM NENHUMA GARANTIA, EXPLÍCITAS OU IMPLÍCITAS , COMERCIAIS +OU DE ATENDIMENTO A UMA DETERMINADA FINALIDADE. Consulte a Licença Pública +Geral GNU para maiores detalhes. + + + +1.1-) Partição de Disco + + Uma partição de disco é o local onde o sistema operacional armazena seu +sistema de arquivos(arquivos, diretórios, FAT, boot sector, etc). + + + +1.2-) Tabela de partição + +A Tabela de partição é o local do disco rígido onde se localizam os dados sobre +todas as partições existentes no disco como o sistema de arquivos utilizado, se +ela é inicializável, a cabeça inicial/final, setor inicial/final, cilindro +inicial/final, número de setores ocupados por ela no disco. + + + +1.3-) Introdução ao particionamento de discos + +Particionar o disco rígido é dividir ele em partes para armazenamento +de arquivos e programas. As partições criadas no disco podem ter o tamanho +que desejar (desde que esteja dentro da capacidade máxima do disco rígido). + +Uma partição não interfere em outras partições do mesmo disco(é como +se tivessemos vários discos rígidos dentro de um). + +Em um disco rígido, pode ser criada uma partição única, que neste caso +todo o disco rígido é usado para armazenar os arquivos(que é o caso mais +comum caso voce tenha o DOS), ou várias partições, que podem ser usadas +pelo mesmo SO(Sistema Operacional) ou outros sistemas operacionais diferentes +(um exemplo de várias partições, é se voce for usar o DOS e o Linux no mesmo +disco, os dois sistemas vão estar no mesmo disco mas um não interfere no +outro). + +Este manual tem a itenção de explicar o particionamento de discos utilizando +o programa fdisk (fdisk do Linux não do DOS!). + + + +1.4-) Algumas identificações utilizadas neste manual para facilitar a + compreensão do texto + +Esta parte descreve algumas características de organização deste manual +e algumas identificações que adotei para facilitar o seu entendimento, e as +explicações que serão dadas. + +Explicação de nomes e comandos, sera seguida da palavra "onde" e abaixo +dela as explicações sobre os comandos, exemplo: + +onde: +nome a ser explicado1 : Descrição +nome a ser explicado2 : Descrição +nome a ser explicado3 : Descrição + +ou + +onde: +nome a ser explicado1 - Descrição +nome a ser explicado2 - Descrição +nome a ser explicado3 - Descrição + + +Quando for feita alguma referência com tecla do teclado, por exemplo, +pressione p para listar as partições, a letra sera colocada entre <> para +facilitar a interpretação: + +pressione <p> para listar as partições +após isto pressione <Enter> para confirmar +pressione <l> para listar os tipos de partições disponíveis + + +As linhas pontilhadas que aparecem na tela, veja abaixo, +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +servem para identificar que o que esta entre as linhas é um exemplo de como +será a resposta do comando para a tela de seu computador. + + + +1.5-) Identificação de discos e partições no Linux + +Antes de descrever como se utiliza o programa fdisk, é importante fazer +algumas explicações sobre a identificação das partições e unidades de disco +no sistema Linux( e outros *nix). Se voce for um usuário que já conhece +a interpretação de discos e partições neste sistema, voce não precisará ler +esta parte. + +No sistema operacional Linux, os dispositivos existentes no computador +(como impressoras, unidades de disquetes, discos rígidos, monitor, placa de +som, etc...) são identificados por um nome referente a este dispositivo e +colocado no diretório /dev (que é utilizado para identificar dispositivos ou +periféricos existentes no computador). + +A identificação dos discos rígidos segue a seguinte forma: + + /dev/hda1 + | | || + | | ||_Número que identifica a partição do disco rígido(1=Primeira, 2=segunda) + | | | + | | |_Letra que identifica o disco rígido(a=primeiro disco, b=segundo disco, etc..) + | | + | |_Sigla HD - Significa que é um disco rígido IDE(Se tiver um SD significa SCSI) + | + |_ Identificação do diretório onde os dispositivos do sistema são armazenados + +OBS: As unidades de disco rígido SCSI, são identificadas com as letras SD + seguida pela letra da unidade e número da partição e os discos IDE são + identificados por HD seguida pela letra da unidade de disco e o número + da partição do disco(como visto acima). + +Abaixo, algumas identificações de disco do sistema Linux: + +/dev/hda1 - Disco rígido IDE primário principal - Primeira partição +/dev/hda2 - Disco rígido IDE primário principal - Segunda partição +/dev/hda3 - Disco rígido IDE primário principal - Terceira partição +/dev/hdb1 - Disco rígido IDE primário escravo - Primeira partição +/dev/hdb2 - Disco rígido IDE primário escravo - Segunda partição +/dev/hdb3 - Disco rígido IDE primário escravo - Terceira partição +/dev/hdc1 - Disco rígido IDE secundário principal - Primeira partição +/dev/hdc2 - Disco rígido IDE secundário principal - Segunda partição +/dev/hdc3 - Disco rígido IDE secundário principal - Terceira partição +/dev/hdd1 - Disco rígido IDE secundário escravo - Primeira partição +/dev/hdd2 - Disco rígido IDE secundário escravo - Segunda partição +/dev/hdd3 - Disco rígido IDE secundário escravo - Terceira partição +/dev/sda1 - Primeiro disco rígido SCSI - Primeira partição +/dev/sda2 - Primeiro disco rígido SCSI - Segunda partição +/dev/sda3 - Primeiro disco rígido SCSI - Terceira partição +/dev/sdb1 - Segundo disco rígido SCSI - Primeira partição +/dev/sdb2 - Segundo disco rígido SCSI - Segunda partição +/dev/sdb3 - Segundo disco rígido SCSI - Terceira partição + +No exemplo acima foram usadas 3 partições por disco, mas podem existir +mais partições no mesmo disco, um exemplo é se o disco rígido possuir +partições Lógicas, que são identificadas no sistemas a partir de /dev/hdx5 +em diante. + +Abaixo um exemplo de como o Linux identifica as partições em cada disco +existente em seu computador: + +Vamos supor que eu tenha 2 discos rígidos: +o 1ºdisco de 2GB e o 2ºdisco de 1GB(Giga Byte ou 1.000 Megas!) + +No primeiro disco(de 2GB), a primeira partição é de 800MB do tipo +FAT16(DOS), a segunda partição é de 1.2GB do tipo EXT2(Linux)(1.2GB+800MB=2GB +que é a capacidade total do disco). Então as partições seriam identificadas +da seguinte forma no Linux: + +/dev/hda - Disco rígido Primário Principal +/dev/hda1 - Primeira partição do primeiro disco rígido (de 800MB do tipo DOS) +/dev/hda2 - Segunda partição do primeiro disco rígido( de 1.2GB do tipo Linux) + +Neste caso estariam disponíveis 800MB para serem usados com o DOS e +1.2GB para o Linux. +Por exemplo, se voce particionar um disco rígido em duas partes e usar +as duas partições no DOS, ele reconhecerá as partições como sendo C: e D:. + +Lembre-se: Quando um disco é particionado, uma partição não interfere + nas outras, repare que quando voce particiona(divide) um disco, + é como se tivesse dois discos rígidos(o único cuidado que + voce deve tomar é com as cópias de segurança, porque se der + um problema de parte eletrônica no disco rígido, por exemplo, + a sua placa controladora queimar ou o cabeçote dele ir pro + espaço, voce perderá as suas 2 partições que estão armazenadas + nele. + + +Voltando ao exemplo das classificações das partições do disco, vamos +para o segundo disco: + +No segundo disco(1GB), eu tenho uma partição de 950MB do tipo FAT16(DOS), +que costumo usar para armazenar arquivos temporários e cópias de segurança +de meu sistema, etc..., e outra de 50MB SWAP(Partição de memória virtual +como descrevi acima)(950MB+50MB=1GB). Então as partições deste disco seriam +identificadas da seguinte forma no Linux: + +/dev/hdb - Disco rígido principal escravo +/dev/hdb1 - Primeira partição do disco acima ( de 950MB do tipo DOS) +/dev/hdb2 - Segunda partição do disco acima ( de 50MB do tipo SWAP) + +No disco acima, 950MB estão disponíveis para serem usados pelo DOS e 50 MB pela +memória virtual (SWAP) do Linux. + +Note que se voce utiliza o MS-DOS, não será possível ver as partições +do Linux e SWAP, porque são imcompatíveis com o formato aceito pelo DOS (ele +identificaria a primeira partição do primeiro disco(800MB) como a unidade C: +e a primeira partição do segundo disco(950MB) como unidade D), mas o +contrário não acontece; O Linux tem total compatibilidade com a partição +DOS FAT12, FAT16, FAT32, OS/2 HPFS, e muitas outras. + + + +1.6-) Tipos de partições de discos + +As partições de disco são divididas em tres tipos: Primária, Extendida +e Lógica. + +Pode se ter no máximo quatro partições primárias e extendidas no mesmo +disco. A partição Primária permite o armazenamento de arquivos e diretórios. +Todos os computadores que possuem somente a unidade C(supondo que voce use o +DOS), usam este tipo de partição para armazenamento de arquivos e inicialização +do sistema operacional. + +Se for preciso criar mais que 4 partições no mesmo disco, será necessário +criar uma partição Extendida. A partição Extendida não pode ser utilizada +para armazenar arquivos. Ela é usada para a criação de outras partições, +dentro dela, que são chamadas de partições Lógicas. + +Uma partição extendida podem conter várias partições Lógicas. As partições +Lógicas podem armazenar arquivos e diretórios(como as partições primárias). + +Um mesmo disco rígido pode armazenar mais de 64 partições independentes +uma das outras. + +OBS: Os arquivos e diretórios podem ser armazenados somente em partições de + disco primárias ou lógicas, a partição extendida não é usada para armazanamento + de arquivos e diretórios. + +Se possuir duas partições em seu computador (C: e D: no DOS), e não +estiver usando a partição D:, a instalação pode ser feita nesta partição +desde que ela tenha o espaço necessário para o sistema operacional Linux, +os programas que desejar instalar, mais a partição SWAP. + + + +1.7-) Observações sobre o formato DOS 6.XX(FAT 16) + +No formato DOS 6.XX(FAT16), o primeiro setor da área de dados da partição +é utilizado frequentemente pelo DOS para armazenamento de dados sobre a +partição de disco, e estes dados são usados pelo sistema para se ter maior +confiabilidade do que os dados armazenados na tabela de partição. O sistema +de arquivos DOS, faz o FDISK(do DOS) limpar os primeiros 512 bytes da área +de dados da partição sempre que uma mudança de tamanho acontecer. + +O formatador do DOS(format) verifica este primeiro setor toda vez que +a upção /U (que é utilizada para não salvar dados para se fazer a desformatação +do disco) é utilizada. + +Isto é considerado uma FALHA no Format(do DOS) e no Fdisk(do DOS). +A opção abaixo deve ser utilizada caso voce crie uma partição do DOS FAT16 +com o Fdisk, que faz com que os primeiros 512 bytes daquela partição +sejam "limpos", para manter a compatibilidade com o DOS. Utilize esta opção +dentro do Linux, após criar a partição com o Fdisk e reiniciar o seu +computador. Foi notado que esta opção só funciona corretamente somente quando +o Sistema Linux estiver instalado em seu computador. Não me responsabilizo +caso utiliza-la a partir de um disquete de recuperação. + +dd if=/dev/zero of=/dev/hdx1 bs=512 count=1 + +onde: +hdx1 - É a identificação da unidade de disco e a partição que foi criada + pelo Fdisk utilizando o sistema de arquivos DOS que terá seu + primeiro setor "limpo". + + +OBS1: Cuidado ao utilizar esta opção, um pequeno descuido pode resultar na + perda de dados do seu disco rígido ou outras partição. + +OBS2: Não utilize este comando com partições que utilizam o sistema de arquivos + FAT32(utilizada nos sistemas operacionais Windows 95 OSR/2 e superiores) + se for utilizada em um disco com este sistema, sua FAT será corrompida, + se isto acontecer, será necessária a re-formatação da partição. + +OBS3: É extremamente recomendado que se utilize o programa de particionamento + que acompanha o seu sistema operacional. Por exemplo, se deseja criar + uma partição DOS 6.XX, utilize o FDisk qua acompanha o DOS. + + + +2-) Iniciando o programa Fdisk + +Para iniciar o programa fdisk(Linux)digite: +fdisk [unidade] + +Onde: +unidade - deve ser a unidade de disco rígido no padrão Linux( /dev/hda, + /dev/hdb, /dev/sda, /dev/sdb, etc... ). Se voce tem apenas 1 + disco rígido IDE, use /dev/hda, para fazer o fdisk trabalhar + com este disco. Se possuir 1 disco SCSI, use /dev/sda + +Se a unidade não for especificada, o programa fdisk usará /dev/hda como +unidade de disco padrão. + +ATENÇÃO : A OPERAÇÃO DE PARTICIONAMENTO DE DISCOS PODE FAZER COM QUE OS DADOS + ARMAZENADOS EM SEU DISCO RÍGIDO SEJAM PERDIDOS, SE FOR USADA + INCORRETAMENTE. É SEMPRE RECOMENDADO RETIRAR UMA CÓPIA DE SEGURANÇA + DOS SEUS ARQUIVOS EXISTENTES NO MICRO ANTES DE SE EXECUTAR UM + PROGRAMA DESTE TIPO, A NÃO SER QUE TENHA CONFIANÇA NO QUE ESTA + FAZENDO E QUE ENTENDEU AS EXPLICAÇÕES SOBRE A IDENTIFICAÇÃO DE + DISCOS RÍGIDOS E SUAS PARTIÇÕES NO SISTEMA. + + + +2.1-) Opções de linha de comando + +Com a utilização de opções de linha de comando, voce pode fazer com que +o programa inicie de uma forma específica, ou personalizada. + +fdisk [-b] [-u] [unidade] - Opções aceitas para o particionamento. +fdisk [-l] [-b] [-u] - Opções aceitas para listar as partições atuais. +fdisk [-s] [unidade] - Opção aceita para mostrar o Tamanho da partição +fdisk [-v] - Versão do programa + +Onde: +-b : Faz com que o fdisk mostre na tela a coluna BEGIN quando utilizar + a opção <p> durante o particionamento do disco ou com a opção -l + quando se for listar as partições na linha de comando. + OBS: Esta opção é geralmente desnecessária, porque seu valor equivale + ao valor da coluna START. +-u : Muda a unidade de medida padrão para Setores. Se esta opção for usada + na linha de comando para se fazer o particionamento de disco, após + pressionar <p>, o programa mostrará na tela o inicio e o fim da + partição em Setores ao invés de utilizar cilindros para a listagem. + Se for utilizada em conjunto com a opção -l, a unidade de medida do + Inicio e Fim da partição será listada Setores ao invés de cilindros. +-l : Lista as partições existentes no disco, sem entrar no programa + fdisk, ou alterar qualquer partição. Esta opção é equivalente a + entrar no programa fdisk e pressionar <p>, mas ela somente lista + as partições sem entrar no programa. +-s : Mostra o tamanho de uma partição de disco. A única diferença desta + para as outras opções, é que se deve especificar a unidade mais a + partição que deseja ver o tamanho, por exemplo, digitando-se: + fdisk -s /dev/hda1 + voce visualizará o tamanho total da partição de disco hda1. +-v : Mostra a versão do programa fdisk que esta utilizando. + + + +2.2-) Comandos do fdisk. + +O fdisk do Linux manipula as partições de seu disco através de comandos +digitados no teclado. Cada letra digitada corresponde a um comando diferente +no fdisk. Estes comandos serão utilizados após iniciar o programa. + +Aqui vai a lista de comandos disponíveis no fdisk, recomendo que anote +em um papel, ou imprima esta parte do texto( ou todo o documento) para que +possa consultar estas opções durante o particionamento do seu disco rígido. + +a - Seleciona entre partição inicializável e não inicializável. +b - Edita um volume de disco BSD(não usada em computadores com DOS) +d - Apaga uma tabela de partição (Delete) +l - Lista os tipos de partições disponíveis (List) +m - Ajuda +n - Cria uma nova tabela de partição (New) +p - Mostra a tabela de partição atual (Print) +q - sai do fdisk sem gravar as alterações no disco (quit) +t - Muda o tipo da partição (Type) +u - Altera as unidades de medidas que são mostradas na tela +v - Verifica a tabela de partição (verify) +w - grava as alterações feitas para o disco e sai do fdisk (write) +x - Comandos especiais do programa(somente para usuários experientes) + + + +3-) Manipulando partições no disco rígido + +Agora vamos começar realmente a trabalhar com o fdisk, os textos que +foram colocados acima, foi para que voce entendesse o que é o particionamento +de um disco rígido e para que soubesse a diferença entre partição e um disco +rígido,(já vi muitas pessoas falarem de partição como se fosse disco rígido...) + +Abaixo uma explicação passo-a-passo de como particionar um disco usando +o fdisk e seus comandos. + +ATENÇÃO: O disco rígido usado no particionamento é um exemplo. Ele não deve + ser usado por voce para fazer o particionamento de seu disco, uma + vez que a capacidade e outros parâmetros do disco rígido variam de + um para o outro. Este exemplo serve apenas para que voce entenda + como o fdisk funciona, o que faz cada um de seus comandos e a + fazer o cálculo do tamanho das partições. + +A tradução das mensagens que aparecem em Ingles nos exemplos que vou colocar +logo abaixo, e a ajuda do programa, não foram feitas porque aparecem exatamente +como estão quando fizer o particionamento de seu disco, e não conheço +nenhuma versão do fdisk(Linux) em português (caso alguém conheça uma versão +deste programa em português, favor entrar em contato comigo para que eu +possa atualizar este documento, meu endereço de E-mail esta no final do +documento). +Somente vou explicar o que significa cada mensagem que aparece no fdisk +através de uma comparação. + +No exemplo eu vou usar um disco de 1.08GB. Este disco possui 630 cilindros, +16 cabeças, e 21 setores por trilha(modo LBA). + + + +3.1-) Listando partições existentes no disco + +Primeiro digite fdisk /dev/hda (supondo que este disco seja o principal), +se a unidade de disco não for digitada, o fdisk usará /dev/hda como padrão. +Após voce digitar este comando, o fdisk procura por partições existentes, +seus tamanhos e outras características(geometria do disco) que serão +utilizadas para se fazer o cálculo de partições. + +Quando entrar no programa, digite a letra <p> para que o programa mostre +as tabelas de partição existentes no disco rígido. + +A tela que aparece é a seguinte: + +---------------------------------------------------------------------------- +Command (m for help): p +Disk /dev/hda: 16 heads, 21 sectors, 630 cylinders +Units = cylinders of 630*512 bytes + + Device Boot Begin Start End Blocks Id System + /dev/hda1 * 1 1 117 204800 6 DOS 16-bits >=32M + +Command (m for help): +----------------------------------------------------------------------------- + + +Abaixo uma tradução desta tela: +---------------------------------------------------------------------------- +Commando (m para ajuda): <p> +Disco /dev/hda: 16 cabeças, 21 setores, 630 cilindros +Unidades = cilindros de 630*512 bytes + +Dispositivo Partida Começa Inicio Fim Blocos Identif. Sistema +/dev/hda1 * 1 1 117 204800 6 DOS 16-bits >=32M + +Comando (m para ajuda): +---------------------------------------------------------------------------- + +Onde: +Device : É a identificação da partição de disco. +Boot : Se estiver com "*", se a partição pode ser usada para BOOT. +Begin : Cilindro inicial da partição de disco +Start : Cilindro inicial da partição de disco +End : Cilindro Final da partição do disco +Blocks : Quantidade de blocos ocupados pela partição de disco. No Linux, um + Bloco equivale a 1024 bytes(1KB) +ID : Tipo da partição (conforme a lista de partições existentes quando é + pressionada a letra <L>. +System : Descrição do sistema de arquivos que é usado na partição de disco. + +Como vemos acima, o disco rígido possui uma partição do tipo DOS- FAT16 +ocupando 200MB de espaço em disco (200000 Blocos multiplicados por 1024). + + + +3.2-) Criando uma partição de Disco + +Para criar uma partição de disco, pressionamos a letra <n>. Neste +exemplo vamos criar uma partição do tipo Linux EXT2(Nativa) com o tamanho de +820MB, esta partição é a que conterá todo o sistema de arquivos Linux e seus +programas, veja o exemplo: + +---------------------------------------------------------------------------- +Command ( m for help): <n> + e extended + p primary partition (1-4) +<p> +Partition number (1-4): <2> +First cylinder(118-630): <118> +Last cylinder or +size or +sizeK or +sizeM (118-630): <+820M> +---------------------------------------------------------------------------- +O fdisk perguntará se deseja criar uma partição extendida ou primária. +Crie uma partição primária para o sistema de arquivos do Linux, ou uma +partição extendida caso voce ja tenha 3 partições primárias criadas em seu +disco, conforme foi visto acima. + +Como pode ter notado no exemplo acima, como já existia a partição 1, +digitamos o número 2 para que fosse criada uma segunda partição, se +a partição número 2 já existisse, seria digitado o número 3 para criar +uma terceira partição, assim por diante. + +Após escolher o tipo de partição que será criada, voce deverá especificar +o cilindro inicial da partição de disco. No exemplo acima, o valor do cilindro +inicial é de 118. Utilize sempre o valor do cilindro inicial sugerido pelo +fdisk, a não ser que se queira deixar um espaço entre uma partição antiga e +a nova partição para a criação de uma partição menor ou por outros motivos. + +O último passo é especificar onde terminará a partição de disco. É +permitida a utilização de Cilindros, bytes, Kbytes e Mbytes para marcar o +final da partição de disco (veja detalhes abaixo). + +LEMBRE-SE: Em um mesmo disco rígido podem existir até 4 partições primárias + (contando com a partição Extendida). + +onde: + Partition number : Número da partição que vai ser criada, como já temos + uma partição no disco, digitamos o número 2 para + dizer ao fdisk que queremos criar uma segunda partição + primária. Neste exemplo, voce acabou de criar a + partição /dev/hda2. + First cylinder : Primeiro cilindro disponível após o último cilindro + usado pela partição 1. Neste caso usamos o cilindro + 118 até o cilindro final(Last Cylinder). O valor + deve ser digitado em cilindros. + Last cylinder or +size or +sizeK or +sizeM : Aqui voce pode especificar + o final da partição de disco. + Os seguintes valores podem ser usados para marcar o + final da partição de disco: + + 597 - É o valor equivalente a partição de 820MB + (em cilindros) + +820000000 - É o valor equivalente a partição de + 820MB (em bytes) + +820000K - É o valor equivalente a partição de + 820MB (em Kbytes) + +820M - É o valor equivalente a partição de + 820MB (em Mbytes) + +Recomendo que especifique o valor em MB ou KB por não exigir o +cálculo do espaço do disco usado em cada cilindro, e por ser um dos mais +utilizados e mais práticos. Especificando o valor em bytes, Kbytes ou +Mbytes, o fdisk se encarregará de converter o tamanho digitado para +um valor de cilindro final. + +Se digitar um número acima do espaço disponível no disco(ou cilindro +diponível), será mostrada uma mensagem de erro dizendo que a partição não +pode ser criada. + +OBS: Caso seja criada uma partição DOS FAT16, deverá ser utilizado o comando + dd if=/dev/zero of=/dev/hdx1 bs=512 count=1 + para que a partição criada seja compatível com o formato utilizado pelo + DOS. Para maiores detalhes veja Observações sobre o formato DOS 6.XX + + + Para verificar as partições existentes no disco tecle <p> +---------------------------------------------------------------------------- +Command (m for help): p +Disk /dev/hda: 16 heads, 21 sectors, 630 cylinders +Units = cylinders of 630*512 bytes + + Device Boot Begin Start End Blocks Id System +/dev/hda1 * 1 1 117 204800 6 DOS 16-bits >=32M +/dev/hda2 118 118 597 839680 83 Linux Native + +Command (m for help): +---------------------------------------------------------------------------- + + + + +3.3-) Mudando o tipo de uma partição + +O tipo da partição é a identificação de qual sistema de arquvios que ela +pertence e na qual possuem características próprias e diferentes de outros +sistemas de arquivos. + +Tecle <t> para trocar o tipo de partição usado no disco. +Pressione a tecla <l> se desejar ver os tipos de partições compatíveis +com o programa fdisk. + +Veja o exemplo de como trocar o tipo da partição de Linux Native (tipo +83) para Linux Swap (tipo 82): + +---------------------------------------------------------------------------- + Command (m for help): <t> + Partition number (1-4): <3> + Hex code (type L to list codes): <82> +---------------------------------------------------------------------------- + Agora a partição em /dev/hda3 é do tipo Linux SWAP(tipo 82). + + +Pressione a tecla <p> para verificar a partição /dev/hda3: +---------------------------------------------------------------------------- +Command (m for help): p +Disk /dev/hda: 16 heads, 21 sectors, 630 cylinders +Units = cylinders of 630*512 bytes + + Device Boot Begin Start End Blocks Id System +/dev/hda1 * 1 1 117 204800 6 DOS 16-bits >=32M +/dev/hda2 118 118 597 839680 83 Linux Native +/dev/hda3 598 598 630 61440 83 Linux SWAP +Command (m for help): +---------------------------------------------------------------------------- + + + +3.4-) Excluindo uma partição de Disco + +Para excluir uma partição, pressione a tecla <d>, será mostrada a seguinte +tela: + +---------------------------------------------------------------------------- +Command (m for help):<d> +Partition number(1-4): 3 + +Command(m for help): +---------------------------------------------------------------------------- + +Com o comando acima, a partição número 3 (SWAP) foi excluida,. O espaço +ocupado pela partição 3 é novamente liberado para que voce possa utilizar +para criar outra (ou outras) partições de disco. + +ATENÇÃO: TENHA MUITO CUIDADE COM O DA OPÇÃO <D>(Delete) DO FDISK. Caso se + tenha apagado acidentalmente alguma partição que contém dados, + pressione a tecla <q> para sair do fdisk sem gravar o que fez. + Neste caso, será necessário refazer todo o particionamento do disco. + Não pressione a tecla <w> se voce excluiu alguma partição que + utiliza, porque todo o que foi feito no fdisk será gravado, inclusive + a partição excluida acidentalmente, sem a possibilidade de + recupera-la. + +para verificar se a partição foi excluida pressionamos <p>: +---------------------------------------------------------------------------- +Command (m for help): p +Disk /dev/hda: 16 heads, 21 sectors, 630 cylinders +Units = cylinders of 630*512 bytes + + Device Boot Begin Start End Blocks Id System +/dev/hda1 * 1 1 117 204800 6 DOS 16-bits >=32M +/dev/hda2 118 118 597 839680 83 Linux Native +Command (m for help): +---------------------------------------------------------------------------- + + + +3.5-) Gravando partições alteradas para o disco + +Para gravar as alterações feitas na(s) partições para o disco após +fazer o particionamento, pressione a tecla <w>, esta opção faz a saida do +fdisk gravando todas as alterações que fez durante o uso do programa +fdisk(partições criadas, alteradas, excluidas). + +Enquando voce trabalha no fdisk criando partições, modificando tamanhos, +excluindo partições, nada do que faz é gravado para o disco automaticamente +(por motivos de segurança contra perda de alguma partição já existente). + + + +3.6-) Abandonando o particionamento de disco sem gravar as alterações + +Para sair do fdisk sem gravar as alterações para o disco pressione <q>. +Esta opção de sair do fdisk sem gravar as alterações(abandona o programa), +é bastante útil caso tenha apagado acidentalmente uma partição que contenha +arquivos e programas importantes armazenados nela. + + + +3.7-) Alternando entre partição inicializável e não inicializável + +Partição inicializável é aquela em que o sistema pode dar a partida(boot). +Pressione a tecla <a> para alterar o tipo da partição entre inicializável +e não inicalizável. + +OBS: O Linux pode iniciar mesmo que a partição que esta instalado esteja + marcada como não inicializável, utilizando um boot manager(gerenciador + de inicialização) como o LILO(Linux Loader) ou o LoadLin no DOS. + + + +3.8-) Alterando a unidade de medida do tamanho ocupado pela partição + +Para alterar de uma unidade de medida para outra, pressione a tecla <u>. +A unidade de medida da partição, é o tipo de valor que mostrará o tamanho +que a partição ocupa no disco toda a vez que se pressiona a tecla <p>, para +mostrar as partições na tela, durante o particionamento de disco ou quando +se utilizar a opção -l na linha de comando, para listar as partições de +disco. + +As unidades de medida disponíveis são: +Cilindros : Este é o padrão do sistema, corresponde ao local onde começa e + aonde termina a partição, em cilindros. +Setores : corresponde ao local onde começa e aonde termina a partição, em + setores. + + + + +4-) Outros tipos de partições disponíveis no fdisk(para referência técnica) + +Abaixo, segue a listagem dos tipos de partições compatíveis com esta versão +do fdisk, que pode servir de guia durante o processo de particionamento, e +para que conheça a compatibilidade deste programa com os diversos tipos +de partições que suporte. + +OBS1: Recomendo que voce use o programa de particionamento específico de + seu sistema operacional, por exemplo: + Para criar uma partição DOS, utilize o Fdisk do dos. + Para criar uma partição Linux, utilize o Fdisk dele. + + +Tipo Descrição + +0 Vazio +1 DOS FAT 12 +2 Xenix root +3 Xenix /usr +4 DOS 16-bits<32MB +5 Extendida DOS +6 DOS 16-bits >=32MB +7 OS/2 HPFS +8 AIX +9 AIX inicializável +a OS/2 Boot Manager +40 Venix 80286 +51 Novell +52 Microport +63 GNU hurd +64 Novell Netware 286 +65 Novell Netware 386 +75 PC/IX +80 OLD Minix +81 Linux Minix +82 Linux SWAP +83 Linux Native +85 Linux Extendida +93 Amoeba +94 Amoeba BBT +a5 BSD/386 +a6 Open BSD +a7 NextStep +b7 BSDI File System +b8 BSDI Swap +c7 Syrinx +db CP/M +e1 DOS access +e3 DOS R/O +f2 Dos Secundária +ff BBT + + + +5-) Direitos Autorais + +Este documento foi desenvolvido com base em minha experiência e conhecimento +em discos e partições, mediante pesquisa em alguns documentos como os How-TO's +do Linux, e verificando as principais dúvidas de usuários durante a utilização +de particionadores de disco, tendo como objetivo levar o conhecimento sobre +discos, partições e utilização deste programa, atendendo tanto usuários +iniciantes como avançados e como contribuição para a comunidade Linux em geral. + +Gleydson M. da Silva (gleydson_s@yahoo.com e gleydson@linuxbr.com.br) + +Qualquer dúvida, sugestão ou reclamação podem ser mandadas para um dos E-Mail's +Acima. Conto com sua contribuição para a melhoria deste Manual. + +Autorizo a reprodução Total ou parcial deste texto para que seja utilizado para +fins educativos, autoaprendizado, colocação em Home pages e qualquer outra forma +de distribuição não comercial do documento desde que sejam mantidos os meus +créditos pela pesquisa e elaboração deste documento de acordo com os termos da +GNU (veja baixo Licenças e Garantias sobre este documento). + + +6- ) Licenças e garantias sobre este documento + +Fdisk-Portuguese Copyright (C) 1999 Gleydson M. da Silva + +Este é um documento de livre distribuição, que pode ser copiado e +distribuído sob os termos da Licença Pública Geral GNU, conforme publicada +pela Free Software Foundation, versão 2 da licença ou (a critério do autor) +qualquer versão posterior. + +Este documento é distribuído com a itenção de ser útil ao seu utilizador, +no entanto NÃO TEM NENHUMA GARANTIA, EXPLÍCITAS OU IMPLÍCITAS , COMERCIAIS +OU DE ATENDIMENTO A UMA DETERMINADA FINALIDADE. Consulte a Licença Pública +Geral GNU para maiores detalhes. + +gleydson_s@yahoo.com +gleydson@linuxbr.com.br + + + +7- ) Marcas Registradas + +Os programas e referências mencionados neste manual são de propriedade dos +seus respectivos donos: + +MS-DOS, Windows 3.1x, Windows 9x, Windows NT são de propriedade da Microsoft. +OS/2 e OS/2 Warp são de propriedade da IBM + + +8- Agradecimentos + +Agradeço a todas as pessoas que me mandam correções, comentários, críticas, +elogios, dúvidas sobre este documento, pois através destas mensagens, estão +contribuindo para a melhoria deste projeto e me icentivando para sua continuação. + +<EOF>
\ No newline at end of file diff --git a/fdisk/fdisk.8 b/fdisk/fdisk.8 index 6307b98ec..e26baf1c5 100644 --- a/fdisk/fdisk.8 +++ b/fdisk/fdisk.8 @@ -5,9 +5,9 @@ .SH NAME fdisk \- Partition table manipulator for Linux .SH SYNOPSIS -.BI "fdisk [\-u] [" device ] +.BI "fdisk [\-u] " device .sp -.BI "fdisk \-l [\-u] [" "device ..." ] +.BI "fdisk \-l [\-u] " "device ..." .sp .BI "fdisk \-s " "partition ..." .sp @@ -189,20 +189,6 @@ of cylinders. The .I size of the partition (in blocks) is printed on the standard output. -This value is normally used as an argument to the -.BR mkfs (8) -program to specify the size of the partition which will be formatted. -(Older versions of fdisk would do this only if the partition id is -greater than 10, in an attempt to refuse DOS partitions; -this test has been deleted.) -Note that -.B "sfdisk -s" -gives different (namely, correct) answers. -Reasons for the difference are that the kernel and -.B fdisk -need not have the same idea about partition numbering -(e.g., in case you have BSD slices), and have different -ideas about the size of an extended partition. .SH BUGS There are several *fdisk programs around. Each has its problems and strengths. @@ -210,6 +196,20 @@ Try them in the order .BR cfdisk , .BR fdisk , .BR sfdisk . +(Indeed, +.B cfdisk +is a beautiful program that has strict requirements on +the partition tables it accepts, and produces high quality partition +tables. Use it if you can. +.B fdisk +is a buggy program that does fuzzy things - usually it happens to +produce reasonable results. Its single advantage is that it has +some support for BSD disk labels and other non-DOS partition tables. +Avoid it if you can. +.B sfdisk +is for hackers only - the user interface is terrible, but it is +more correct than fdisk and more powerful than both fdisk and cfdisk. +Moreover, it can be used noninteractively.) .PP The IRIX/SGI type disklabel is currently not supported by the kernel. Moreover, IRIX/SGI header directories are not fully supported yet. diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index 8cdc6df84..8270d344f 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -66,6 +66,22 @@ * Modified, Sat Oct 3 14:40:17 MET DST 1998, ANeuper@GUUG.de * Support SGI's partitioning -- an, 980930. * Do the verify using LBA, not CHS, limits -- aeb, 981206. + * Corrected single-cylinder partition creating a little, now that + * ankry@mif.pg.gda.pl pointed out a bug; there are more bugs -- aeb, 990214. + * + * Sat Mar 20 09:31:05 EST 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br> + * Internationalization + * + * Corrected deleting last logical partition -- aeb, 990430. + * Removed all assumptions on file names -- aeb, 990709 + * [modprobe gave ugly error messages, and the number of devices to probe + * increased all the time: hda, sda, eda, rd/c0d0, ida/c0d0, ... + * Also partition naming was very ugly.] + * + * Corrected a bug where creating an extended hda3, say, then a logical hda5 + * that does not start at the beginning of hda3, then a logical hda6 that does + * start at the beginning of hda3 would wipe out the partition table describing + * hda5. [Patch by Klaus G. Wagner" <kgw@suse.de>] -- aeb, 990711 */ @@ -78,6 +94,8 @@ #include <setjmp.h> #include <errno.h> #include <getopt.h> +#include <locale.h> +#include "nls.h" #include <sys/stat.h> #include <sys/ioctl.h> @@ -85,6 +103,7 @@ #include <linux/hdreg.h> /* for HDIO_GETGEO */ #include <linux/fs.h> /* for BLKRRPART, BLKGETSIZE */ +#include "common.h" #include "fdisk.h" #include "fdisksunlabel.h" @@ -92,6 +111,10 @@ #include "fdiskaixlabel.h" #include "../version.h" +#include "../defines.h" +#ifdef HAVE_blkpg_h +#include <linux/blkpg.h> +#endif #define hex_val(c) ({ \ char _c = (c); \ @@ -100,8 +123,6 @@ }) -#define DEFAULT_DEVICE "/dev/hda" -#define ALTERNATE_DEVICE "/dev/sda" #define LINE_LENGTH 80 #define offset(b, n) ((struct partition *)((b) + 0x1be + \ (n) * sizeof(struct partition))) @@ -175,7 +196,7 @@ get_nr_sects(struct partition *p) { /* normally O_RDWR, -l option gives O_RDONLY */ static int type_open = O_RDWR; -char *disk_device = DEFAULT_DEVICE, /* hda, unless specified */ +char *disk_device, /* must be specified */ *line_ptr, /* interactive input */ line_buffer[LINE_LENGTH], changed[MAXIMUM_PARTS], /* marks changed buffers */ @@ -195,8 +216,8 @@ uint heads, cylinders, sector_size = DEFAULT_SECTOR_SIZE, sector_offset = 1, - display_factor = 1, /* in units/sector */ - unit_flag = 1, + units_per_sector = 1, + display_in_cyl_units = 1, extended_offset = 0, /* offset of link pointers */ offsets[MAXIMUM_PARTS] = {0, 0, 0, 0}; @@ -210,58 +231,6 @@ struct partition *part_table[MAXIMUM_PARTS] /* partitions */ *ext_pointers[MAXIMUM_PARTS] /* link pointers */ = {NULL, NULL, NULL, NULL}; -struct systypes sys_types[] = { - {0x00, "Empty"}, - {0x01, "DOS 12-bit FAT"}, - {0x02, "XENIX root"}, - {0x03, "XENIX usr"}, - {0x04, "DOS 16-bit <32M"}, - {0x05, "Extended"}, - {0x06, "DOS 16-bit >=32M"}, - {0x07, "OS/2 HPFS"}, /* or QNX? */ - {0x08, "AIX"}, - {0x09, "AIX bootable"}, - {0x0a, "OS/2 Boot Manager"}, - {0x0b, "Win95 FAT32"}, - {0x0c, "Win95 FAT32 (LBA)"}, - {0x0e, "Win95 FAT16 (LBA)"}, - {0x0f, "Win95 Extended (LBA)"}, - {0x11, "Hidden DOS FAT12"}, - {0x14, "Hidden DOS FAT16"}, - {0x16, "Hidden DOS FAT16 (big)"}, - {0x17, "Hidden OS/2 HPFS or NTFS"}, - {0x40, "Venix 80286"}, - {0x41, "PPC PReP Boot"}, - {0x51, "Novell?"}, - {0x52, "Microport"}, /* or CPM? */ - {0x63, "GNU HURD"}, /* or System V/386? */ - {0x64, "Novell Netware 286"}, - {0x65, "Novell Netware 386"}, - {0x75, "PC/IX"}, - {0x80, "Old MINIX"}, /* Minix 1.4a and earlier */ - - {LINUX_PARTITION, "Linux/MINIX"}, /* Minix 1.4b and later */ - {LINUX_SWAP, "Linux swap"}, - {LINUX_NATIVE, "Linux native"}, - {LINUX_EXTENDED, "Linux extended"}, - - {0x93, "Amoeba"}, - {0x94, "Amoeba BBT"}, /* (bad block table) */ - {0xa5, "BSD/386"}, - {0xa6, "OpenBSD"}, - {0xa7, "NEXTSTEP"}, - {0xb7, "BSDI fs"}, - {0xb8, "BSDI swap"}, - {0xc7, "Syrinx"}, - {0xdb, "CP/M"}, /* or Concurrent DOS? */ - {0xe1, "DOS access"}, - {0xe3, "DOS R/O"}, - {0xeb, "BeOS fs"}, - {0xf2, "DOS secondary"}, - {0xff, "BBT"}, /* (bad track table) */ - { 0, NULL } -}; - jmp_buf listingbuf; void fatal(enum failure why) @@ -275,39 +244,53 @@ void fatal(enum failure why) } switch (why) { - case usage: message = -"Usage: fdisk [-b SSZ] [-u] [DISK] Change partition table\n" -" fdisk -l [-b SSZ] [-u] [DISK] List partition table(s)\n" -" fdisk -s PARTITION Give partition size(s) in blocks\n" -" fdisk -v Give fdisk version\n" + case usage: message = _( +"Usage: fdisk [-b SSZ] [-u] DISK Change partition table\n" +" fdisk -l [-b SSZ] [-u] DISK List partition table(s)\n" +" fdisk -s PARTITION Give partition size(s) in blocks\n" +" fdisk -v Give fdisk version\n" "Here DISK is something like /dev/hdb or /dev/sda\n" "and PARTITION is something like /dev/hda7\n" "-u: give Start and End in sector (instead of cylinder) units\n" -"-b 2048: (for certain MO drives) use 2048-byte sectors\n"; +"-b 2048: (for certain MO drives) use 2048-byte sectors\n"); + break; + case usage2: + /* msg in cases where fdisk used to probe */ + message = _( +"Usage: fdisk [-l] [-b SSZ] [-u] device\n" +"E.g.: fdisk /dev/hda (for the first IDE disk)\n" +" or: fdisk /dev/sdc (for the third SCSI disk)\n" +" or: fdisk /dev/eda (for the first PS/2 ESDI drive)\n" +" or: fdisk /dev/rd/c0d0 or: fdisk /dev/ida/c0d0 (for RAID devices)\n" +" ...\n"); break; case no_device: - message = "A disk block device is needed.\n"; + message = _("A disk block device is needed.\n"); break; case no_partition: - message = "Given name does not refer to a partition,\n" - "or maybe not even to a block device.\n"; + message =_("Given name does not refer to a partition,\n" + "or maybe not even to a block device.\n"); break; case unable_to_open: - sprintf(error, "Unable to open %s\n", disk_device); + sprintf(error, _("Unable to open %s\n"), disk_device); break; case unable_to_read: - sprintf(error, "Unable to read %s\n", disk_device); + sprintf(error, _("Unable to read %s\n"), disk_device); break; case unable_to_seek: - sprintf(error, "Unable to seek on %s\n", disk_device); + sprintf(error, _("Unable to seek on %s\n"),disk_device); break; case unable_to_write: - sprintf(error, "Unable to write %s\n", disk_device); + sprintf(error, _("Unable to write %s\n"), disk_device); + break; + case ioctl_error: + sprintf(error, _("BLKGETSIZE ioctl failed on %s\n"), + disk_device); break; case out_of_memory: - message = "Unable to allocate any more memory\n"; + message = _("Unable to allocate any more memory\n"); break; - default: message = "Fatal error\n"; + default: message = _("Fatal error\n"); } fputc('\n', stderr); @@ -317,104 +300,107 @@ void fatal(enum failure why) void menu(void) { - if (sun_label) - puts("Command action\n" - " a toggle a read only flag\n" /* sun */ - " b edit bsd disklabel\n" - " c toggle the mountable flag\n" /* sun */ - " d delete a partition\n" - " l list known partition types\n" - " m print this menu\n" - " n add a new partition\n" - " o create a new empty DOS partition table\n" - " p print the partition table\n" - " q quit without saving changes\n" - " s create a new empty Sun disklabel\n" /* sun */ - " t change a partition's system id\n" - " u change display/entry units\n" - " v verify the partition table\n" - " w write table to disk and exit\n" - " x extra functionality (experts only)" - ); - else if(sgi_label) - puts("Command action\n" - " a select bootable partition\n" /* sgi flavour */ - " b edit bootfile entry\n" /* sgi */ - " c select sgi swap partition\n" /* sgi flavour */ - " d delete a partition\n" - " l list known partition types\n" - " m print this menu\n" - " n add a new partition\n" - " o create a new empty DOS partition table\n" - " p print the partition table\n" - " q quit without saving changes\n" - " t change a partition's system id\n" - " u change display/entry units\n" - " v verify the partition table\n" - " w write table to disk and exit\n" - ); - else if(aix_label) - puts("Command action\n" - " m print this menu\n" - " o create a new empty DOS partition table\n" - " q quit without saving changes\n" - ); - else - puts("Command action\n" - " a toggle a bootable flag\n" - " b edit bsd disklabel\n" - " c toggle the dos compatibility flag\n" - " d delete a partition\n" - " l list known partition types\n" - " m print this menu\n" - " n add a new partition\n" - " o create a new empty DOS partition table\n" - " p print the partition table\n" - " q quit without saving changes\n" - " t change a partition's system id\n" - " u change display/entry units\n" - " v verify the partition table\n" - " w write table to disk and exit\n" - " x extra functionality (experts only)" - ); + if (sun_label) { + puts(_("Command action")); + puts(_(" a toggle a read only flag")); /* sun */ + puts(_(" b edit bsd disklabel")); + puts(_(" c toggle the mountable flag")); /* sun */ + puts(_(" d delete a partition")); + puts(_(" l list known partition types")); + puts(_(" m print this menu")); + puts(_(" n add a new partition")); + puts(_(" o create a new empty DOS partition table")); + puts(_(" p print the partition table")); + puts(_(" q quit without saving changes")); + puts(_(" s create a new empty Sun disklabel")); /* sun */ + puts(_(" t change a partition's system id")); + puts(_(" u change display/entry units")); + puts(_(" v verify the partition table")); + puts(_(" w write table to disk and exit")); + puts(_(" x extra functionality (experts only)")); + } + else if(sgi_label) { + puts(_("Command action")); + puts(_(" a select bootable partition")); /* sgi flavour */ + puts(_(" b edit bootfile entry")); /* sgi */ + puts(_(" c select sgi swap partition")); /* sgi flavour */ + puts(_(" d delete a partition")); + puts(_(" l list known partition types")); + puts(_(" m print this menu")); + puts(_(" n add a new partition")); + puts(_(" o create a new empty DOS partition table")); + puts(_(" p print the partition table")); + puts(_(" q quit without saving changes")); + puts(_(" s create a new empty Sun disklabel")); /* sun */ + puts(_(" t change a partition's system id")); + puts(_(" u change display/entry units")); + puts(_(" v verify the partition table")); + puts(_(" w write table to disk and exit")); + } + else if(aix_label) { + puts(_("Command action")); + puts(_(" m print this menu")); + puts(_(" o create a new empty DOS partition table")); + puts(_(" q quit without saving changes")); + puts(_(" s create a new empty Sun disklabel")); /* sun */ + } + else { + puts(_("Command action")); + puts(_(" a toggle a bootable flag")); + puts(_(" b edit bsd disklabel")); + puts(_(" c toggle the dos compatibility flag")); + puts(_(" d delete a partition")); + puts(_(" l list known partition types")); + puts(_(" m print this menu")); + puts(_(" n add a new partition")); + puts(_(" o create a new empty DOS partition table")); + puts(_(" p print the partition table")); + puts(_(" q quit without saving changes")); + puts(_(" s create a new empty Sun disklabel")); /* sun */ + puts(_(" t change a partition's system id")); + puts(_(" u change display/entry units")); + puts(_(" v verify the partition table")); + puts(_(" w write table to disk and exit")); + puts(_(" x extra functionality (experts only)")); + } } void xmenu(void) { - if (sun_label) - puts("Command action\n" - " a change number of alternate cylinders\n" /* sun */ - " c change number of cylinders\n" - " d print the raw data in the partition table\n" - " e change number of extra sectors per cylinder\n" /*sun*/ - " h change number of heads\n" - " i change interleave factor\n" /* sun */ - " o change rotation speed (rpm)\n" /* sun */ - " m print this menu\n" - " p print the partition table\n" - " q quit without saving changes\n" - " r return to main menu\n" - " s change number of sectors\n" - " v verify the partition table\n" - " w write table to disk and exit\n" - " y change number of physical cylinders" /* sun */ - ); - else - puts("Command action\n" - " b move beginning of data in a partition\n" /* !sun */ - " c change number of cylinders\n" - " d print the raw data in the partition table\n" - " e list extended partitions\n" /* !sun */ - " g create an IRIX partition table\n" /* sgi */ - " h change number of heads\n" - " m print this menu\n" - " p print the partition table\n" - " q quit without saving changes\n" - " r return to main menu\n" - " s change number of sectors\n" - " v verify the partition table\n" - " w write table to disk and exit" - ); + if (sun_label) { + puts(_("Command action")); + puts(_(" a change number of alternate cylinders")); /*sun*/ + puts(_(" c change number of cylinders")); + puts(_(" d print the raw data in the partition table")); + puts(_(" e change number of extra sectors per cylinder"));/*sun*/ + puts(_(" h change number of heads")); + puts(_(" i change interleave factor")); /*sun*/ + puts(_(" o change rotation speed (rpm)")); /*sun*/ + puts(_(" m print this menu")); + puts(_(" p print the partition table")); + puts(_(" q quit without saving changes")); + puts(_(" r return to main menu")); + puts(_(" s change number of sectors/track")); + puts(_(" v verify the partition table")); + puts(_(" w write table to disk and exit")); + puts(_(" y change number of physical cylinders")); /*sun*/ + } + else { + puts(_("Command action")); + puts(_(" b move beginning of data in a partition")); /* !sun */ + puts(_(" c change number of cylinders")); + puts(_(" d print the raw data in the partition table")); + puts(_(" e list extended partitions")); /* !sun */ + puts(_(" g create an IRIX partition table")); /* sgi */ + puts(_(" h change number of heads")); + puts(_(" m print this menu")); + puts(_(" p print the partition table")); + puts(_(" q quit without saving changes")); + puts(_(" r return to main menu")); + puts(_(" s change number of sectors/track")); + puts(_(" v verify the partition table")); + puts(_(" w write table to disk and exit")); + } } int @@ -428,7 +414,7 @@ struct systypes * get_sys_types(void) { return ( sun_label ? sun_sys_types : - sgi_label ? sgi_sys_types : sys_types); + sgi_label ? sgi_sys_types : i386_sys_types); } char *partition_type(unsigned char type) @@ -437,8 +423,8 @@ char *partition_type(unsigned char type) struct systypes *types = get_sys_types(); for (i=0; types[i].name; i++) - if (types[i].index == type) - return types[i].name; + if (types[i].type == type) + return _(types[i].name); return NULL; } @@ -457,7 +443,7 @@ void list_types(struct systypes *sys) do { printf("%c%2x %-15.15s", i ? ' ' : '\n', - sys[next].index, sys[next].name); + sys[next].type, _(sys[next].name)); next = last[i++] + done; if (i > 3 || next >= last[i]) { i = 0; @@ -501,7 +487,7 @@ int test_c(char **m, char *mesg) { int val = 0; if (!*m) - fprintf(stderr, "You must set"); + fprintf(stderr, _("You must set")); else { fprintf(stderr, " %s", *m); val = 1; @@ -515,16 +501,16 @@ int warn_geometry(void) char *m = NULL; int prev = 0; if (!heads) - prev = test_c(&m, "heads"); + prev = test_c(&m, _("heads")); if (!sectors) - prev = test_c(&m, "sectors"); + prev = test_c(&m, _("sectors")); if (!cylinders) - prev = test_c(&m, "cylinders"); + prev = test_c(&m, _("cylinders")); if (!m) return 0; fprintf(stderr, - "%s%s.\nYou can do this from the extra functions menu.\n", - prev ? " and " : " ", m); + _("%s%s.\nYou can do this from the extra functions menu.\n"), + prev ? _(" and ") : " ", m); return 1; } @@ -532,10 +518,10 @@ void update_units(void) { int cyl_units = heads * sectors; - if (unit_flag && cyl_units) - display_factor = cyl_units; + if (display_in_cyl_units && cyl_units) + units_per_sector = cyl_units; else - display_factor = 1; /* in sectors */ + units_per_sector = 1; /* in sectors */ } void warn_cylinders(void) @@ -558,11 +544,14 @@ void read_extended(struct partition *p) ext_pointers[ext_index] = part_table[ext_index]; if (!get_start_sect(p)) - fprintf(stderr, "Bad offset in primary extended partition\n"); + fprintf(stderr, _("Bad offset in primary extended partition\n")); else while (IS_EXTENDED (p->sys_ind)) { if (partitions >= MAXIMUM_PARTS) { + /* This is not a Linux restriction, but + this program uses arrays of size MAXIMUM_PARTS. + Do not try to `improve' this test. */ fprintf(stderr, - "Warning: deleting partitions after %d\n", + _("Warning: deleting partitions after %d\n"), partitions); clear_partition(ext_pointers[partitions - 1]); changed[partitions - 1] = 1; @@ -583,16 +572,16 @@ void read_extended(struct partition *p) for (i = 0; i < 4; i++, p++) { if (IS_EXTENDED (p->sys_ind)) { if (ext_pointers[partitions]) - fprintf(stderr, "Warning: extra link " + fprintf(stderr, _("Warning: extra link " "pointer in partition table " - "%d\n", partitions + 1); + "%d\n"), partitions + 1); else ext_pointers[partitions] = p; } else if (p->sys_ind) { if (part_table[partitions]) fprintf(stderr, - "Warning: ignoring extra data " - "in partition table %d\n", + _("Warning: ignoring extra data " + "in partition table %d\n"), partitions + 1); else part_table[partitions] = p; @@ -617,9 +606,9 @@ void create_doslabel(void) int i; fprintf(stderr, - "Building a new DOS disklabel. Changes will remain in memory only,\n" - "until you decide to write them. After that, of course, the previous\n" - "content won't be recoverable.\n\n"); + _("Building a new DOS disklabel. Changes will remain in memory only,\n" + "until you decide to write them. After that, of course, the previous\n" + "content won't be recoverable.\n\n")); sun_nolabel(); /* otherwise always recognised as sun */ sgi_nolabel(); /* otherwise always recognised as sgi */ @@ -653,9 +642,20 @@ int get_boot(enum action what) if ((fd = open(disk_device, O_RDONLY)) < 0) fatal(unable_to_open); else - printf("You will not be able to write the partition table.\n"); + printf(_("You will not be able to write the partition table.\n")); } +#if defined(BLKSSZGET) && defined(HAVE_blkpg_h) + /* For a short while BLKSSZGET gave a wrong sector size */ + { int arg; + if (ioctl(fd, BLKSSZGET, &arg) == 0) + sector_size = arg; + if (sector_size != DEFAULT_SECTOR_SIZE) + printf(_("Note: sector size is %d (not %d)\n"), + sector_size, DEFAULT_SECTOR_SIZE); + } +#endif + guess_device_type(fd); if (sector_size != read(fd, buffer, sector_size)) @@ -673,10 +673,11 @@ int get_boot(enum action what) if (dos_compatible_flag) sector_offset = sectors; } else { - if (!ioctl(fd, BLKGETSIZE, §ors)) { + long longsectors; + if (!ioctl(fd, BLKGETSIZE, &longsectors)) { heads = 1; cylinders = 1; - sectors /= sec_fac; + sectors = longsectors / sec_fac; } else { heads = cylinders = sectors = 0; } @@ -698,8 +699,8 @@ got_table: switch(what) { case fdisk: fprintf(stderr, - "Device contains neither a valid DOS partition" - " table, nor Sun or SGI disklabel\n"); + _("Device contains neither a valid DOS partition" + " table, nor Sun or SGI disklabel\n")); #ifdef __sparc__ create_sunlabel(); #else @@ -714,7 +715,7 @@ got_table: break; } - fprintf(stderr, "Internal error\n"); + fprintf(stderr, _("Internal error\n")); exit(1); } @@ -724,15 +725,15 @@ got_table: for (i = 0; i < 4; i++) if(IS_EXTENDED (part_table[i]->sys_ind)) { if (partitions != 4) - fprintf(stderr, "Ignoring extra extended " - "partition %d\n", i + 1); + fprintf(stderr, _("Ignoring extra extended " + "partition %d\n"), i + 1); else read_extended(part_table[ext_index = i]); } for (i = 3; i < partitions; i++) if (!valid_part_table_flag(buffers[i])) { fprintf(stderr, - "Warning: invalid flag 0x%04x of partition " - "table %d will be corrected by w(rite)\n", + _("Warning: invalid flag 0x%04x of partition " + "table %d will be corrected by w(rite)\n"), part_table_flag(buffers[i]), i + 1); changed[i] = 1; } @@ -744,9 +745,19 @@ got_table: int read_line(void) { + static int got_eof = 0; + line_ptr = line_buffer; - if (!fgets(line_buffer, LINE_LENGTH, stdin)) + if (!fgets(line_buffer, LINE_LENGTH, stdin)) { + if (feof(stdin)) + got_eof++; /* user typed ^D ? */ + if (got_eof >= 3) { + fflush(stdout); + fprintf(stderr, _("\ngot EOF thrice - exiting..\n")); + exit(1); + } return 0; + } while (*line_ptr && !isgraph(*line_ptr)) line_ptr++; return *line_ptr; @@ -779,7 +790,7 @@ read_hex(struct systypes *sys) while (1) { - read_char("Hex code (type L to list codes): "); + read_char(_("Hex code (type L to list codes): ")); if (tolower(*line_ptr) == 'l') list_types(sys); else if (isxdigit (*line_ptr)) @@ -818,7 +829,7 @@ read_int(uint low, uint dflt, uint high, uint base, char *mesg) default_ok = 0; if (default_ok) - sprintf(ms, "%s (%d-%d, default %d): ", mesg, low, high, dflt); + sprintf(ms, _("%s (%d-%d, default %d): "), mesg, low, high, dflt); else sprintf(ms, "%s (%d-%d): ", mesg, low, high); @@ -839,26 +850,26 @@ read_int(uint low, uint dflt, uint high, uint base, char *mesg) switch (*line_ptr) { case 'c': case 'C': - if (!unit_flag) + if (!display_in_cyl_units) i *= heads * sectors; break; case 'k': case 'K': i *= 2; i /= (sector_size / 512); - i /= display_factor; + i /= units_per_sector; break; case 'm': case 'M': i *= 2048; i /= (sector_size / 512); - i /= display_factor; + i /= units_per_sector; break; case 'g': case 'G': i *= 2048000; i /= (sector_size / 512); - i /= display_factor; + i /= units_per_sector; break; default: break; @@ -872,18 +883,18 @@ read_int(uint low, uint dflt, uint high, uint base, char *mesg) } } if (use_default) - printf("Using default value %d\n", i = dflt); + printf(_("Using default value %d\n"), i = dflt); if (i >= low && i <= high) break; else - printf("Value out of range.\n"); + printf(_("Value out of range.\n")); } return i; } int get_partition(int warn, int max) { - int i = read_int(1, 0, max, 0, "Partition number") - 1; + int i = read_int(1, 0, max, 0, _("Partition number")) - 1; if (warn && ( (!sun_label && !sgi_label && !part_table[i]->sys_ind) @@ -891,23 +902,24 @@ int get_partition(int warn, int max) (!sunlabel->partitions[i].num_sectors || !sunlabel->infos[i].id)) || (sgi_label && (!sgi_get_num_sectors(i))) - )) fprintf(stderr, "Warning: partition %d has empty type\n", i+1); + )) fprintf(stderr, _("Warning: partition %d has empty type\n"), i+1); return i; } -char *const str_units(void) +char *const str_units(int n) /* n==1: use singular */ { - return unit_flag ? "cylinder" : "sector"; + if (n == 1) + return display_in_cyl_units ? _("cylinder") : _("sector"); + else + return display_in_cyl_units ? _("cylinders") : _("sectors"); } void change_units(void) { - if ((unit_flag = !unit_flag)) - display_factor = 1; - else display_factor = heads * sectors; + display_in_cyl_units = !display_in_cyl_units; update_units(); - printf("Changing display/entry units to %ss\n", - str_units()); + printf(_("Changing display/entry units to %s\n"), + str_units(PLURAL)); } void toggle_active(int i) @@ -916,7 +928,7 @@ void toggle_active(int i) if (IS_EXTENDED (p->sys_ind) && !p->boot_ind) fprintf(stderr, - "WARNING: Partition %d is an extended partition\n", + _("WARNING: Partition %d is an extended partition\n"), i + 1); if (p->boot_ind) p->boot_ind = 0; @@ -927,14 +939,14 @@ void toggle_active(int i) void toggle_dos(void) { dos_compatible_flag = ~dos_compatible_flag; - printf("DOS Compatibility flag is "); - if (dos_compatible_flag) + if (dos_compatible_flag) { sector_offset = sectors; + printf(_("DOS Compatibility flag is set\n")); + } else { sector_offset = 1; - printf("not "); + printf(_("DOS Compatibility flag is not set\n")); } - printf("set\n"); } void delete_partition(int i) @@ -969,6 +981,7 @@ void delete_partition(int i) else if (!q->sys_ind && i > 4) { free(buffers[--partitions]); clear_partition(ext_pointers[--i]); + changed[i] = 1; } else if (i > 3) { if (i > 4) { @@ -1018,39 +1031,39 @@ void change_sysid(void) origsys = sys = get_sysid(i); if (!sys && !sgi_label) - printf("Partition %d does not exist yet!\n", i + 1); + printf(_("Partition %d does not exist yet!\n"), i + 1); else while (1) { sys = read_hex (get_sys_types()); if (!sys && !sgi_label) { - printf("Type 0 means free space to many systems\n" + printf(_("Type 0 means free space to many systems\n" "(but not to Linux). Having partitions of\n" "type 0 is probably unwise. You can delete\n" - "a partition using the `d' command.\n"); + "a partition using the `d' command.\n")); /* break; */ } if (!sun_label && !sgi_label) { if (IS_EXTENDED (sys) != IS_EXTENDED (p->sys_ind)) { - printf("You cannot change a partition into" + printf(_("You cannot change a partition into" " an extended one or vice versa\n" - "Delete it first.\n"); + "Delete it first.\n")); break; } } if (sys < 256) { if (sun_label && i == 2 && sys != WHOLE_DISK) - printf("Consider leaving partition 3 " + printf(_("Consider leaving partition 3 " "as Whole disk (5),\n" "as SunOS/Solaris expects it and " - "even Linux likes it.\n\n"); + "even Linux likes it.\n\n")); if (sgi_label && ((i == 10 && sys != ENTIRE_DISK) || (i == 8 && sys != 0))) - printf("Consider leaving partition 9 " + printf(_("Consider leaving partition 9 " "as volume header (0),\nand " "partition 11 as entire volume (6)" - "as IRIX expects it.\n\n"); + "as IRIX expects it.\n\n")); if (sys == origsys) break; @@ -1061,10 +1074,10 @@ void change_sysid(void) sgi_change_sysid(i, sys); } else part_table[i]->sys_ind = sys; - printf ("Changed system type of partition %d " - "to %x (%s)\n", i + 1, sys, + printf (_("Changed system type of partition %d " + "to %x (%s)\n"), i + 1, sys, (temp = partition_type(sys)) ? temp : - "Unknown"); + _("Unknown")); changed[i] = 1; break; } @@ -1114,45 +1127,45 @@ static void check_consistency(struct partition *p, int partition) /* Same physical / logical beginning? */ if (cylinders <= 1024 && (pbc != lbc || pbh != lbh || pbs != lbs)) { - printf("Partition %d has different physical/logical " - "beginnings (non-Linux?):\n", partition + 1); - printf(" phys=(%d, %d, %d) ", pbc, pbh, pbs); - printf("logical=(%d, %d, %d)\n",lbc, lbh, lbs); + printf(_("Partition %d has different physical/logical " + "beginnings (non-Linux?):\n"), partition + 1); + printf(_(" phys=(%d, %d, %d) "), pbc, pbh, pbs); + printf(_("logical=(%d, %d, %d)\n"),lbc, lbh, lbs); } /* Same physical / logical ending? */ if (cylinders <= 1024 && (pec != lec || peh != leh || pes != les)) { - printf("Partition %d has different physical/logical " - "endings:\n", partition + 1); - printf(" phys=(%d, %d, %d) ", pec, peh, pes); - printf("logical=(%d, %d, %d)\n",lec, leh, les); + printf(_("Partition %d has different physical/logical " + "endings:\n"), partition + 1); + printf(_(" phys=(%d, %d, %d) "), pec, peh, pes); + printf(_("logical=(%d, %d, %d)\n"),lec, leh, les); } #if 0 /* Beginning on cylinder boundary? */ if (pbh != !pbc || pbs != 1) { - printf("Partition %i does not start on cylinder " - "boundary:\n", partition + 1); - printf(" phys=(%d, %d, %d) ", pbc, pbh, pbs); - printf("should be (%d, %d, 1)\n", pbc, !pbc); + printf(_("Partition %i does not start on cylinder " + "boundary:\n"), partition + 1); + printf(_(" phys=(%d, %d, %d) "), pbc, pbh, pbs); + printf(_("should be (%d, %d, 1)\n"), pbc, !pbc); } #endif /* Ending on cylinder boundary? */ if (peh != (heads - 1) || pes != sectors) { - printf("Partition %i does not end on cylinder boundary:\n", + printf(_("Partition %i does not end on cylinder boundary:\n"), partition + 1); - printf(" phys=(%d, %d, %d) ", pec, peh, pes); - printf("should be (%d, %d, %d)\n", + printf(_(" phys=(%d, %d, %d) "), pec, peh, pes); + printf(_("should be (%d, %d, %d)\n"), pec, heads - 1, sectors); } } void list_disk_geometry(void) { - printf("\nDisk %s: %d heads, %d sectors, %d cylinders\nUnits = " - "%ss of %d * %d bytes\n\n", disk_device, heads, sectors, - cylinders, str_units(), display_factor, sector_size); + printf(_("\nDisk %s: %d heads, %d sectors, %d cylinders\nUnits = " + "%s of %d * %d bytes\n\n"), disk_device, heads, sectors, + cylinders, str_units(PLURAL), units_per_sector, sector_size); } void list_table(int xtra) @@ -1183,8 +1196,12 @@ void list_table(int xtra) if (w < 5) w = 5; - printf("%*s Boot Start End Blocks Id System\n", - (digit_last ? w + 2 : w + 1), "Device"); + + /* FIXME! let's see how this shows up with other languagues + acme@conectiva.com.br */ + + printf(_("%*s Boot Start End Blocks Id System\n"), + (digit_last ? w + 2 : w + 1), _("Device")); for (i = 0 ; i < partitions; i++) { if ((p = part_table[i])->sys_ind) { @@ -1209,7 +1226,7 @@ void list_table(int xtra) /* odd flag on end */ (long) pblocks, podd ? '+' : ' ', /* type id */ p->sys_ind, /* type name */ (type = partition_type(p->sys_ind)) ? - type : "Unknown"); + type : _("Unknown")); check_consistency(p, i); } } @@ -1224,9 +1241,9 @@ void x_list_table(int extend) q = ext_pointers; else q = part_table; - printf("\nDisk %s: %d heads, %d sectors, %d cylinders\n\n", + printf(_("\nDisk %s: %d heads, %d sectors, %d cylinders\n\n"), disk_device, heads, sectors, cylinders); - printf("Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID\n"); + printf(_("Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID\n")); for (i = 0 ; i < partitions; i++) if ((p = q[i]) != NULL) { printf("%2d %02x%4d%4d%5d%4d%4d%5d%8d%8d %02x\n", @@ -1265,21 +1282,21 @@ void check(int n, uint h, uint s, uint c, uint start) real_c = cylinder(s, c); total = (real_c * sectors + real_s) * heads + h; if (!total) - fprintf(stderr, "Warning: partition %d contains sector 0\n", n); + fprintf(stderr, _("Warning: partition %d contains sector 0\n"), n); if (h >= heads) fprintf(stderr, - "Partition %d: head %d greater than maximum %d\n", + _("Partition %d: head %d greater than maximum %d\n"), n, h + 1, heads); if (real_s >= sectors) - fprintf(stderr, "Partition %d: sector %d greater than " - "maximum %d\n", n, s, sectors); + fprintf(stderr, _("Partition %d: sector %d greater than " + "maximum %d\n"), n, s, sectors); if (real_c >= cylinders) - fprintf(stderr, "Partitions %d: cylinder %d greater than " - "maximum %d\n", n, real_c + 1, cylinders); + fprintf(stderr, _("Partitions %d: cylinder %d greater than " + "maximum %d\n"), n, real_c + 1, cylinders); if (cylinders <= 1024 && start != total) fprintf(stderr, - "Partition %d: previous sectors %d disagrees with " - "total %d\n", n, start, total); + _("Partition %d: previous sectors %d disagrees with " + "total %d\n"), n, start, total); } @@ -1308,16 +1325,16 @@ void verify(void) if (p->sys_ind && !IS_EXTENDED (p->sys_ind)) { check_consistency(p, i); if (get_start_sect(p) + offsets[i] < first[i]) - printf("Warning: bad start-of-data in " - "partition %d\n", i + 1); + printf(_("Warning: bad start-of-data in " + "partition %d\n"), i + 1); check(i + 1, p->end_head, p->end_sector, p->end_cyl, last[i]); total += last[i] + 1 - first[i]; for (j = 0; j < i; j++) if ((first[i] >= first[j] && first[i] <= last[j]) || ((last[i] <= last[j] && last[i] >= first[j]))) { - printf("Warning: partition %d overlaps " - "partition %d.\n", j + 1, i + 1); + printf(_("Warning: partition %d overlaps " + "partition %d.\n"), j + 1, i + 1); total += first[i] >= first[j] ? first[i] : first[j]; total -= last[i] <= last[j] ? @@ -1334,21 +1351,21 @@ void verify(void) total++; if (!p->sys_ind) { if (i != 4 || i + 1 < partitions) - printf("Warning: partition %d " - "is empty\n", i + 1); + printf(_("Warning: partition %d " + "is empty\n"), i + 1); } else if (first[i] < extended_offset || last[i] > e_last) - printf("Logical partition %d not entirely in " - "partition %d\n", i + 1, ext_index + 1); + printf(_("Logical partition %d not entirely in " + "partition %d\n"), i + 1, ext_index + 1); } } if (total > heads * sectors * cylinders) - printf("Total allocated sectors %d greater than the maximum " - "%d\n", total, heads * sectors * cylinders); + printf(_("Total allocated sectors %d greater than the maximum " + "%d\n"), total, heads * sectors * cylinders); else if ((total = heads * sectors * cylinders - total) != 0) - printf("%d unallocated sectors\n", total); + printf(_("%d unallocated sectors\n"), total); } void add_partition(int n, int sys) @@ -1360,8 +1377,8 @@ void add_partition(int n, int sys) first[partitions], last[partitions]; if (p->sys_ind) { - printf("Partition %d is already defined. Delete " - "it before re-adding it.\n", n + 1); + printf(_("Partition %d is already defined. Delete " + "it before re-adding it.\n"), n + 1); return; } fill_bounds(first, last); @@ -1377,11 +1394,11 @@ void add_partition(int n, int sys) start = extended_offset + sector_offset; limit = get_start_sect(q) + get_nr_sects(q) - 1; } - if (unit_flag) + if (display_in_cyl_units) for (i = 0; i < partitions; i++) - first[i] = (cround(first[i]) - 1) * display_factor; + first[i] = (cround(first[i]) - 1) * units_per_sector; - sprintf(mesg, "First %s", str_units()); + sprintf(mesg, _("First %s"), str_units(SINGULAR)); do { temp = start; for (i = 0; i < partitions; i++) { @@ -1395,8 +1412,8 @@ void add_partition(int n, int sys) } if (start > limit) break; - if (start >= temp+display_factor && read) { - printf("Sector %d is already allocated\n", temp); + if (start >= temp+units_per_sector && read) { + printf(_("Sector %d is already allocated\n"), temp); temp = start; read = 0; } @@ -1405,15 +1422,21 @@ void add_partition(int n, int sys) i = start; start = read_int(cround(i), cround(i), cround(limit), 0, mesg); - if (unit_flag) { - start = (start - 1) * display_factor; + if (display_in_cyl_units) { + start = (start - 1) * units_per_sector; if (start < i) start = i; } read = 1; } } while (start != temp || !read); - if (n > 4) /* NOT for fifth partition */ + if (n > 4) { /* NOT for fifth partition */ offsets[n] = start - sector_offset; + if (offsets[n] == extended_offset) { /* must be corrected */ + offsets[n]++; + if (sector_offset == 1) + start++; + } + } for (i = 0; i < partitions; i++) { if (start < offsets[i] && limit >= offsets[i]) @@ -1422,22 +1445,22 @@ void add_partition(int n, int sys) limit = first[i] - 1; } if (start > limit) { - printf("No free sectors available\n"); + printf(_("No free sectors available\n")); if (n > 4) { free(buffers[n]); partitions--; } return; } - if (cround(start) == cround(limit)) - stop = start; - else { - sprintf(mesg, "Last %s or +size or +sizeM or +sizeK", - str_units()); + if (cround(start) == cround(limit)) { + stop = limit; + } else { + sprintf(mesg, _("Last %s or +size or +sizeM or +sizeK"), + str_units(SINGULAR)); stop = read_int(cround(start), cround(limit), cround(limit), cround(start), mesg); - if (unit_flag) { - stop = stop * display_factor - 1; + if (display_in_cyl_units) { + stop = stop * units_per_sector - 1; if (stop >limit) stop = limit; } @@ -1455,16 +1478,15 @@ void add_partition(int n, int sys) ext_pointers[4] = part_table[4] + 1; changed[4] = 1; partitions = 5; - } - else { + } else { if (n > 4) set_partition(n - 1, ext_pointers[n - 1], - start - sector_offset, stop, EXTENDED, + offsets[n], stop, EXTENDED, extended_offset); #if 0 if ((limit = get_nr_sects(p)) & 1) - printf("Warning: partition %d has an odd " - "number of sectors.\n", n + 1); + printf(_("Warning: partition %d has an odd " + "number of sectors.\n"), n + 1); #endif } } @@ -1500,7 +1522,7 @@ void new_partition(void) } if (partitions >= MAXIMUM_PARTS) { - printf("The maximum number of partitions has been created\n"); + printf(_("The maximum number of partitions has been created\n")); return; } @@ -1510,13 +1532,13 @@ void new_partition(void) if (extended_offset) add_logical(); else - printf("You must delete some partition and add " - "an extended partition first\n"); + printf(_("You must delete some partition and add " + "an extended partition first\n")); } else { char c, line[LINE_LENGTH]; - sprintf(line, "Command action\n %s\n p primary " - "partition (1-4)\n", extended_offset ? - "l logical (5 or over)" : "e extended"); + sprintf(line, _("Command action\n %s\n p primary " + "partition (1-4)\n"), extended_offset ? + _("l logical (5 or over)") : _("e extended")); while (1) if ((c = tolower(read_char(line))) == 'p') { add_partition(get_partition(0, 4), @@ -1533,8 +1555,8 @@ void new_partition(void) return; } else - printf("Invalid partition number " - "for type `%c'\n", c); + printf(_("Invalid partition number " + "for type `%c'\n"), c); } } @@ -1565,9 +1587,9 @@ void write_table(void) } } - printf("The partition table has been altered!\n\n"); + printf(_("The partition table has been altered!\n\n")); - printf("Calling ioctl() to re-read partition table.\n"); + printf(_("Calling ioctl() to re-read partition table.\n")); sync(); sleep(2); if ((i = ioctl(fd, BLKRRPART)) != 0) { @@ -1584,20 +1606,20 @@ void write_table(void) close(fd); - printf("Syncing disks.\n"); + printf(_("Syncing disks.\n")); sync(); sleep(4); /* for sync() */ if (i < 0) - printf("Re-read table failed with error %d: %s.\nReboot your " - "system to ensure the partition table is updated.\n", + printf(_("Re-read table failed with error %d: %s.\nReboot your " + "system to ensure the partition table is updated.\n"), error, strerror(error)); if (!sun_label && !sgi_label) printf( - "\nWARNING: If you have created or modified any DOS 6.x\n" + _("\nWARNING: If you have created or modified any DOS 6.x\n" "partitions, please see the fdisk manual page for additional\n" - "information.\n"); + "information.\n")); exit(0); } @@ -1626,7 +1648,7 @@ void print_raw(void) { int i; - printf("Device: %s\n", disk_device); + printf(_("Device: %s\n"), disk_device); if (sun_label || sgi_label) print_buffer(buffer); else for (i = 3; i < partitions; i++) @@ -1641,13 +1663,13 @@ void move_begin(int i) if (warn_geometry()) return; if (!p->sys_ind || !get_nr_sects(p) || IS_EXTENDED (p->sys_ind)) { - printf("Partition %d has no data area\n", i + 1); + printf(_("Partition %d has no data area\n"), i + 1); return; } first = get_start_sect(p) + offsets[i]; new = read_int(first, first, get_start_sect(p) + get_nr_sects(p) + offsets[i] - 1, - first, "New beginning of data") - offsets[i]; + first, _("New beginning of data")) - offsets[i]; if (new != get_nr_sects(p)) { first = get_nr_sects(p) + get_start_sect(p) - new; @@ -1661,7 +1683,7 @@ void xselect(void) { while(1) { putchar('\n'); - switch (tolower(read_char("Expert command (m for help): "))) { + switch (tolower(read_char(_("Expert command (m for help): ")))) { case 'a': if (sun_label) sun_set_alt_cyl(); @@ -1672,7 +1694,7 @@ void xselect(void) break; case 'c': cylinders = read_int(1, cylinders, 65535, - 0, "Number of cylinders"); + 0, _("Number of cylinders")); if (sun_label) sun_set_ncyl(cylinders); warn_cylinders(); @@ -1693,7 +1715,7 @@ void xselect(void) break; case 'h': heads = read_int(1, heads, 256, 0, - "Number of heads"); + _("Number of heads")); update_units(); break; case 'i': @@ -1712,17 +1734,18 @@ void xselect(void) break; case 'q': close(fd); + printf("\n"); exit(0); case 'r': return; case 's': sectors = read_int(1, sectors, 63, 0, - "Number of sectors"); + _("Number of sectors")); if (dos_compatible_flag) { sector_offset = sectors; - fprintf(stderr, "Warning: setting " + fprintf(stderr, _("Warning: setting " "sector offset for DOS " - "compatiblity\n"); + "compatiblity\n")); } update_units(); break; @@ -1782,8 +1805,8 @@ void try(char *device, int user_specified) list_disk_geometry(); if (btrydev(device) < 0) fprintf(stderr, - "Disk %s doesn't contain a valid " - "partition table\n", device); + _("Disk %s doesn't contain a valid " + "partition table\n"), device); close(fd); } else { close(fd); @@ -1796,39 +1819,52 @@ void try(char *device, int user_specified) and SCSI hard disks which may not be installed on the system. */ if(errno == EACCES) { - fprintf(stderr, "Cannot open %s\n", device); + fprintf(stderr, _("Cannot open %s\n"), device); return; } } } } +int +dir_exists(char *dirname) { + struct stat statbuf; + + return (stat(dirname, &statbuf) == 0 && S_ISDIR(statbuf.st_mode)); +} + void dummy(int *kk) {} int main(int argc, char **argv) { - int i, j, s, c; + int j, c; int optl = 0, opts = 0; - char *part; + int user_set_sector_size = 0; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); /* * Calls: * fdisk -v - * fdisk -l [-b sectorsize] [-u] [device] ... + * fdisk -l [-b sectorsize] [-u] device ... * fdisk -s [partition] ... - * fdisk [-b sectorsize] [-u] [device] + * fdisk [-b sectorsize] [-u] device */ while ((c = getopt(argc, argv, "b:lsuv")) != EOF) { switch (c) { case 'b': + /* ugly: this sector size is really per device, + so cannot be combined with multiple disks */ sector_size = atoi(optarg); if (sector_size != 512 && sector_size != 1024 && sector_size != 2048) fatal(usage); sector_offset = 2; + user_set_sector_size = 1; break; case 'l': optl = 1; @@ -1837,7 +1873,7 @@ main(int argc, char **argv) opts = 1; break; case 'u': - unit_flag = 0; + display_in_cyl_units = 0; break; case 'v': printf("fdisk v" UTIL_LINUX_VERSION "\n"); @@ -1847,6 +1883,14 @@ main(int argc, char **argv) } } +#if 0 + printf(_("This kernel finds the sector size itself - -b option ignored\n")); +#else + if (user_set_sector_size && argc-optind != 1) + printf(_("Warning: the -b (set sector size) option should" + " be used with one specified device\n")); +#endif + if (optl) { listing = 1; nowarn = 1; @@ -1859,39 +1903,16 @@ main(int argc, char **argv) for(k=optind; k<argc; k++) try(argv[k], 1); } else { - try("/dev/hda", 0); - try("/dev/hdb", 0); - try("/dev/hdc", 0); /* often a CDROM */ - try("/dev/hdd", 0); - try("/dev/sda", 0); - try("/dev/sdb", 0); - try("/dev/sdc", 0); - try("/dev/sdd", 0); - try("/dev/sde", 0); - try("/dev/sdf", 0); - try("/dev/sdg", 0); - try("/dev/sdh", 0); - try("/dev/eda", 0); /* PS/2 ESDI drives */ - try("/dev/edb", 0); - try("/dev/edc", 0); - try("/dev/edd", 0); - try("/dev/rd/c0d0", 0); /* DAC960 RAID disks */ - try("/dev/rd/c0d1", 0); - try("/dev/rd/c0d2", 0); - try("/dev/rd/c0d3", 0); - try("/dev/rd/c0d4", 0); - try("/dev/rd/c0d5", 0); - try("/dev/rd/c0d6", 0); - try("/dev/rd/c0d7", 0); + /* we no longer have default device names */ + fatal(usage2); } exit(0); } if (opts) { - /* Very silly assumptions here about device naming */ - /* All this junk will disappear again */ + long size; + nowarn = 1; - disk_device = (char *) malloc(16); type_open = O_RDONLY; opts = argc - optind; @@ -1899,46 +1920,16 @@ main(int argc, char **argv) fatal(usage); for (j = optind; j < argc; j++) { - part = argv[j]; - if (strncmp(part, "/dev/rd/", 8) == 0) { - char *p = strrchr(part, 'p'); - if (p == NULL) - fatal(usage); - if (!(i = atoi(p + 1))) - fatal(usage); - i--; /* count from 0 */ - *p = '\0'; - strcpy(disk_device, part); - } else { - if (strlen(part) < 9) - fatal(usage); - if (!(i = atoi(part + 8))) - fatal(usage); - i--; /* count from 0 */ - strncpy(disk_device, part, 8); - disk_device[8] = 0; - } + disk_device = argv[j]; if ((fd = open(disk_device, type_open)) < 0) fatal(unable_to_open); + if (ioctl(fd, BLKGETSIZE, &size)) + fatal(ioctl_error); close(fd); - if (get_boot(require) < 0) - exit(1); - if (i >= partitions) - exit(1); -#if defined(sparc) - if (!sun_label) { - int id = sunlabel->infos[i].id; - - if (!(id > 1 && id != WHOLE_DISK)) - exit(1); - s = get_num_sectors(sunlabel->partitions[i]); - } else -#endif - s = get_nr_sects(part_table[i]); if (opts == 1) - printf("%d\n", s/2); + printf("%ld\n", size/2); else - printf("%s: %d\n", argv[j], s/2); + printf("%s: %ld\n", argv[j], size/2); } exit(0); } @@ -1947,17 +1938,14 @@ main(int argc, char **argv) disk_device = argv[optind]; else if (argc-optind != 0) fatal(usage); - else { - if ((fd = open(DEFAULT_DEVICE, O_RDWR)) < 0) - disk_device = ALTERNATE_DEVICE; - else close(fd); - printf("Using %s as default device!\n", disk_device); - } + else + fatal(usage2); + get_boot(fdisk); while (1) { putchar('\n'); - switch (tolower(read_char("Command (m for help): "))) { + switch (tolower(read_char(_("Command (m for help): ")))) { case 'a': if (sun_label) toggle_sunflags(get_partition(1, partitions), @@ -1971,11 +1959,11 @@ main(int argc, char **argv) break; case 'b': if (sgi_label) { - printf("\nThe current boot file is: %s\n", + printf(_("\nThe current boot file is: %s\n"), sgi_get_bootfile()); - if (read_chars("Please enter the name of the " - "new boot file: ") == '\n') - printf("Boot file unchanged\n"); + if (read_chars(_("Please enter the name of the " + "new boot file: ")) == '\n') + printf(_("Boot file unchanged\n")); else sgi_set_bootfile(line_ptr); } else @@ -2015,6 +2003,7 @@ main(int argc, char **argv) break; case 'q': close(fd); + printf("\n"); exit(0); case 's': create_sunlabel(); @@ -2034,8 +2023,8 @@ main(int argc, char **argv) case 'x': if( sgi_label ) { fprintf(stderr, - "\n\tSorry, no experts menu for SGI " - "partition tables available.\n\n"); + _("\n\tSorry, no experts menu for SGI " + "partition tables available.\n\n")); } else xselect(); break; diff --git a/fdisk/fdisk.h b/fdisk/fdisk.h index 080515e5f..ace1b0cd9 100644 --- a/fdisk/fdisk.h +++ b/fdisk/fdisk.h @@ -21,7 +21,8 @@ #define SIZE(a) (sizeof(a)/sizeof((a)[0])) -#define cround(n) (((n) + display_factor * unit_flag) / display_factor) +#define cround(n) (display_in_cyl_units ? ((n)/units_per_sector)+1 : (n)) +#define scround(x) (((x)+units_per_sector-1)/units_per_sector) #if defined(__GNUC__) || defined(HAS_LONG_LONG) typedef long long ext2_loff_t; @@ -46,23 +47,19 @@ struct partition { unsigned char size4[4]; /* nr of sectors in partition */ }; -enum failure {usage, unable_to_open, unable_to_read, unable_to_seek, +enum failure {usage, usage2, ioctl_error, + unable_to_open, unable_to_read, unable_to_seek, unable_to_write, out_of_memory, no_partition, no_device}; enum action {fdisk, require, try_only, create_empty}; -struct systypes { - unsigned char index; - char *name; -}; - /* prototypes for fdisk.c */ extern char *disk_device, *line_ptr; extern int fd, partitions; -extern uint unit_flag, - display_factor; +extern uint display_in_cyl_units, + units_per_sector; extern struct partition *part_table[]; extern void fatal(enum failure why); extern int get_boot(enum action what); @@ -72,7 +69,10 @@ extern int read_line (void); extern char read_char(char *mesg); extern int read_hex(struct systypes *sys); uint read_int(uint low, uint dflt, uint high, uint base, char *mesg); -extern char *const str_units(void); + +#define PLURAL 0 +#define SINGULAR 1 +extern char *const str_units(int); extern unsigned int get_start_sect(struct partition *p); extern unsigned int get_nr_sects(struct partition *p); diff --git a/fdisk/fdiskaixlabel.c b/fdisk/fdiskaixlabel.c index 848a6ece8..7540f9a6d 100644 --- a/fdisk/fdiskaixlabel.c +++ b/fdisk/fdiskaixlabel.c @@ -1,3 +1,8 @@ +/* + Changes: + Sat Mar 20 09:51:38 EST 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br> + Internationalization +*/ #include <stdio.h> /* stderr */ #include <stdlib.h> /* uint */ #include <string.h> /* strstr */ @@ -5,8 +10,10 @@ #include <endian.h> +#include "common.h" #include "fdisk.h" #include "fdiskaixlabel.h" +#include "nls.h" static int other_endian = 0; static short volumes=1; @@ -18,8 +25,8 @@ static short volumes=1; void aix_info( void ) { - printf( - "\n\tThere is a valid AIX label on this disk.\n" + puts( + _("\n\tThere is a valid AIX label on this disk.\n" "\tUnfortunately Linux cannot handle these\n" "\tdisks at the moment. Nevertheless some\n" "\tadvice:\n" @@ -29,7 +36,7 @@ aix_info( void ) "\t erase the other disks as well, if unmirrored.)\n" "\t3. Before deleting this physical volume be sure\n" "\t to remove the disk logically from your AIX\n" - "\t machine. (Otherwise you become an AIXpert).\n" + "\t machine. (Otherwise you become an AIXpert).") ); } diff --git a/fdisk/fdiskbsdlabel.c b/fdisk/fdiskbsdlabel.c index 8edec2331..64a792734 100644 --- a/fdisk/fdiskbsdlabel.c +++ b/fdisk/fdiskbsdlabel.c @@ -33,6 +33,9 @@ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + Changes: + 19990319 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> - i18n/nls */ #include <unistd.h> @@ -43,12 +46,14 @@ #include <ctype.h> #include <setjmp.h> #include <errno.h> +#include "nls.h" #include <sys/ioctl.h> #include <sys/param.h> #include <linux/hdreg.h> /* for HDIO_GETGEO */ +#include "common.h" #include "fdisk.h" #define NETBSD_PARTITION 0xa5 #define DKTYPENAMES @@ -89,7 +94,7 @@ int btrydev (char * dev) { if (xbsd_readlabel (NULL, &xbsd_dlabel) == 0) return -1; - printf("\nBSD label for device: %s\n", dev); + printf(_("\nBSD label for device: %s\n"), dev); xbsd_print_disklabel (0); return 0; } @@ -97,25 +102,24 @@ btrydev (char * dev) { void bmenu (void) { - puts ("Command action\n" - " d delete a BSD partition\n" - " e edit drive data\n" - " i install bootstrap\n" - " l list known filesystem types\n" - " m print this menu\n" - " n add a new BSD partition\n" - " p print BSD partition table\n" - " q quit without saving changes\n" + puts (_("Command action")); + puts (_(" d delete a BSD partition")); + puts (_(" e edit drive data")); + puts (_(" i install bootstrap")); + puts (_(" l list known filesystem types")); + puts (_(" m print this menu")); + puts (_(" n add a new BSD partition")); + puts (_(" p print BSD partition table")); + puts (_(" q quit without saving changes")); #if defined (i386) || defined (sparc) - " r return to main menu\n" + puts (_(" r return to main menu")); #endif - " s show complete disklabel\n" - " t change a partition's filesystem id\n" - " w write disklabel to disk\n" + puts (_(" s show complete disklabel")); + puts (_(" t change a partition's filesystem id")); + puts (_(" w write disklabel to disk")); #if defined (i386) || defined (sparc) - " x link BSD partition to non-BSD partition" + puts (_(" x link BSD partition to non-BSD partition")); #endif - ); } int @@ -139,11 +143,11 @@ bselect (void) { xbsd_part_index = t; ss = get_start_sect(xbsd_part); if (ss == 0) { - fprintf (stderr, "Partition %s%d has invalid starting sector 0.\n", + fprintf (stderr, _("Partition %s%d has invalid starting sector 0.\n"), disk_device, t+1); return; } - printf ("Reading disklabel of %s%d at sector %d.\n", + printf (_("Reading disklabel of %s%d at sector %d.\n"), disk_device, t+1, ss + BSD_LABELSECTOR); if (xbsd_readlabel (xbsd_part, &xbsd_dlabel) == 0) if (xbsd_create_disklabel () == 0) @@ -152,7 +156,7 @@ bselect (void) { } if (t == 4) { - printf ("There is no *BSD partition on %s.\n", disk_device); + printf (_("There is no *BSD partition on %s.\n"), disk_device); return; } @@ -167,7 +171,7 @@ bselect (void) { while (1) { putchar ('\n'); - switch (tolower (read_char ("BSD disklabel command (m for help): "))) + switch (tolower (read_char (_("BSD disklabel command (m for help): ")))) { case 'd': xbsd_delete_part (); @@ -245,18 +249,18 @@ xbsd_new_part (void) end = xbsd_dlabel.d_secperunit; #endif - sprintf (mesg, "First %s", str_units()); + sprintf (mesg, _("First %s"), str_units(SINGULAR)); begin = read_int (cround (begin), cround (begin), cround (end), 0, mesg); - sprintf (mesg, "Last %s or +size or +sizeM or +sizeK", str_units()); + sprintf (mesg, _("Last %s or +size or +sizeM or +sizeK"), str_units(SINGULAR)); end = read_int (cround (begin), cround (end), cround (end), cround (begin), mesg); - if (unit_flag) + if (display_in_cyl_units) { - begin = (begin - 1) * display_factor; - end = end * display_factor - 1; + begin = (begin - 1) * units_per_sector; + end = end * units_per_sector - 1; } xbsd_dlabel.d_partitions[i].p_size = end - begin + 1; xbsd_dlabel.d_partitions[i].p_offset = begin; @@ -279,33 +283,33 @@ xbsd_print_disklabel (int show_all) fprintf(f, "# %s:\n", disk_device); #endif if ((unsigned) lp->d_type < BSD_DKMAXTYPES) - fprintf(f, "type: %s\n", xbsd_dktypenames[lp->d_type]); + fprintf(f, _("type: %s\n"), xbsd_dktypenames[lp->d_type]); else - fprintf(f, "type: %d\n", lp->d_type); - fprintf(f, "disk: %.*s\n", (int) sizeof(lp->d_typename), lp->d_typename); - fprintf(f, "label: %.*s\n", (int) sizeof(lp->d_packname), lp->d_packname); - fprintf(f, "flags:"); + fprintf(f, _("type: %d\n"), lp->d_type); + fprintf(f, _("disk: %.*s\n"), (int) sizeof(lp->d_typename), lp->d_typename); + fprintf(f, _("label: %.*s\n"), (int) sizeof(lp->d_packname), lp->d_packname); + fprintf(f, _("flags:")); if (lp->d_flags & BSD_D_REMOVABLE) - fprintf(f, " removable"); + fprintf(f, _(" removable")); if (lp->d_flags & BSD_D_ECC) - fprintf(f, " ecc"); + fprintf(f, _(" ecc")); if (lp->d_flags & BSD_D_BADSECT) - fprintf(f, " badsect"); + fprintf(f, _(" badsect")); fprintf(f, "\n"); /* On various machines the fields of *lp are short/int/long */ /* In order to avoid problems, we cast them all to long. */ - fprintf(f, "bytes/sector: %ld\n", (long) lp->d_secsize); - fprintf(f, "sectors/track: %ld\n", (long) lp->d_nsectors); - fprintf(f, "tracks/cylinder: %ld\n", (long) lp->d_ntracks); - fprintf(f, "sectors/cylinder: %ld\n", (long) lp->d_secpercyl); - fprintf(f, "cylinders: %ld\n", (long) lp->d_ncylinders); - fprintf(f, "rpm: %d\n", lp->d_rpm); - fprintf(f, "interleave: %d\n", lp->d_interleave); - fprintf(f, "trackskew: %d\n", lp->d_trackskew); - fprintf(f, "cylinderskew: %d\n", lp->d_cylskew); - fprintf(f, "headswitch: %ld\t\t# milliseconds\n", (long) lp->d_headswitch); - fprintf(f, "track-to-track seek: %ld\t# milliseconds\n", (long) lp->d_trkseek); - fprintf(f, "drivedata: "); + fprintf(f, _("bytes/sector: %ld\n"), (long) lp->d_secsize); + fprintf(f, _("sectors/track: %ld\n"), (long) lp->d_nsectors); + fprintf(f, _("tracks/cylinder: %ld\n"), (long) lp->d_ntracks); + fprintf(f, _("sectors/cylinder: %ld\n"), (long) lp->d_secpercyl); + fprintf(f, _("cylinders: %ld\n"), (long) lp->d_ncylinders); + fprintf(f, _("rpm: %d\n"), lp->d_rpm); + fprintf(f, _("interleave: %d\n"), lp->d_interleave); + fprintf(f, _("trackskew: %d\n"), lp->d_trackskew); + fprintf(f, _("cylinderskew: %d\n"), lp->d_cylskew); + fprintf(f, _("headswitch: %ld\t\t# milliseconds\n"), (long) lp->d_headswitch); + fprintf(f, _("track-to-track seek: %ld\t# milliseconds\n"), (long) lp->d_trkseek); + fprintf(f, _("drivedata: ")); for (i = NDDATA - 1; i >= 0; i--) if (lp->d_drivedata[i]) break; @@ -314,8 +318,8 @@ xbsd_print_disklabel (int show_all) for (j = 0; j <= i; j++) fprintf(f, "%ld ", (long) lp->d_drivedata[j]); } - fprintf (f, "\n%d partitions:\n", lp->d_npartitions); - fprintf (f, "# size offset fstype [fsize bsize cpg]\n"); + fprintf (f, _("\n%d partitions:\n"), lp->d_npartitions); + fprintf (f, _("# size offset fstype [fsize bsize cpg]\n")); pp = lp->d_partitions; for (i = 0; i < lp->d_npartitions; i++, pp++) { if (pp->p_size) { @@ -371,10 +375,10 @@ static void xbsd_write_disklabel (void) { #if defined (i386) || defined (sparc) - printf ("Writing disklabel to %s%d.\n", disk_device, xbsd_part_index+1); + printf (_("Writing disklabel to %s%d.\n"), disk_device, xbsd_part_index+1); xbsd_writelabel (xbsd_part, &xbsd_dlabel); #elif defined (__alpha__) - printf ("Writing disklabel to %s.\n", disk_device); + printf (_("Writing disklabel to %s.\n"), disk_device); xbsd_writelabel (NULL, &xbsd_dlabel); #endif } @@ -385,14 +389,14 @@ xbsd_create_disklabel (void) char c; #if defined (i386) || defined (sparc) - fprintf (stderr, "%s%d contains no disklabel.\n", + fprintf (stderr, _("%s%d contains no disklabel.\n"), disk_device, xbsd_part_index+1); #elif defined (__alpha__) - fprintf (stderr, "%s contains no disklabel.\n", disk_device); + fprintf (stderr, _("%s contains no disklabel.\n"), disk_device); #endif while (1) - if ((c = tolower (read_char ("Do you want to create a disklabel? (y/n) "))) == 'y') + if ((c = tolower (read_char (_("Do you want to create a disklabel? (y/n) ")))) == 'y') { #if defined (i386) || defined (sparc) if (xbsd_initlabel (xbsd_part, &xbsd_dlabel, xbsd_part_index) == 1) @@ -431,28 +435,28 @@ xbsd_edit_disklabel (void) d = &xbsd_dlabel; #ifdef __alpha__ - d -> d_secsize = (u_long) edit_int ((u_long) d -> d_secsize ,"bytes/sector"); - d -> d_nsectors = (u_long) edit_int ((u_long) d -> d_nsectors ,"sectors/track"); - d -> d_ntracks = (u_long) edit_int ((u_long) d -> d_ntracks ,"tracks/cylinder"); - d -> d_ncylinders = (u_long) edit_int ((u_long) d -> d_ncylinders ,"cylinders"); + d -> d_secsize = (u_long) edit_int ((u_long) d -> d_secsize ,_("bytes/sector")); + d -> d_nsectors = (u_long) edit_int ((u_long) d -> d_nsectors ,_("sectors/track")); + d -> d_ntracks = (u_long) edit_int ((u_long) d -> d_ntracks ,_("tracks/cylinder")); + d -> d_ncylinders = (u_long) edit_int ((u_long) d -> d_ncylinders ,_("cylinders")); #endif /* d -> d_secpercyl can be != d -> d_nsectors * d -> d_ntracks */ while (1) { d -> d_secpercyl = (u_long) edit_int ((u_long) d -> d_nsectors * d -> d_ntracks, - "sectors/cylinder"); + _("sectors/cylinder")); if (d -> d_secpercyl <= d -> d_nsectors * d -> d_ntracks) break; - printf ("Must be <= sectors/track * tracks/cylinder (default).\n"); + printf (_("Must be <= sectors/track * tracks/cylinder (default).\n")); } - d -> d_rpm = (u_short) edit_int ((u_short) d -> d_rpm ,"rpm"); - d -> d_interleave = (u_short) edit_int ((u_short) d -> d_interleave,"interleave"); - d -> d_trackskew = (u_short) edit_int ((u_short) d -> d_trackskew ,"trackskew"); - d -> d_cylskew = (u_short) edit_int ((u_short) d -> d_cylskew ,"cylinderskew"); - d -> d_headswitch = (u_long) edit_int ((u_long) d -> d_headswitch ,"headswitch"); - d -> d_trkseek = (u_long) edit_int ((u_long) d -> d_trkseek ,"track-to-track seek"); + d -> d_rpm = (u_short) edit_int ((u_short) d -> d_rpm ,_("rpm")); + d -> d_interleave = (u_short) edit_int ((u_short) d -> d_interleave,_("interleave")); + d -> d_trackskew = (u_short) edit_int ((u_short) d -> d_trackskew ,_("trackskew")); + d -> d_cylskew = (u_short) edit_int ((u_short) d -> d_cylskew ,_("cylinderskew")); + d -> d_headswitch = (u_long) edit_int ((u_long) d -> d_headswitch ,_("headswitch")); + d -> d_trkseek = (u_long) edit_int ((u_long) d -> d_trkseek ,_("track-to-track seek")); d -> d_secperunit = d -> d_secpercyl * d -> d_ncylinders; } @@ -493,7 +497,7 @@ xbsd_write_bootstrap (void) else dkbasename = "wd"; - printf ("Bootstrap: %sboot -> boot%s (%s): ", dkbasename, dkbasename, dkbasename); + printf (_("Bootstrap: %sboot -> boot%s (%s): "), dkbasename, dkbasename, dkbasename); if (read_line ()) { line_ptr[strlen (line_ptr)-1] = '\0'; @@ -519,7 +523,7 @@ xbsd_write_bootstrap (void) for (p=d; p < e; p++) if (*p) { - fprintf (stderr, "Bootstrap overlaps with disk label!\n"); + fprintf (stderr, _("Bootstrap overlaps with disk label!\n")); exit ( EXIT_FAILURE ); } @@ -540,9 +544,9 @@ xbsd_write_bootstrap (void) fatal (unable_to_write); #if defined (i386) || defined (sparc) - printf ("Bootstrap installed on %s%d.\n", disk_device, xbsd_part_index+1); + printf (_("Bootstrap installed on %s%d.\n"), disk_device, xbsd_part_index+1); #elif defined (__alpha__) - printf ("Bootstrap installed on %s.\n", disk_device); + printf (_("Bootstrap installed on %s.\n"), disk_device); #endif sync_disks (); @@ -563,7 +567,7 @@ xbsd_get_part_index (int max) char prompt[40]; char l; - sprintf (prompt, "Partition (a-%c): ", 'a' + max - 1); + sprintf (prompt, _("Partition (a-%c): "), 'a' + max - 1); do l = tolower (read_char (prompt)); while (l < 'a' || l > 'a' + max - 1); @@ -583,7 +587,7 @@ xbsd_check_new_partition (int *i) if (t == BSD_MAXPARTITIONS) { - fprintf (stderr, "The maximum number of partitions has been created\n"); + fprintf (stderr, _("The maximum number of partitions has been created\n")); return 0; } } @@ -594,7 +598,7 @@ xbsd_check_new_partition (int *i) if (xbsd_dlabel.d_partitions[*i].p_size != 0) { - fprintf (stderr, "This partition already exists.\n"); + fprintf (stderr, _("This partition already exists.\n")); return 0; } return 1; @@ -716,7 +720,7 @@ xbsd_readlabel (struct partition *p, struct xbsd_disklabel *d) return 0; if (d -> d_npartitions > BSD_MAXPARTITIONS) - fprintf (stderr, "Warning: too many partitions (%d, maximum is %d).\n", + fprintf (stderr, _("Warning: too many partitions (%d, maximum is %d).\n"), d -> d_npartitions, BSD_MAXPARTITIONS); return 1; } @@ -762,7 +766,7 @@ xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d) static void sync_disks (void) { - printf ("\nSyncing disks.\n"); + printf (_("\nSyncing disks.\n")); sync (); sleep (4); } diff --git a/fdisk/fdisksgilabel.c b/fdisk/fdisksgilabel.c index 42f7363e4..25ed31a3e 100644 --- a/fdisk/fdisksgilabel.c +++ b/fdisk/fdisksgilabel.c @@ -5,6 +5,9 @@ * Copyright (C) Andreas Neuper, Sep 1998. * This file may be modified and redistributed under * the terms of the GNU Public License. + * + * Sat Mar 20 EST 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br> + * Internationalization */ #include <stdio.h> /* stderr */ #include <stdlib.h> /* uint */ @@ -15,9 +18,11 @@ #include <assert.h> /* assert */ #include <endian.h> +#include "nls.h" #include <linux/major.h> /* FLOPPY_MAJOR */ #include <linux/hdreg.h> /* HDIO_GETGEO */ +#include "common.h" #include "fdisk.h" #include "fdisksgilabel.h" @@ -47,23 +52,22 @@ int isinfreelist( int b ) \ /* * end of free blocks section */ - struct systypes sgi_sys_types[] = { - {SGI_VOLHDR, "SGI volhdr"}, - {0x01, "SGI trkrepl"}, - {0x02, "SGI secrepl"}, - {SGI_SWAP, "SGI raw"}, - {0x04, "SGI bsd"}, - {0x05, "SGI sysv"}, - {ENTIRE_DISK, "SGI volume"}, - {SGI_EFS, "SGI efs"}, - {0x08, "SGI lvol"}, - {0x09, "SGI rlvol"}, - {0x0A, "SGI xfs"}, - {0x0B, "SGI xlvol"}, - {0x0C, "SGI rxlvol"}, - {LINUX_SWAP, "Linux swap"}, - {LINUX_NATIVE,"Linux native"}, + {SGI_VOLHDR, N_("SGI volhdr")}, + {0x01, N_("SGI trkrepl")}, + {0x02, N_("SGI secrepl")}, + {SGI_SWAP, N_("SGI raw")}, + {0x04, N_("SGI bsd")}, + {0x05, N_("SGI sysv")}, + {ENTIRE_DISK, N_("SGI volume")}, + {SGI_EFS, N_("SGI efs")}, + {0x08, N_("SGI lvol")}, + {0x09, N_("SGI rlvol")}, + {0x0A, N_("SGI xfs")}, + {0x0B, N_("SGI xlvol")}, + {0x0C, N_("SGI rxlvol")}, + {LINUX_SWAP, N_("Linux swap")}, + {LINUX_NATIVE,N_("Linux native")}, {0, NULL } }; @@ -136,8 +140,8 @@ int check_sgi_label() { if (sizeof(sgilabel) > 512) { fprintf(stderr, - "According to MIPS Computer Systems, Inc the " - "Label must not contain more than 512 bytes\n"); + _("According to MIPS Computer Systems, Inc the " + "Label must not contain more than 512 bytes\n")); exit(1); } @@ -155,7 +159,7 @@ int check_sgi_label() if( two_s_complement_32bit_sum( (unsigned int*)sgilabel, sizeof(*sgilabel) ) ) { - fprintf( stderr, "Detected sgi disklabel with wrong checksum.\n" ); + fprintf( stderr, _("Detected sgi disklabel with wrong checksum.\n")); } else { heads = sgi_get_ntrks(); @@ -179,27 +183,28 @@ sgi_list_table( int xtra ) if( xtra ) { - printf( "\nDisk %s (SGI disk label): %d heads, %d sectors\n" + printf(_("\nDisk %s (SGI disk label): %d heads, %d sectors\n" "%d cylinders, %d physical cylinders\n" "%d extra sects/cyl, interleave %d:1\n" "%s\n" - "Units = %ss of %d * 512 bytes\n\n", + "Units = %s of %d * 512 bytes\n\n"), disk_device, heads, sectors, cylinders, SSWAP16(sgiparam.pcylcount), SSWAP16(sgiparam.sparecyl), SSWAP16(sgiparam.ilfact), (char *)sgilabel, - str_units(), display_factor); + str_units(PLURAL), units_per_sector); } else { - printf( "\nDisk %s (SGI disk label): %d heads, %d sectors, %d cylinders\n" - "Units = %ss of %d * 512 bytes\n\n", + printf( _("\nDisk %s (SGI disk label): " + "%d heads, %d sectors, %d cylinders\n" + "Units = %s of %d * 512 bytes\n\n"), disk_device, heads, sectors, cylinders, - str_units(), display_factor ); + str_units(PLURAL), units_per_sector ); } - printf("----- partitions -----\n" - "%*s Info Start End Sectors Id System\n", - w + 1, "Device"); + printf(_("----- partitions -----\n" + "%*s Info Start End Sectors Id System\n"), + w + 1, _("Device")); for (i = 0 ; i < partitions; i++) { if( sgi_get_num_sectors(i) || debug ) @@ -216,12 +221,12 @@ sgi_list_table( int xtra ) /* no odd flag on end */ (long) len, /* type id */ sgi_get_sysid(i), /* type name */ (type = partition_type(sgi_get_sysid(i))) - ? type : "Unknown"); + ? type : _("Unknown")); } } - printf( "----- bootinfo -----\nBootfile: %s\n" - "----- directory entries -----\n", - sgilabel->boot_file ); + printf(_("----- bootinfo -----\nBootfile: %s\n" + "----- directory entries -----\n"), + sgilabel->boot_file ); for (i = 0 ; i < volumes; i++) { if (sgilabel->directory[i].vol_file_size) @@ -229,7 +234,7 @@ sgi_list_table( int xtra ) __u32 start = SSWAP32(sgilabel->directory[i].vol_file_start); __u32 len = SSWAP32(sgilabel->directory[i].vol_file_size); char*name = sgilabel->directory[i].vol_file_name; - printf("%2d: %-10s sector%5u size%8u\n", + printf(_("%2d: %-10s sector%5u size%8u\n"), i, name, (unsigned int) start, (unsigned int) len); } } @@ -290,25 +295,25 @@ sgi_check_bootfile( const char* aFile ) { if( strlen( aFile ) < 3 ) /* "/a\n" is minimum */ { - printf( "\nInvalid Bootfile!\n" + printf( _("\nInvalid Bootfile!\n" "\tThe bootfile must be an absolute non-zero pathname,\n" - "\te.g. \"/unix\" or \"/unix.save\".\n" ); + "\te.g. \"/unix\" or \"/unix.save\".\n") ); return 0; } else if( strlen( aFile ) > 16 ) { - printf( "\n\tName of Bootfile too long: 16 bytes maximum.\n" ); + printf( _("\n\tName of Bootfile too long: 16 bytes maximum.\n") ); return 0; } else if( aFile[0] != '/' ) { - printf( "\n\tBootfile must have a fully qualified pathname.\n" ); + printf( _("\n\tBootfile must have a fully qualified pathname.\n") ); return 0; } if( strncmp( aFile, sgilabel->boot_file, 16 ) ) { - printf( "\n\tBe aware, that the bootfile is not checked for existence.\n\t" - "SGI's default is \"/unix\" and for backup \"/unix.save\".\n" ); + printf( _("\n\tBe aware, that the bootfile is not checked for existence.\n\t" + "SGI's default is \"/unix\" and for backup \"/unix.save\".\n") ); /* filename is correct and did change */ return 1; } @@ -335,7 +340,7 @@ sgi_set_bootfile( const char* aFile ) sgilabel->boot_file[i] = 0; i++; } - printf( "\n\tBootfile is changed to \"%s\".\n", sgilabel->boot_file ); + printf( _("\n\tBootfile is changed to \"%s\".\n"), sgilabel->boot_file ); } return; } @@ -385,7 +390,7 @@ sgi_write_table( void ) static int -compare_start( int*x, int*y ) +compare_start( int *x, int *y ) { /* * sort according to start sectors @@ -423,7 +428,6 @@ verify_sgi( int verbose ) { int Index[16]; /* list of valid partitions */ int sortcount = 0; /* number of used partitions, i.e. non-zero lengths */ - int compare_start();/* comparison function above */ int entire = 0, i = 0; /* local counters */ int start = 0; int gap = 0; /* count unused blocks */ @@ -441,7 +445,7 @@ verify_sgi( int verbose ) if( entire++ == 1 ) { if(verbose) - printf("More than one entire disk entriy present.\n"); + printf(_("More than one entire disk entry present.\n")); } } } @@ -449,27 +453,27 @@ verify_sgi( int verbose ) if( sortcount == 0 ) { if(verbose) - printf("No partitions defined\n"); + printf(_("No partitions defined\n")); return lastblock; } qsort( Index, sortcount, sizeof(Index[0]), (void*)compare_start ); if( sgi_get_sysid( Index[0] ) == ENTIRE_DISK ) { if( ( Index[0] != 10 ) && verbose ) - printf( "IRIX likes when Partition 11 covers the entire disk.\n" ); + printf( _("IRIX likes when Partition 11 covers the entire disk.\n") ); if( ( sgi_get_start_sector( Index[0] ) != 0 ) && verbose ) - printf( "The entire disk partition should start at block 0,\nnot " - "at diskblock %d.\n", sgi_get_start_sector(Index[0] ) ); + printf( _("The entire disk partition should start at block 0,\nnot " + "at diskblock %d.\n"), sgi_get_start_sector(Index[0] ) ); if(debug) /* I do not understand how some disks fulfil it */ if( ( sgi_get_num_sectors( Index[0] ) != lastblock ) && verbose ) - printf( "The entire disk partition is only %d diskblock large,\n" - "but the disk is %d diskblocks long.\n", + printf( _("The entire disk partition is only %d diskblock large,\n" + "but the disk is %d diskblocks long.\n"), sgi_get_num_sectors( Index[0] ), lastblock ); lastblock = sgi_get_num_sectors( Index[0] ); } else { if( verbose ) - printf( "One Partition (#11) should cover the entire disk.\n" ); + printf( _("One Partition (#11) should cover the entire disk.\n") ); if(debug>2) printf( "sysid=%d\tpartition=%d\n", sgi_get_sysid( Index[0] ), Index[0]+1 ); @@ -481,14 +485,14 @@ verify_sgi( int verbose ) { if(debug) /* I do not understand how some disks fulfil it */ if( verbose ) - printf( "Partition %d does not start on cylinder boundary.\n", + printf( _("Partition %d does not start on cylinder boundary.\n"), Index[i]+1 ); } if( sgi_get_num_sectors( Index[i] ) % cylsize != 0 ) { if(debug) /* I do not understand how some disks fulfil it */ if( verbose ) - printf( "Partition %d does not end on cylinder boundary.\n", + printf( _("Partition %d does not end on cylinder boundary.\n"), Index[i]+1 ); } /* We cannot handle several "entire disk" entries. */ @@ -496,7 +500,7 @@ verify_sgi( int verbose ) if( start > sgi_get_start_sector( Index[i] ) ) { if( verbose ) - printf( "The Partition %d and %d overlap by %d sectors.\n", + printf( _("The Partition %d and %d overlap by %d sectors.\n"), Index[i-1]+1, Index[i]+1, start - sgi_get_start_sector( Index[i] ) ); if( gap > 0 ) gap = -gap; @@ -505,7 +509,7 @@ verify_sgi( int verbose ) if( start < sgi_get_start_sector( Index[i] ) ) { if( verbose ) - printf( "Unused gap of %8d sectors - sectors %8d-%d\n", + printf( _("Unused gap of %8d sectors - sectors %8d-%d\n"), sgi_get_start_sector( Index[i] ) - start, start, sgi_get_start_sector( Index[i] )-1 ); gap += sgi_get_start_sector( Index[i] ) - start; @@ -525,7 +529,7 @@ verify_sgi( int verbose ) if( ( start < lastblock ) ) { if( verbose ) - printf( "Unused gap of %8d sectors - sectors %8d-%d\n", + printf( _("Unused gap of %8d sectors - sectors %8d-%d\n"), lastblock - start, start, lastblock-1 ); gap += lastblock - start; add2freelist( start, lastblock ); @@ -538,20 +542,20 @@ verify_sgi( int verbose ) { if( !sgi_get_num_sectors( sgi_get_bootpartition() ) ) { - printf( "\nThe boot partition does not exist.\n" ); + printf( _("\nThe boot partition does not exist.\n") ); } if( !sgi_get_num_sectors( sgi_get_swappartition() ) ) { - printf( "\nThe swap partition does not exist.\n" ); + printf( _("\nThe swap partition does not exist.\n") ); } else if( ( sgi_get_sysid( sgi_get_swappartition() ) != SGI_SWAP ) && ( sgi_get_sysid( sgi_get_swappartition() ) != LINUX_SWAP ) ) { - printf( "\nThe swap partition has no swap type.\n" ); + printf( _("\nThe swap partition has no swap type.\n") ); } if( sgi_check_bootfile( "/unix" ) ) { - printf( "\tYou have chosen an unusual boot file name.\n" ); + printf( _("\tYou have chosen an unusual boot file name.\n") ); } } return gap; @@ -562,18 +566,18 @@ sgi_change_sysid( int i, int sys ) { if( sgi_get_num_sectors(i) == 0 ) /* caught already before, ... */ { - printf("Sorry You may change the Tag of non-empty partitions.\n"); + printf(_("Sorry You may change the Tag of non-empty partitions.\n")); return; } if( ((sys != ENTIRE_DISK ) && (sys != SGI_VOLHDR)) && (sgi_get_start_sector(i)<1) ) { read_chars( - "It is highly recommended that the partition at offset 0\n" + _("It is highly recommended that the partition at offset 0\n" "is of type \"SGI volhdr\", the IRIX system will rely on it to\n" "retrieve from its directory standalone tools like sash and fx.\n" "Only the \"SGI volume\" entire disk section may violate this.\n" - "Type YES if you are sure about tagging this partition differently.\n" ); + "Type YES if you are sure about tagging this partition differently.\n")); if (strcmp (line_ptr, "YES\n")) return; } @@ -614,9 +618,7 @@ sgi_set_partition( int i, uint start, uint length, int sys ) SSWAP32( start ); changed[i] = 1; if( sgi_gaps(0) < 0 ) /* rebuild freelist */ - { - printf( "Do You know, You got a partition overlap on the disk?\n" ); - } + printf(_("Do You know, You got a partition overlap on the disk?\n")); return; } @@ -679,38 +681,36 @@ sgi_add_partition( int n, int sys ) } if( sgi_get_num_sectors(n) ) { - printf( "Partition %d is already defined. Delete " - "it before re-adding it.\n", n + 1); + printf(_("Partition %d is already defined. Delete " + "it before re-adding it.\n"), n + 1); return; } if( (sgi_entire() == -1) && (sys != SGI_VOLUME) ) { - printf( "Attempting to generate entire disk entry automatically.\n" ); + printf(_("Attempting to generate entire disk entry automatically.\n")); sgi_set_entire(); sgi_set_volhdr(); } if( (sgi_gaps() == 0) && (sys != SGI_VOLUME) ) { - printf( "The entire disk is already covered with partitions.\n" ); + printf(_("The entire disk is already covered with partitions.\n")); return; } if( sgi_gaps() < 0 ) { - printf( "You got a partition overlap on the disk. Fix it first!\n" ); + printf(_("You got a partition overlap on the disk. Fix it first!\n")); return; } - sprintf(mesg, "First %s", str_units()); - for(;;) - { - if(sys == SGI_VOLUME) - { + sprintf(mesg, _("First %s"), str_units(SINGULAR)); + for(;;) { + if(sys == SGI_VOLUME) { last = sgi_get_lastblock(); first = read_int(0, 0, last-1, 0, mesg); if( first != 0 ) { - printf( "It is highly recommended that eleventh partition\n" - "covers the entire disk and is of type `SGI volume'\n"); + printf(_("It is highly recommended that eleventh partition\n" + "covers the entire disk and is of type `SGI volume'\n")); } } else { first = freelist[0].first; @@ -718,30 +718,28 @@ sgi_add_partition( int n, int sys ) first = read_int(scround(first), scround(first), scround(last)-1, 0, mesg); } - if (unit_flag) - first *= display_factor; + if (display_in_cyl_units) + first *= units_per_sector; else first = first; /* align to cylinder if you know how ... */ if( !last ) last = isinfreelist(first); if( last == 0 ) { - printf( "You will get a partition overlap on the disk. " - "Fix it first!\n" ); + printf(_("You will get a partition overlap on the disk. " + "Fix it first!\n")); } else break; } - sprintf(mesg, " Last %s", str_units()); + sprintf(mesg, _(" Last %s"), str_units(SINGULAR)); last = read_int(scround(first), scround(last)-1, scround(last)-1, scround(first), mesg)+1; - if (unit_flag) - last *= display_factor; + if (display_in_cyl_units) + last *= units_per_sector; else last = last; /* align to cylinder if You know how ... */ if( (sys == SGI_VOLUME) && ( first != 0 || last != sgi_get_lastblock() ) ) - { - printf( "It is highly recommended that eleventh partition\n" - "covers the entire disk and is of type `SGI volume'\n"); - } + printf(_("It is highly recommended that eleventh partition\n" + "covers the entire disk and is of type `SGI volume'\n")); sgi_set_partition( n, first, last-first, sys ); return; } @@ -755,9 +753,9 @@ create_sgilabel( void ) int sysid; } old[4]; int i=0; fprintf( stderr, - "Building a new SGI disklabel. Changes will remain in memory only,\n" + _("Building a new SGI disklabel. Changes will remain in memory only,\n" "until you decide to write them. After that, of course, the previous\n" - "content will be unrecoverable lost.\n\n"); + "content will be unrecoverable lost.\n\n")); #if BYTE_ORDER == LITTLE_ENDIAN other_endian = 1; #else @@ -783,9 +781,9 @@ create_sgilabel( void ) old[i].sysid = part_table[i]->sys_ind; old[i].start = get_start_sect( part_table[i] ); old[i].nsect = get_nr_sects( part_table[i] ); - printf( "Trying to keep parameters of partition %d.\n", i ); + printf( _("Trying to keep parameters of partition %d.\n"), i ); if( debug ) - printf( "ID=%02x\tSTART=%d\tLENGTH=%d\n", + printf( _("ID=%02x\tSTART=%d\tLENGTH=%d\n"), old[i].sysid, old[i].start, old[i].nsect ); } } diff --git a/fdisk/fdisksgilabel.h b/fdisk/fdisksgilabel.h index 6eb7293f9..fa35f8f3e 100644 --- a/fdisk/fdisksgilabel.h +++ b/fdisk/fdisksgilabel.h @@ -91,7 +91,6 @@ typedef struct { : (__u16)(x)) #define SSWAP32(x) (other_endian ? __swap32(x) \ : (__u32)(x)) -#define scround(x) ((x+(display_factor-1)*unit_flag)/display_factor) /* fdisk.c */ #define sgilabel ((sgi_partition *)buffer) diff --git a/fdisk/fdisksunlabel.c b/fdisk/fdisksunlabel.c index 708377379..d484e7932 100644 --- a/fdisk/fdisksunlabel.c +++ b/fdisk/fdisksunlabel.c @@ -5,6 +5,9 @@ * Jakub Jelinek (jj@sunsite.mff.cuni.cz), July 1996 * * Merged with fdisk for other architectures, aeb, June 1998. + * + * Sat Mar 20 EST 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br> + * Internationalization */ #include <stdio.h> /* stderr */ @@ -13,14 +16,19 @@ #include <unistd.h> /* write */ #include <sys/ioctl.h> /* ioctl */ #include <sys/stat.h> /* stat */ +#include "nls.h" #include <endian.h> -#if 1 +#include "../defines.h" /* for HAVE_scsi_h */ +#ifdef HAVE_scsi_h +#define u_char unsigned char #include <scsi/scsi.h> /* SCSI_IOCTL_GET_IDLUN */ +#undef u_char #endif #include <linux/major.h> /* FLOPPY_MAJOR */ #include <linux/hdreg.h> /* HDIO_GETGEO */ +#include "common.h" #include "fdisk.h" #include "fdisksunlabel.h" @@ -32,17 +40,17 @@ static int floppy = 0; #define LINUX_NATIVE 0x83 struct systypes sun_sys_types[] = { - {0, "Empty"}, - {1, "Boot"}, - {2, "SunOS root"}, - {SUNOS_SWAP, "SunOS swap"}, - {4, "SunOS usr"}, - {WHOLE_DISK, "Whole disk"}, - {6, "SunOS stand"}, - {7, "SunOS var"}, - {8, "SunOS home"}, - {LINUX_SWAP, "Linux swap"}, - {LINUX_NATIVE, "Linux native"}, + {0, N_("Empty")}, + {1, N_("Boot")}, + {2, N_("SunOS root")}, + {SUNOS_SWAP, N_("SunOS swap")}, + {4, N_("SunOS usr")}, + {WHOLE_DISK, N_("Whole disk")}, + {6, N_("SunOS stand")}, + {7, N_("SunOS var")}, + {8, N_("SunOS home")}, + {LINUX_SWAP, N_("Linux swap")}, + {LINUX_NATIVE, N_("Linux native")}, { 0, NULL } }; @@ -111,10 +119,10 @@ int check_sun_label(void) ush = ((unsigned short *) (sunlabel + 1)) - 1; for (csum = 0; ush >= (unsigned short *)sunlabel;) csum ^= *ush--; if (csum) { - fprintf(stderr, "Detected sun disklabel with wrong checksum.\n" + fprintf(stderr,_("Detected sun disklabel with wrong checksum.\n" "Probably you'll have to set all the values,\n" "e.g. heads, sectors, cylinders and partitions\n" - "or force a fresh label (s command in main menu)\n"); + "or force a fresh label (s command in main menu)\n")); } else { heads = SSWAP16(sunlabel->ntrks); cylinders = SSWAP16(sunlabel->ncyl); @@ -204,7 +212,7 @@ sun_autoconfigure_scsi() { continue; if (!strstr(model, sun_drives[i].model)) continue; - printf("Autoconfigure found a %s%s%s\n",sun_drives[i].vendor,(*sun_drives[i].vendor) ? " " : "",sun_drives[i].model); + printf(_("Autoconfigure found a %s%s%s\n"),sun_drives[i].vendor,(*sun_drives[i].vendor) ? " " : "",sun_drives[i].model); p = sun_drives + i; break; } @@ -230,9 +238,10 @@ void create_sunlabel(void) unsigned char c; struct sun_predefined_drives *p = NULL; - fprintf(stderr, "Building a new sun disklabel. Changes will remain in memory only,\n" - "until you decide to write them. After that, of course, the previous\n" - "content won't be recoverable.\n\n"); + fprintf(stderr, + _("Building a new sun disklabel. Changes will remain in memory only,\n" + "until you decide to write them. After that, of course, the previous\n" + "content won't be recoverable.\n\n")); #if BYTE_ORDER == LITTLE_ENDIAN other_endian = 1; #else @@ -241,9 +250,9 @@ void create_sunlabel(void) memset(buffer, 0, SECTOR_SIZE); sunlabel->magic = SSWAP16(SUN_LABEL_MAGIC); if (!floppy) { - puts("Drive type\n" + puts(_("Drive type\n" " ? auto configure\n" - " 0 custom (with hardware detected defaults)"); + " 0 custom (with hardware detected defaults)")); for (i = 0; i < SIZE(sun_drives); i++) { printf(" %c %s%s%s\n", i + 'a', sun_drives[i].vendor, @@ -251,7 +260,7 @@ void create_sunlabel(void) sun_drives[i].model); } for (;;) { - c = read_char("Select type (? for auto, 0 for custom): "); + c = read_char(_("Select type (? for auto, 0 for custom): ")); if (c >= 'a' && c < 'a' + SIZE(sun_drives)) { p = sun_drives + c - 'a'; break; @@ -263,7 +272,7 @@ void create_sunlabel(void) } else if (c == '?' && scsi_disk) { p = sun_autoconfigure_scsi(); if (!p) - printf("Autoconfigure failed.\n"); + printf(_("Autoconfigure failed.\n")); else break; } @@ -290,26 +299,26 @@ void create_sunlabel(void) sunlabel->ilfact = SSWAP16(1); sunlabel->sparecyl = 0; } else { - heads = read_int(1,heads,1024,0,"Heads"); - sectors = read_int(1,sectors,1024,0,"Sectors/track"); + heads = read_int(1,heads,1024,0,_("Heads")); + sectors = read_int(1,sectors,1024,0,_("Sectors/track")); if (cylinders) - cylinders = read_int(1,cylinders-2,65535,0,"Cylinders"); + cylinders = read_int(1,cylinders-2,65535,0,_("Cylinders")); else - cylinders = read_int(1,0,65535,0,"Cylinders"); + cylinders = read_int(1,0,65535,0,_("Cylinders")); sunlabel->nacyl = SSWAP16(read_int(0,2,65535,0, - "Alternate cylinders")); + _("Alternate cylinders"))); sunlabel->pcylcount = SSWAP16(read_int(0,cylinders+SSWAP16(sunlabel->nacyl), - 65535,0,"Physical cylinders")); + 65535,0,_("Physical cylinders"))); sunlabel->rspeed = SSWAP16(read_int(1,5400,100000,0, - "Rotation speed (rpm)")); + _("Rotation speed (rpm)"))); sunlabel->ilfact = - SSWAP16(read_int(1,1,32,0,"Interleave factor")); + SSWAP16(read_int(1,1,32,0,_("Interleave factor"))); sunlabel->sparecyl = SSWAP16(read_int(0,0,sectors,0, - "Extra sectors per cylinder")); + _("Extra sectors per cylinder"))); } } else { sunlabel->sparecyl = SSWAP16(p->sparecyl); @@ -322,10 +331,10 @@ void create_sunlabel(void) cylinders = p->ncyl; heads = p->ntrks; sectors = p->nsect; - puts("You may change all the disk params from the x menu"); + puts(_("You may change all the disk params from the x menu")); } sprintf(buffer, "%s%s%s cyl %d alt %d hd %d sec %d", - p ? p->vendor : "", (p && *p->vendor) ? " " : "", p ? p->model : (floppy ? "3,5\" floppy" : "Linux custom"), + p ? p->vendor : "", (p && *p->vendor) ? " " : "", p ? p->model : (floppy ? _("3,5\" floppy") : _("Linux custom")), cylinders, SSWAP16(sunlabel->nacyl), heads, sectors); sunlabel->ntrks = SSWAP16(heads); sunlabel->nsect = SSWAP16(sectors); @@ -406,7 +415,7 @@ void verify_sun(void) for (k = 0; k < 7; k++) { for (i = 0; i < 8; i++) { if (k && (lens[i] % (heads * sectors))) { - printf("Partition %d doesn't end on cylinder boundary\n", i+1); + printf(_("Partition %d doesn't end on cylinder boundary\n"), i+1); } if (lens[i]) { for (j = 0; j < i; j++) @@ -426,8 +435,8 @@ void verify_sun(void) endo = starts[i]+lens[i]; if (starts[j]+lens[j] < endo) endo = starts[j]+lens[j]; - printf("Partition %d overlaps with others in " - "sectors %d-%d\n", i+1, starto, endo); + printf(_("Partition %d overlaps with others in " + "sectors %d-%d\n"), i+1, starto, endo); } } } @@ -443,18 +452,18 @@ void verify_sun(void) qsort(array,SIZE(array),sizeof(array[0]), (int (*)(const void *,const void *)) verify_sun_cmp); if (array[0] == -1) { - printf("No partitions defined\n"); + printf(_("No partitions defined\n")); return; } stop = cylinders * heads * sectors; if (starts[array[0]]) - printf("Unused gap - sectors 0-%d\n",starts[array[0]]); + printf(_("Unused gap - sectors 0-%d\n"),starts[array[0]]); for (i = 0; i < 7 && array[i+1] != -1; i++) { - printf("Unused gap - sectors %d-%d\n",starts[array[i]]+lens[array[i]],starts[array[i+1]]); + printf(_("Unused gap - sectors %d-%d\n"),starts[array[i]]+lens[array[i]],starts[array[i+1]]); } start = starts[array[i]]+lens[array[i]]; if (start < stop) - printf("Unused gap - sectors %d-%d\n",start,stop); + printf(_("Unused gap - sectors %d-%d\n"),start,stop); } void add_sun_partition(int n, int sys) @@ -467,8 +476,8 @@ void add_sun_partition(int n, int sys) int i, first, last; if (sunlabel->partitions[n].num_sectors && sunlabel->infos[n].id) { - printf("Partition %d is already defined. Delete " - "it before re-adding it.\n", n + 1); + printf(_("Partition %d is already defined. Delete " + "it before re-adding it.\n"), n + 1); return; } @@ -477,20 +486,20 @@ void add_sun_partition(int n, int sys) if (n == 2) whole_disk = 1; else { - printf("Other partitions already cover the whole disk.\nDelete " - "some/shrink them before retry.\n"); + printf(_("Other partitions already cover the whole disk.\nDelete " + "some/shrink them before retry.\n")); return; } } - sprintf(mesg, "First %s", str_units()); + sprintf(mesg, _("First %s"), str_units(SINGULAR)); for (;;) { if (whole_disk) first = read_int(0, 0, 0, 0, mesg); else first = read_int(scround(start), scround(stop)+1, scround(stop), 0, mesg); - if (unit_flag) - first *= display_factor; + if (display_in_cyl_units) + first *= units_per_sector; else /* Starting sector has to be properly aligned */ first = (first + heads * sectors - 1) / (heads * sectors); @@ -507,7 +516,7 @@ and is of type `Whole disk'\n"); whole_disk = 1; break; } - printf("Sector %d is already allocated\n", first); + printf(_("Sector %d is already allocated\n"), first); } else break; } @@ -517,7 +526,7 @@ and is of type `Whole disk'\n"); if (starts[i] > first && starts[i] < stop) stop = starts[i]; } - sprintf(mesg, "Last %s or +size or +sizeM or +sizeK", str_units()); + sprintf(mesg, _("Last %s or +size or +sizeM or +sizeK"), str_units(SINGULAR)); if (whole_disk) last = read_int(scround(stop2), scround(stop2), scround(stop2), 0, mesg); @@ -527,16 +536,19 @@ and is of type `Whole disk'\n"); else last = read_int(scround(first), scround(stop), scround(stop), scround(first), mesg); - if (unit_flag) - last *= display_factor; + if (display_in_cyl_units) + last *= units_per_sector; if (n == 2 && !first) { if (last >= stop2) { whole_disk = 1; last = stop2; } else if (last > stop) { - printf ("You haven't covered whole disk with 3rd partition, but your value\n" - "%d %s coveres some other partition. Your entry have been changed\n" - "to %d %s\n", scround(last), str_units(), scround(stop), str_units()); + printf ( + _("You haven't covered the whole disk with the 3rd partition, but your value\n" + "%d %s covers some other partition. Your entry has been changed\n" + "to %d %s\n"), + scround(last), str_units(SINGULAR), + scround(stop), str_units(SINGULAR)); last = stop; } } else if (!whole_disk && last > stop) @@ -552,10 +564,10 @@ sun_delete_partition(int i) { !sunlabel->partitions[i].start_cylinder && SSWAP32(sunlabel->partitions[i].num_sectors) == heads * sectors * cylinders) - printf("If you want to maintain SunOS/Solaris compatibility, " + printf(_("If you want to maintain SunOS/Solaris compatibility, " "consider leaving this\n" "partition as Whole disk (5), starting at 0, with %u " - "sectors\n", + "sectors\n"), (uint) SSWAP32(sunlabel->partitions[i].num_sectors)); sunlabel->infos[i].id = 0; sunlabel->partitions[i].num_sectors = 0; @@ -565,11 +577,11 @@ void sun_change_sysid(int i, int sys) { if (sys == LINUX_SWAP && !sunlabel->partitions[i].start_cylinder) { read_chars( - "It is highly recommended that the partition at offset 0\n" + _("It is highly recommended that the partition at offset 0\n" "is UFS, EXT2FS filesystem or SunOS swap. Putting Linux swap\n" "there may destroy your partition table and bootblock.\n" "Type YES if you're very sure you would like that partition\n" - "tagged with 82 (Linux swap): "); + "tagged with 82 (Linux swap): ")); if (strcmp (line_ptr, "YES\n")) return; } @@ -595,26 +607,28 @@ sun_list_table(int xtra) { w = strlen(disk_device); if (xtra) - printf("\nDisk %s (Sun disk label): %d heads, %d sectors, %d rpm\n" - "%d cylinders, %d alternate cylinders, %d physical cylinders\n" - "%d extra sects/cyl, interleave %d:1\n" - "%s\n" - "Units = %ss of %d * 512 bytes\n\n", + printf( + _("\nDisk %s (Sun disk label): %d heads, %d sectors, %d rpm\n" + "%d cylinders, %d alternate cylinders, %d physical cylinders\n" + "%d extra sects/cyl, interleave %d:1\n" + "%s\n" + "Units = %s of %d * 512 bytes\n\n"), disk_device, heads, sectors, SSWAP16(sunlabel->rspeed), cylinders, SSWAP16(sunlabel->nacyl), SSWAP16(sunlabel->pcylcount), SSWAP16(sunlabel->sparecyl), SSWAP16(sunlabel->ilfact), (char *)sunlabel, - str_units(), display_factor); + str_units(PLURAL), units_per_sector); else - printf("\nDisk %s (Sun disk label): %d heads, %d sectors, %d cylinders\n" - "Units = %ss of %d * 512 bytes\n\n", + printf( + _("\nDisk %s (Sun disk label): %d heads, %d sectors, %d cylinders\n" + "Units = %s of %d * 512 bytes\n\n"), disk_device, heads, sectors, cylinders, - str_units(), display_factor); + str_units(PLURAL), units_per_sector); - printf("%*s Flag Start End Blocks Id System\n", - w + 1, "Device"); + printf(_("%*s Flag Start End Blocks Id System\n"), + w + 1, _("Device")); for (i = 0 ; i < partitions; i++) { if (sunlabel->partitions[i].num_sectors) { __u32 start = SSWAP32(sunlabel->partitions[i].start_cylinder) * heads * sectors; @@ -629,7 +643,7 @@ sun_list_table(int xtra) { /* odd flag on end */ (long) len / 2, len & 1 ? '+' : ' ', /* type id */ sunlabel->infos[i].id, /* type name */ (type = partition_type(sunlabel->infos[i].id)) - ? type : "Unknown"); + ? type : _("Unknown")); } } } @@ -638,7 +652,7 @@ void sun_set_alt_cyl(void) { sunlabel->nacyl = SSWAP16(read_int(0,SSWAP16(sunlabel->nacyl), 65535, 0, - "Number of alternate cylinders")); + _("Number of alternate cylinders"))); } void @@ -650,28 +664,28 @@ void sun_set_xcyl(void) { sunlabel->sparecyl = SSWAP16(read_int(0, SSWAP16(sunlabel->sparecyl), sectors, 0, - "Extra sectors per cylinder")); + _("Extra sectors per cylinder"))); } void sun_set_ilfact(void) { sunlabel->ilfact = SSWAP16(read_int(1, SSWAP16(sunlabel->ilfact), 32, 0, - "Interleave factor")); + _("Interleave factor"))); } void sun_set_rspeed(void) { sunlabel->rspeed = SSWAP16(read_int(1, SSWAP16(sunlabel->rspeed), 100000, 0, - "Rotation speed (rpm)")); + _("Rotation speed (rpm)"))); } void sun_set_pcylcount(void) { sunlabel->pcylcount = SSWAP16(read_int(0, SSWAP16(sunlabel->pcylcount), 65535, 0, - "Number of physical cylinders")); + _("Number of physical cylinders"))); } void diff --git a/fdisk/fdisksunlabel.h b/fdisk/fdisksunlabel.h index d9d3706d3..1a75713c8 100644 --- a/fdisk/fdisksunlabel.h +++ b/fdisk/fdisksunlabel.h @@ -36,8 +36,6 @@ typedef struct { #define SSWAP32(x) (other_endian ? __swap32(x) \ : (__u32)(x)) -#define scround(x) ((x+(display_factor-1)*unit_flag)/display_factor) - /* fdisk.c */ extern char changed[MAXIMUM_PARTS]; extern char buffer[MAX_SECTOR_SIZE]; diff --git a/fdisk/i386_sys_types.c b/fdisk/i386_sys_types.c new file mode 100644 index 000000000..f3624724e --- /dev/null +++ b/fdisk/i386_sys_types.c @@ -0,0 +1,86 @@ +/* DOS partition types */ +#include "common.h" +#include "nls.h" + +struct systypes i386_sys_types[] = { + {0x00, N_("Empty")}, + {0x01, N_("FAT12")}, + {0x02, N_("XENIX root")}, + {0x03, N_("XENIX usr")}, + {0x04, N_("FAT16 <32M")}, + {0x05, N_("Extended")}, /* DOS 3.3+ extended partition */ + {0x06, N_("FAT16")}, /* DOS 16-bit >=32M */ + {0x07, N_("HPFS/NTFS")}, /* OS/2 IFS, eg, HPFS or NTFS or QNX */ + {0x08, N_("AIX")}, /* AIX boot (AIX -- PS/2 port) or SplitDrive */ + {0x09, N_("AIX bootable")}, /* AIX data or Coherent */ + {0x0a, N_("OS/2 Boot Manager")},/* OS/2 Boot Manager */ + {0x0b, N_("Win95 FAT32")}, + {0x0c, N_("Win95 FAT32 (LBA)")},/* LBA really is `Extended Int 13h' */ + {0x0e, N_("Win95 FAT16 (LBA)")}, + {0x0f, N_("Win95 Ext'd (LBA)")}, + {0x10, N_("OPUS")}, + {0x11, N_("Hidden FAT12")}, + {0x12, N_("Compaq diagnostics")}, + {0x14, N_("Hidden FAT16 <32M")}, + {0x16, N_("Hidden FAT16")}, + {0x17, N_("Hidden HPFS/NTFS")}, + {0x18, N_("AST Windows swapfile")}, + {0x1b, N_("Hidden Win95 FAT32")}, + {0x1c, N_("Hidden Win95 FAT32 (LBA)")}, + {0x1e, N_("Hidden Win95 FAT16 (LBA)")}, + {0x24, N_("NEC DOS")}, + {0x3c, N_("PartitionMagic recovery")}, + {0x40, N_("Venix 80286")}, + {0x41, N_("PPC PReP Boot")}, + {0x42, N_("SFS")}, + {0x4d, N_("QNX4.x")}, + {0x4e, N_("QNX4.x 2nd part")}, + {0x4f, N_("QNX4.x 3rd part")}, + {0x50, N_("OnTrack DM")}, + {0x51, N_("OnTrack DM6 Aux1")}, /* (or Novell) */ + {0x52, N_("CP/M")}, /* CP/M or Microport SysV/AT */ + {0x53, N_("OnTrack DM6 Aux3")}, + {0x54, N_("OnTrackDM6")}, + {0x55, N_("EZ-Drive")}, + {0x56, N_("Golden Bow")}, + {0x5c, N_("Priam Edisk")}, + {0x61, N_("SpeedStor")}, + {0x63, N_("GNU HURD or SysV")}, /* GNU HURD or Mach or Sys V/386 (such as ISC UNIX) */ + {0x64, N_("Novell Netware 286")}, + {0x65, N_("Novell Netware 386")}, + {0x70, N_("DiskSecure Multi-Boot")}, + {0x75, N_("PC/IX")}, + {0x80, N_("Old Minix")}, /* Minix 1.4a and earlier */ + {0x81, N_("Minix / old Linux")},/* Minix 1.4b and later */ + {0x82, N_("Linux swap")}, /* also Solaris */ + {0x83, N_("Linux")}, + {0x84, N_("OS/2 hidden C: drive")}, + {0x85, N_("Linux extended")}, + {0x86, N_("NTFS volume set")}, + {0x87, N_("NTFS volume set")}, + {0x93, N_("Amoeba")}, + {0x94, N_("Amoeba BBT")}, /* (bad block table) */ + {0xa0, N_("IBM Thinkpad hibernation")}, + {0xa5, N_("BSD/386")}, + {0xa6, N_("OpenBSD")}, + {0xa7, N_("NeXTSTEP")}, + {0xb7, N_("BSDI fs")}, + {0xb8, N_("BSDI swap")}, + {0xc1, N_("DRDOS/sec (FAT-12)")}, + {0xc4, N_("DRDOS/sec (FAT-16 < 32M)")}, + {0xc6, N_("DRDOS/sec (FAT-16)")}, + {0xc7, N_("Syrinx")}, + {0xdb, N_("CP/M / CTOS / ...")},/* CP/M or Concurrent CP/M or Concurrent DOS or CTOS */ + {0xe1, N_("DOS access")}, /* DOS access or SpeedStor 12-bit FAT extended partition */ + {0xe3, N_("DOS R/O")}, /* DOS R/O or SpeedStor */ + {0xe4, N_("SpeedStor")}, /* SpeedStor 16-bit FAT extended partition < 1024 cyl. */ + {0xeb, N_("BeOS fs")}, + {0xf1, N_("SpeedStor")}, + {0xf4, N_("SpeedStor")}, /* SpeedStor large partition */ + {0xf2, N_("DOS secondary")}, /* DOS 3.3+ secondary */ + {0xfd, N_("Linux raid autodetect")},/* New (2.2.x) raid partition with autodetect + using persistent superblock */ + {0xfe, N_("LANstep")}, /* SpeedStor >1024 cyl. or LANstep */ + {0xff, N_("BBT")}, /* Xenix Bad Block Table */ + { 0, 0 } +}; diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c index c3f470f89..d25543dd3 100644 --- a/fdisk/sfdisk.c +++ b/fdisk/sfdisk.c @@ -25,6 +25,9 @@ * Well, a good user interface is still lacking. On the other hand, * many configurations cannot be handled by any other fdisk. * I changed the name to sfdisk to prevent confusion. - aeb, 970501 + * + * Changes: + * 19990319 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> - i18n */ #define PROGNAME "sfdisk" @@ -45,6 +48,9 @@ #include <linux/unistd.h> /* _syscall */ #include <linux/hdreg.h> /* HDIO_GETGEO */ #include <linux/fs.h> /* BLKGETSIZE */ +#include <locale.h> +#include "nls.h" +#include "common.h" #define SIZE(a) (sizeof(a)/sizeof(a[0])) @@ -139,12 +145,12 @@ sseek(char *dev, unsigned int fd, unsigned long s) { if ((out = lseek(fd, in, SEEK_SET)) != in) { #endif perror("llseek"); - error("seek error on %s - cannot seek to %lu\n", dev, s); + error(_("seek error on %s - cannot seek to %lu\n"), dev, s); return 0; } if (in != out) { - error("seek error: wanted 0x%08x%08x, got 0x%08x%08x\n", + error(_("seek error: wanted 0x%08x%08x, got 0x%08x%08x\n"), (uint)(in>>32), (uint)(in & 0xffffffff), (uint)(out>>32), (uint)(out & 0xffffffff)); return 0; @@ -190,11 +196,11 @@ get_sector(char *dev, int fd, unsigned long sno) { return 0; if (!(s = (struct sector *) malloc(sizeof(struct sector)))) - fatal("out of memory - giving up\n"); + fatal(_("out of memory - giving up\n")); if (read(fd, s->data, sizeof(s->data)) != sizeof(s->data)) { perror("read"); - error("read error on %s - cannot read sector %lu\n", dev, sno); + error(_("read error on %s - cannot read sector %lu\n"), dev, sno); free(s); return 0; } @@ -210,7 +216,7 @@ get_sector(char *dev, int fd, unsigned long sno) { int msdos_signature (struct sector *s) { if (*(unsigned short *) (s->data + 0x1fe) != 0xaa55) { - error("ERROR: sector %lu does not have an msdos signature\n", + error(_("ERROR: sector %lu does not have an msdos signature\n"), s->sectornumber); return 0; } @@ -227,7 +233,7 @@ write_sectors(char *dev, int fd) { return 0; if (write(fd, s->data, sizeof(s->data)) != sizeof(s->data)) { perror("write"); - error("write error on %s - cannot write sector %lu\n", + error(_("write error on %s - cannot write sector %lu\n"), dev, s->sectornumber); return 0; } @@ -265,7 +271,7 @@ save_sectors(char *dev, int fdin) { fdout = open(save_sector_file, O_WRONLY | O_CREAT, 0444); if (fdout < 0) { perror(save_sector_file); - error("cannot open partition sector save file (%s)\n", + error(_("cannot open partition sector save file (%s)\n"), save_sector_file); return 0; } @@ -277,13 +283,13 @@ save_sectors(char *dev, int fdin) { return 0; if (read(fdin, ss+4, 512) != 512) { perror("read"); - error("read error on %s - cannot read sector %lu\n", + error(_("read error on %s - cannot read sector %lu\n"), dev, s->sectornumber); return 0; } if (write(fdout, ss, sizeof(ss)) != sizeof(ss)) { perror("write"); - error("write error on %s\n", save_sector_file); + error(_("write error on %s\n"), save_sector_file); return 0; } } @@ -301,35 +307,35 @@ restore_sectors(char *dev) { if (stat(restore_sector_file, &statbuf) < 0) { perror(restore_sector_file); - error("cannot stat partition restore file (%s)\n", + error(_("cannot stat partition restore file (%s)\n"), restore_sector_file); return 0; } if (statbuf.st_size % 516) { - error("partition restore file has wrong size - not restoring\n"); + error(_("partition restore file has wrong size - not restoring\n")); return 0; } if (!(ss = (char *) malloc(statbuf.st_size))) { - error("out of memory?\n"); + error(_("out of memory?\n")); return 0; } fdin = open(restore_sector_file, O_RDONLY); if (fdin < 0) { perror(restore_sector_file); - error("cannot open partition restore file (%s)\n", + error(_("cannot open partition restore file (%s)\n"), restore_sector_file); return 0; } if (read(fdin, ss, statbuf.st_size) != statbuf.st_size) { perror("read"); - error("error reading %s\n", restore_sector_file); + error(_("error reading %s\n"), restore_sector_file); return 0; } fdout = open(dev, O_WRONLY); if (fdout < 0) { perror(dev); - error("cannot open device %s for writing\n", dev); + error(_("cannot open device %s for writing\n"), dev); return 0; } @@ -341,7 +347,7 @@ restore_sectors(char *dev) { return 0; if (write(fdout, ss+4, 512) != 512) { perror(dev); - error("error writing sector %lu on %s\n", sno, dev); + error(_("error writing sector %lu on %s\n"), sno, dev); return 0; } ss += 516; @@ -367,61 +373,70 @@ restore_sectors(char *dev) { * }; */ -unsigned long cylindersize; -unsigned long heads, sectors, cylinders; -unsigned long specified_heads, specified_sectors, specified_cylinders; +/* + * We consider several geometries for a disk: + * B - the BIOS geometry, gotten from the kernel via HDIO_GETGEO + * F - the fdisk geometry + * U - the user-specified geometry + * + * 0 means unspecified / unknown + */ +struct geometry { + unsigned long cylindersize; + unsigned long heads, sectors, cylinders; +} B, F, U; void get_cylindersize(char *dev, int fd, int silent) { struct hd_geometry g; int ioctl_ok = 0; - heads = sectors = cylinders = 0; + B.heads = B.sectors = B.cylinders = 0; if (!ioctl(fd, HDIO_GETGEO, &g)) { ioctl_ok = 1; - heads = g.heads; - sectors = g.sectors; - cylinders = g.cylinders; + B.heads = g.heads; + B.sectors = g.sectors; + B.cylinders = g.cylinders; } - if (specified_heads) - heads = specified_heads; - if (specified_sectors) - sectors = specified_sectors; - if (specified_cylinders) - cylinders = specified_cylinders; + if (U.heads) + B.heads = U.heads; + if (U.sectors) + B.sectors = U.sectors; + if (U.cylinders) + B.cylinders = U.cylinders; - cylindersize = heads * sectors; + B.cylindersize = B.heads * B.sectors; if (ioctl_ok) { if (g.start && !force) { warn( - "Warning: start=%d - this looks like a partition rather than\n" + _("Warning: start=%d - this looks like a partition rather than\n" "the entire disk. Using fdisk on it is probably meaningless.\n" - "[Use the --force option if you really want this]\n", g.start); + "[Use the --force option if you really want this]\n"), g.start); exit(1); } - if (heads != g.heads) - warn("Warning: HDIO_GETGEO says that there are %d heads\n", + if (B.heads != g.heads) + warn(_("Warning: HDIO_GETGEO says that there are %d heads\n"), g.heads); - if (sectors != g.sectors) - warn("Warning: HDIO_GETGEO says that there are %d sectors\n", + if (B.sectors != g.sectors) + warn(_("Warning: HDIO_GETGEO says that there are %d sectors\n"), g.sectors); - if (cylinders != g.cylinders) - warn("Warning: HDIO_GETGEO says that there are %d cylinders\n", + if (B.cylinders != g.cylinders) + warn(_("Warning: HDIO_GETGEO says that there are %d cylinders\n"), g.cylinders); } else if (!silent) - if (!heads || !sectors || !cylinders) - printf("Disk %s: cannot get geometry\n", dev); - if (sectors > 63) - warn("Warning: unlikely number of sectors (%d) - usually at most 63\n" - "This will give problems with all software that uses C/H/S addressing.\n", - sectors); + if (!B.heads || !B.sectors || !B.cylinders) + printf(_("Disk %s: cannot get geometry\n"), dev); + if (B.sectors > 63) + warn(_("Warning: unlikely number of sectors (%d) - usually at most 63\n" + "This will give problems with all software that uses C/H/S addressing.\n"), + B.sectors); if (!silent) - printf("\nDisk %s: %lu heads, %lu sectors, %lu cylinders\n", - dev, heads, sectors, cylinders); + printf(_("\nDisk %s: %lu cylinders, %lu heads, %lu sectors/track\n"), + dev, B.cylinders, B.heads, B.sectors); } typedef struct { unsigned char h,s,c; } chs; /* has some c bits in s */ @@ -431,19 +446,19 @@ typedef struct { unsigned long h,s,c; } longchs; longchs zero_longchs; chs -longchs_to_chs (longchs aa) { +longchs_to_chs (longchs aa, struct geometry G) { chs a; if (aa.h < 256 && aa.s < 64 && aa.c < 1024) { a.h = aa.h; a.s = aa.s | ((aa.c >> 2) & 0xc0); a.c = (aa.c & 0xff); - } else if (heads && sectors) { - a.h = heads - 1; - a.s = sectors | 0xc0; + } else if (G.heads && G.sectors) { + a.h = G.heads - 1; + a.s = G.sectors | 0xc0; a.c = 0xff; } else - a = zero_chs; + a = zero_chs; return a; } @@ -459,13 +474,13 @@ chs_to_longchs (chs a) { } longchs -ulong_to_longchs (unsigned long sno) { +ulong_to_longchs (unsigned long sno, struct geometry G) { longchs aa; - if (heads && sectors && cylindersize) { - aa.s = 1 + sno % sectors; - aa.h = (sno / sectors) % heads; - aa.c = sno / cylindersize; + if (G.heads && G.sectors && G.cylindersize) { + aa.s = 1 + sno % G.sectors; + aa.h = (sno / G.sectors) % G.heads; + aa.c = sno / G.cylindersize; return aa; } else { return zero_longchs; @@ -473,18 +488,18 @@ ulong_to_longchs (unsigned long sno) { } unsigned long -longchs_to_ulong (longchs aa) { - return (aa.c*cylindersize + aa.h*sectors + aa.s - 1); +longchs_to_ulong (longchs aa, struct geometry G) { + return (aa.c*G.cylindersize + aa.h*G.sectors + aa.s - 1); } chs -ulong_to_chs (unsigned long sno) { - return longchs_to_chs(ulong_to_longchs(sno)); +ulong_to_chs (unsigned long sno, struct geometry G) { + return longchs_to_chs(ulong_to_longchs(sno, G), G); } unsigned long -chs_to_ulong (chs a) { - return longchs_to_ulong(chs_to_longchs(a)); +chs_to_ulong (chs a, struct geometry G) { + return longchs_to_ulong(chs_to_longchs(a), G); } int @@ -499,19 +514,19 @@ chs_ok (chs a, char *v, char *w) { if (is_equal_chs(a, zero_chs)) return 1; - if (heads && aa.h >= heads) { - warn("%s of partition %s has impossible value for head: " - "%d (should be in 0-%d)\n", w, v, aa.h, heads-1); + if (B.heads && aa.h >= B.heads) { + warn(_("%s of partition %s has impossible value for head: " + "%d (should be in 0-%d)\n"), w, v, aa.h, B.heads-1); ret = 0; } - if (sectors && (aa.s == 0 || aa.s > sectors)) { - warn("%s of partition %s has impossible value for sector: " - "%d (should be in 1-%d)\n", w, v, aa.s, sectors); + if (B.sectors && (aa.s == 0 || aa.s > B.sectors)) { + warn(_("%s of partition %s has impossible value for sector: " + "%d (should be in 1-%d)\n"), w, v, aa.s, B.sectors); ret = 0; } - if (cylinders && aa.c >= cylinders) { - warn("%s of partition %s has impossible value for cylinders: " - "%d (should be in 0-%d)\n", w, v, aa.c, cylinders-1); + if (B.cylinders && aa.c >= B.cylinders) { + warn(_("%s of partition %s has impossible value for cylinders: " + "%d (should be in 0-%d)\n"), w, v, aa.c, B.cylinders-1); ret = 0; } return ret; @@ -533,109 +548,25 @@ chs_ok (chs a, char *v, char *w) { #define LINUX_EXTENDED 0x85 #define BSD_PARTITION 0xa5 -/* - * List of system Id's, adapted from fdisk 2.0d and <linux/genhd.h> - * and SFS and several other sources. - */ -struct systypes { - unsigned char type; - char *name; -} sys_types[] = { - {0, "Empty"}, - {1, "DOS 12-bit FAT"}, /* Primary DOS with 12-bit FAT */ - {2, "XENIX /"}, /* XENIX / filesystem */ - {3, "XENIX /usr"}, /* XENIX /usr filesystem */ - {4, "DOS 16-bit FAT <32M"}, /* Primary DOS with 16-bit FAT */ - {5, "DOS Extended"}, /* DOS 3.3+ extended partition */ - {6, "DOS 16-bit FAT >=32M"}, - {7, "HPFS / NTFS"}, - {8, "AIX boot or SplitDrive"}, - {9, "AIX data or Coherent"}, - {0x0a, "OS/2 Boot Manager"}, - {0x0b, "Win95 FAT32"}, - {0x0c, "Win95 FAT32 (LBA)"}, - {0x0e, "Win95 FAT16 (LBA)"}, - {0x0f, "Win95 Extended (LBA)"}, - {0x10, "OPUS"}, - {0x11, "Hidden DOS FAT12"}, - {0x12, "Compaq diagnostics"}, - {0x14, "Hidden DOS FAT16"}, - {0x16, "Hidden DOS FAT16 (big)"}, - {0x17, "Hidden HPFS/NTFS"}, - {0x18, "AST Windows swapfile"}, - {0x24, "NEC DOS"}, - {0x3c, "PartitionMagic recovery"}, - {0x40, "Venix 80286"}, - {0x41, "Linux/MINIX (sharing disk with DRDOS)"}, - {0x42, "SFS or Linux swap (sharing disk with DRDOS)"}, - {0x43, "Linux native (sharing disk with DRDOS)"}, - {0x50, "DM (disk manager)"}, - {0x51, "DM6 Aux1 (or Novell)"}, - {0x52, "CP/M or Microport SysV/AT"}, - {0x53, "DM6 Aux3"}, - {0x54, "DM6"}, - {0x55, "EZ-Drive (disk manager)"}, - {0x56, "Golden Bow (disk manager)"}, - {0x5c, "Priam Edisk (disk manager)"}, - {0x61, "SpeedStor"}, - {0x63, "GNU HURD or Mach or Sys V/386 (such as ISC UNIX)"}, - {0x64, "Novell Netware 286"}, - {0x65, "Novell Netware 386"}, - {0x70, "DiskSecure Multi-Boot"}, - {0x75, "PC/IX"}, - {0x77, "QNX4.x"}, - {0x78, "QNX4.x 2nd part"}, - {0x79, "QNX4.x 3rd part"}, - {0x80, "MINIX until 1.4a"}, - {0x81, "MINIX / old Linux"}, - {0x82, "Linux swap"}, - {0x83, "Linux native"}, - {0x84, "OS/2 hidden C: drive"}, - {0x85, "Linux extended"}, - {0x86, "NTFS volume set"}, - {0x87, "NTFS volume set"}, - {0x93, "Amoeba"}, - {0x94, "Amoeba BBT"}, /* (bad block table) */ - {0xa0, "IBM Thinkpad hibernation"}, /* according to dan@fch.wimsey.bc.ca */ - {0xa5, "BSD/386"}, /* 386BSD */ - {0xa6, "OpenBSD"}, - {0xa7, "NeXTSTEP 486"}, - {0xb7, "BSDI fs"}, - {0xb8, "BSDI swap"}, - {0xc1, "DRDOS/sec (FAT-12)"}, - {0xc4, "DRDOS/sec (FAT-16, < 32M)"}, - {0xc6, "DRDOS/sec (FAT-16, >= 32M)"}, - {0xc7, "Syrinx"}, - {0xdb, "CP/M or Concurrent CP/M or Concurrent DOS or CTOS"}, - {0xe1, "DOS access or SpeedStor 12-bit FAT extended partition"}, - {0xe3, "DOS R/O or SpeedStor"}, - {0xe4, "SpeedStor 16-bit FAT extended partition < 1024 cyl."}, - {0xeb, "BeOS fs"}, - {0xf1, "SpeedStor"}, - {0xf2, "DOS 3.3+ secondary"}, - {0xf4, "SpeedStor large partition"}, - {0xfe, "SpeedStor >1024 cyl. or LANstep"}, - {0xff, "Xenix Bad Block Table"} -}; - +/* List of partition types now in i386_sys_types.c */ const char * sysname(unsigned char type) { struct systypes *s; - for (s = sys_types; s - sys_types < SIZE(sys_types); s++) + for (s = i386_sys_types; s->name; s++) if (s->type == type) - return s->name; - return "Unknown"; + return _(s->name); + return _("Unknown"); } void list_types(void) { struct systypes *s; - printf("Id Name\n\n"); - for (s = sys_types; s - sys_types < SIZE(sys_types); s++) - printf("%2x %s\n", s->type, s->name); + printf(_("Id Name\n\n")); + for (s = i386_sys_types; s->name; s++) + printf("%2x %s\n", s->type, _(s->name)); } int @@ -767,7 +698,8 @@ add_sector_and_offset(struct disk_desc *z) { } /* tell the kernel to reread the partition tables */ -int reread_ioctl(int fd) { +int +reread_ioctl(int fd) { if(ioctl(fd, BLKRRPART)) { perror("BLKRRPART"); return -1; @@ -775,21 +707,28 @@ int reread_ioctl(int fd) { return 0; } +int +is_blockdev(int fd) { + struct stat statbuf; + + return(fstat(fd, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)); +} + /* reread after writing */ void reread_disk_partition(char *dev, int fd) { - printf("Re-reading the partition table ...\n"); + printf(_("Re-reading the partition table ...\n")); fflush(stdout); sync(); sleep(3); /* superfluous since 1.3.20 */ - if(reread_ioctl(fd)) - printf("The command to re-read the partition table failed\n" - "Reboot your system now, before using mkfs\n"); + if(reread_ioctl(fd) && is_blockdev(fd)) + printf(_("The command to re-read the partition table failed\n" + "Reboot your system now, before using mkfs\n")); if (close(fd)) { perror(dev); - printf("Error closing %s\n", dev); + printf(_("Error closing %s\n"), dev); } printf("\n"); } @@ -827,7 +766,7 @@ asc_to_index(char *pnam, struct disk_desc *z) { pno = linux_to_index(pnum, z); } if (!(pno >= 0 && pno < z->partno)) - fatal("%s: no such partition\n", pnam); + fatal(_("%s: no such partition\n"), pnam); return pno; } @@ -850,7 +789,7 @@ void set_format(char c) { switch(c) { default: - printf("unrecognized format - using sectors\n"); + printf(_("unrecognized format - using sectors\n")); case 'S': specified_format = F_SECTOR; break; case 'B': specified_format = F_BLOCK; break; case 'C': specified_format = F_CYLINDER; break; @@ -860,14 +799,15 @@ set_format(char c) { unsigned long unitsize(int format) { - default_format = (cylindersize ? F_CYLINDER : F_MEGABYTE); + default_format = (B.cylindersize ? F_CYLINDER : F_MEGABYTE); if (!format && !(format = specified_format)) format = default_format; switch(format) { default: case F_CYLINDER: - if(cylindersize) return cylindersize; + if(B.cylindersize) + return B.cylindersize; case F_SECTOR: return 1; case F_BLOCK: @@ -879,51 +819,51 @@ unitsize(int format) { unsigned long get_disksize(int format) { - unsigned long cs = cylinders; + unsigned long cs = B.cylinders; if (cs && leave_last) cs--; - return (cs * cylindersize) / unitsize(format); + return (cs * B.cylindersize) / unitsize(format); } void -out_partition_header(char *dev, int format) { +out_partition_header(char *dev, int format, struct geometry G) { if (dump) { - printf("# partition table of %s\n", dev); - printf("unit: sectors\n\n"); + printf(_("# partition table of %s\n"), dev); + printf(_("unit: sectors\n\n")); return; } - default_format = (cylindersize ? F_CYLINDER : F_MEGABYTE); + default_format = (G.cylindersize ? F_CYLINDER : F_MEGABYTE); if (!format && !(format = specified_format)) format = default_format; switch(format) { default: - printf("unimplemented format - using %s\n", - cylindersize ? "cylinders" : "sectors"); + printf(_("unimplemented format - using %s\n"), + G.cylindersize ? _("cylinders") : _("sectors")); case F_CYLINDER: - if (cylindersize) { - printf("Units = cylinders of %lu bytes, blocks of 1024 bytes" - ", counting from %d\n\n", - cylindersize<<9, increment); - printf(" Device Boot Start End #cyls #blocks Id System\n"); + if (G.cylindersize) { + printf(_("Units = cylinders of %lu bytes, blocks of 1024 bytes" + ", counting from %d\n\n"), + G.cylindersize<<9, increment); + printf(_(" Device Boot Start End #cyls #blocks Id System\n")); break; } /* fall through */ case F_SECTOR: - printf("Units = sectors of 512 bytes, counting from %d\n\n", + printf(_("Units = sectors of 512 bytes, counting from %d\n\n"), increment); - printf(" Device Boot Start End #sectors Id System\n"); + printf(_(" Device Boot Start End #sectors Id System\n")); break; case F_BLOCK: - printf("Units = blocks of 1024 bytes, counting from %d\n\n", + printf(_("Units = blocks of 1024 bytes, counting from %d\n\n"), increment); - printf(" Device Boot Start End #blocks Id System\n"); + printf(_(" Device Boot Start End #blocks Id System\n")); break; case F_MEGABYTE: - printf("Units = megabytes of 1048576 bytes, blocks of 1024 bytes" - ", counting from %d\n\n", increment); - printf(" Device Boot Start End MB #blocks Id System\n"); + printf(_("Units = megabytes of 1048576 bytes, blocks of 1024 bytes" + ", counting from %d\n\n"), increment); + printf(_(" Device Boot Start End MB #blocks Id System\n")); break; } } @@ -955,8 +895,19 @@ out_roundup_size(int width, unsigned long n, unsigned long unit) { putchar(' '); } +int +get_fdisk_geometry(struct part_desc *p) { + chs b = p->p.end_chs; + longchs bb = chs_to_longchs(b); + F.heads = bb.h+1; + F.sectors = bb.s; + F.cylindersize = F.heads*F.sectors; + return (F.sectors != B.sectors || F.heads != B.heads); +} + void -out_partition(char *dev, int format, struct part_desc *p, struct disk_desc *z) { +out_partition(char *dev, int format, struct part_desc *p, + struct disk_desc *z, struct geometry G) { unsigned long start, end, size; int pno, lpno; @@ -978,12 +929,12 @@ out_partition(char *dev, int format, struct part_desc *p, struct disk_desc *z) { size = p->size; if (dump) { - printf(" start=%9lu", start); - printf(", size=%8lu", size); + printf(_(" start=%9lu"), start); + printf(_(", size=%8lu"), size); if (p->ptype == DOS_TYPE) { - printf(", Id=%2x", p->p.sys_type); + printf(_(", Id=%2x"), p->p.sys_type); if (p->p.bootable == 0x80) - printf(", bootable"); + printf(_(", bootable")); } printf("\n"); return; @@ -998,10 +949,10 @@ out_partition(char *dev, int format, struct part_desc *p, struct disk_desc *z) { switch(format) { case F_CYLINDER: - if (cylindersize) { - out_rounddown(6, start, cylindersize, increment); - out_roundup(6, end, cylindersize, increment); - out_roundup_size(6, size, cylindersize); + if (G.cylindersize) { + out_rounddown(6, start, G.cylindersize, increment); + out_roundup(6, end, G.cylindersize, increment); + out_roundup_size(6, size, G.cylindersize); out_rounddown(8, size, 2, 0); break; } @@ -1039,22 +990,22 @@ out_partition(char *dev, int format, struct part_desc *p, struct disk_desc *z) { if (!quiet && p->ptype == DOS_TYPE) { chs a, b; longchs aa, bb; - a = (size ? ulong_to_chs(start) : zero_chs); + a = (size ? ulong_to_chs(start,G) : zero_chs); b = p->p.begin_chs; aa = chs_to_longchs(a); bb = chs_to_longchs(b); if(a.s && !is_equal_chs(a, b)) - printf("\t\tstart: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n", + printf(_("\t\tstart: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"), aa.c, aa.h, aa.s, bb.c, bb.h, bb.s); - a = (size ? ulong_to_chs(end) : zero_chs); + a = (size ? ulong_to_chs(end,G) : zero_chs); b = p->p.end_chs; aa = chs_to_longchs(a); bb = chs_to_longchs(b); if(a.s && !is_equal_chs(a, b)) - printf("\t\tend: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n", + printf(_("\t\tend: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"), aa.c, aa.h, aa.s, bb.c, bb.h, bb.s); - if(cylinders && cylinders < 1024 && bb.c > cylinders) - printf("partition ends on cylinder %ld, beyond the end of the disk\n", + if(G.cylinders && G.cylinders < 1024 && bb.c > G.cylinders) + printf(_("partition ends on cylinder %ld, beyond the end of the disk\n"), bb.c); } } @@ -1064,11 +1015,16 @@ out_partitions(char *dev, struct disk_desc *z) { int pno, format = 0; if (z->partno == 0) - printf("No partitions found\n"); + printf(_("No partitions found\n")); else { - out_partition_header(dev, format); + if (get_fdisk_geometry(&(z->partitions[0]))) + printf(_("Warning: The first partition looks like it was made\n" + " for C/H/S=*/%ld/%ld (instead of %ld/%ld/%ld).\n" + "For this listing I'll assume that geometry.\n"), + F.heads, F.sectors, B.cylinders, B.heads, B.sectors); + out_partition_header(dev, format, F); for(pno=0; pno < z->partno; pno++) { - out_partition(dev, format, &(z->partitions[pno]), z); + out_partition(dev, format, &(z->partitions[pno]), z, F); if(show_extended && pno%4==3) printf("\n"); } @@ -1109,9 +1065,9 @@ partitions_ok(struct disk_desc *z) { /* Have at least 4 partitions been defined? */ if (partno < 4) { if (!partno) - fatal("no partition table present.\n"); + fatal(_("no partition table present.\n")); else - fatal("strange, only %d partitions defined.\n", partno); + fatal(_("strange, only %d partitions defined.\n"), partno); return 0; } @@ -1120,13 +1076,13 @@ partitions_ok(struct disk_desc *z) { for (p = partitions; p - partitions < partno; p++) if (p->size == 0) { if(p->p.sys_type != EMPTY_PARTITION) - warn("Warning: partition %s has size 0 but is not marked Empty\n", + warn(_("Warning: partition %s has size 0 but is not marked Empty\n"), PNO(p)); else if(p->p.bootable != 0) - warn("Warning: partition %s has size 0 and is bootable\n", + warn(_("Warning: partition %s has size 0 and is bootable\n"), PNO(p)); else if(p->p.start_sect != 0) - warn("Warning: partition %s has size 0 and nonzero start\n", + warn(_("Warning: partition %s has size 0 and nonzero start\n"), PNO(p)); /* all this is probably harmless, no error return */ } @@ -1137,8 +1093,8 @@ partitions_ok(struct disk_desc *z) { if (p->size && !is_extended(p->p.sys_type)) { q = p->ep; if (p->start < q->start || p->start + p->size > q->start + q->size) { - warn("Warning: partition %s ", PNO(p)); - warn("is not contained in partition %s\n", PNO(q)); + warn(_("Warning: partition %s "), PNO(p)); + warn(_("is not contained in partition %s\n"), PNO(q)); return 0; } } @@ -1149,8 +1105,8 @@ partitions_ok(struct disk_desc *z) { for (q = p+1; q < partitions+partno; q++) if (q->size && !is_extended(q->p.sys_type)) if(!((p->start > q-> start) ? disj(q,p) : disj(p,q))) { - warn("Warning: partitions %s ", PNO(p)); - warn("and %s overlap\n", PNO(q)); + warn(_("Warning: partitions %s "), PNO(p)); + warn(_("and %s overlap\n"), PNO(q)); return 0; } @@ -1161,9 +1117,9 @@ partitions_ok(struct disk_desc *z) { for (q = partitions; q < partitions+partno; q++) if (is_extended(q->p.sys_type)) if (p->start <= q->start && p->start + p->size > q->start) { - warn("Warning: partition %s contains part of ", PNO(p)); - warn("the partition table (sector %lu),\n", q->start); - warn("and will destroy it when filled\n"); + warn(_("Warning: partition %s contains part of "), PNO(p)); + warn(_("the partition table (sector %lu),\n"), q->start); + warn(_("and will destroy it when filled\n")); return 0; } @@ -1172,11 +1128,11 @@ partitions_ok(struct disk_desc *z) { for (p = partitions; p < partitions+partno; p++) if (p->size) { if(p->start == 0) { - warn("Warning: partition %s starts at sector 0\n", PNO(p)); + warn(_("Warning: partition %s starts at sector 0\n"), PNO(p)); return 0; } if (p->size && p->start + p->size > ds) { - warn("Warning: partition %s extends past end of disk\n", PNO(p)); + warn(_("Warning: partition %s extends past end of disk\n"), PNO(p)); return 0; } } @@ -1190,8 +1146,8 @@ partitions_ok(struct disk_desc *z) { if (p->p.sys_type == EXTENDED_PARTITION) ect++; if (ect > 1 && !Linux) { - warn("Among the primary partitions, at most one can be extended\n"); - warn(" (although this is not a problem under Linux)\n"); + warn(_("Among the primary partitions, at most one can be extended\n")); + warn(_(" (although this is not a problem under Linux)\n")); return 0; } } @@ -1202,20 +1158,20 @@ partitions_ok(struct disk_desc *z) { * The first partition starts after MBR. * Logical partitions start slightly after the containing extended partn. */ - if (cylindersize) { + if (B.cylindersize) { for(p = partitions; p < partitions+partno; p++) if (p->size) { - if(p->start % cylindersize != 0 - && (!p->ep || p->start / cylindersize != p->ep->start / cylindersize) - && (p->p.start_sect >= cylindersize)) { - warn("Warning: partition %s does not start " - "at a cylinder boundary\n", PNO(p)); + if(p->start % B.cylindersize != 0 + && (!p->ep || p->start / B.cylindersize != p->ep->start / B.cylindersize) + && (p->p.start_sect >= B.cylindersize)) { + warn(_("Warning: partition %s does not start " + "at a cylinder boundary\n"), PNO(p)); if (!Linux) return 0; } - if((p->start + p->size) % cylindersize) { - warn("Warning: partition %s does not end " - "at a cylinder boundary\n", PNO(p)); + if((p->start + p->size) % B.cylindersize) { + warn(_("Warning: partition %s does not end " + "at a cylinder boundary\n"), PNO(p)); if (!Linux) return 0; } @@ -1232,22 +1188,22 @@ partitions_ok(struct disk_desc *z) { if (pno == -1) pno = p - partitions; else if (p - partitions < 4) { - warn("Warning: more than one primary partition is marked " + warn(_("Warning: more than one primary partition is marked " "bootable (active)\n" "This does not matter for LILO, but the DOS MBR will " - "not boot this disk.\n"); + "not boot this disk.\n")); break; } if (p - partitions >= 4) { - warn("Warning: usually one can boot from primary partitions " - "only\n" "LILO disregards the `bootable' flag.\n"); + warn(_("Warning: usually one can boot from primary partitions " + "only\nLILO disregards the `bootable' flag.\n")); break; } } if (pno == -1 || pno >= 4) - warn("Warning: no primary partition is marked bootable (active)\n" + warn(_("Warning: no primary partition is marked bootable (active)\n" "This does not matter for LILO, but the DOS MBR will " - "not boot this disk.\n"); + "not boot this disk.\n")); } /* Is chs as we expect? */ @@ -1255,26 +1211,26 @@ partitions_ok(struct disk_desc *z) { if(p->ptype == DOS_TYPE) { chs a, b; longchs aa, bb; - a = p->size ? ulong_to_chs(p->start) : zero_chs; + a = p->size ? ulong_to_chs(p->start,B) : zero_chs; b = p->p.begin_chs; aa = chs_to_longchs(a); bb = chs_to_longchs(b); if (!chs_ok(b, PNO(p), "start")) return 0; if(a.s && !is_equal_chs(a, b)) - warn("partition %s: start: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n", + warn(_("partition %s: start: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"), PNO(p), aa.c, aa.h, aa.s, bb.c, bb.h, bb.s); - a = p->size ? ulong_to_chs(p->start + p->size - 1) : zero_chs; + a = p->size ? ulong_to_chs(p->start + p->size - 1, B) : zero_chs; b = p->p.end_chs; aa = chs_to_longchs(a); bb = chs_to_longchs(b); if (!chs_ok(b, PNO(p), "end")) return 0; if(a.s && !is_equal_chs(a, b)) - warn("partition %s: end: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n", + warn(_("partition %s: end: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"), PNO(p), aa.c, aa.h, aa.s, bb.c, bb.h, bb.s); - if(cylinders && cylinders < 1024 && bb.c > cylinders) - warn("partition %s ends on cylinder %ld, beyond the end of the disk\n", + if(B.cylinders && B.cylinders < 1024 && bb.c > B.cylinders) + warn(_("partition %s ends on cylinder %ld, beyond the end of the disk\n"), PNO(p), bb.c); } @@ -1307,7 +1263,7 @@ extended_partition(char *dev, int fd, struct part_desc *ep, struct disk_desc *z) cp = s->data + 0x1be; if (pno+4 >= SIZE(z->partitions)) { - printf("too many partitions - ignoring those past nr (%d)\n", + printf(_("too many partitions - ignoring those past nr (%d)\n"), pno-1); break; } @@ -1320,9 +1276,11 @@ extended_partition(char *dev, int fd, struct part_desc *ep, struct disk_desc *z) partitions[pno].ep = ep; copy_to_part(cp,&p); if (is_extended(p.sys_type)) { + partitions[pno].start = start + p.start_sect; if (next) - printf("tree of partitions?\n"); - partitions[pno].start = next = start + p.start_sect; + printf(_("tree of partitions?\n")); + else + next = partitions[pno].start; /* follow `upper' branch */ moretodo = 1; } else { partitions[pno].start = here + p.start_sect; @@ -1382,8 +1340,8 @@ bsd_partition(char *dev, int fd, struct part_desc *ep, struct disk_desc *z) { bp = bp0 = &l->d_partitions[0]; while (bp - bp0 <= BSD_MAXPARTITIONS) { if (pno+1 >= SIZE(z->partitions)) { - printf("too many partitions - ignoring those " - "past nr (%d)\n", pno-1); + printf(_("too many partitions - ignoring those " + "past nr (%d)\n"), pno-1); break; } if (bp->p_fstype != BSD_FS_UNUSED) { @@ -1424,14 +1382,14 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) { || pt.sys_type == EZD_PARTITION || pt.sys_type == DM6_AUX1PARTITION || pt.sys_type == DM6_AUX3PARTITION) { - printf("detected Disk Manager - unable to handle that\n"); + printf(_("detected Disk Manager - unable to handle that\n")); return 0; } { unsigned int sig = *(unsigned short *)(s->data + 2); if (sig <= 0x1ae && *(unsigned short *)(s->data + sig) == 0x55aa && (1 & *(unsigned char *)(s->data + sig + 2))) { - printf("DM6 signature found - giving up\n"); + printf(_("DM6 signature found - giving up\n")); return 0; } } @@ -1451,14 +1409,14 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) { for (i=0; i<4; i++) { if (is_extended(partitions[i].p.sys_type)) { if (!partitions[i].size) { - printf("strange..., an extended partition of size 0?\n"); + printf(_("strange..., an extended partition of size 0?\n")); continue; } extended_partition(dev, fd, &partitions[i], z); } if (is_bsd(partitions[i].p.sys_type)) { if (!partitions[i].size) { - printf("strange..., a BSD partition of size 0?\n"); + printf(_("strange..., a BSD partition of size 0?\n")); continue; } bsd_partition(dev, fd, &partitions[i], z); @@ -1490,7 +1448,7 @@ get_partitions(char *dev, int fd, struct disk_desc *z) { && !osf_partition(dev, fd, 0, z) && !sun_partition(dev, fd, 0, z) && !amiga_partition(dev, fd, 0, z)) { - printf(" %s: unrecognized partition\n", dev); + printf(_(" %s: unrecognized partition\n"), dev); return; } } @@ -1502,7 +1460,7 @@ write_partitions(char *dev, int fd, struct disk_desc *z) { int pno = z->partno; if (no_write) { - printf("-n flag was given: Nothing changed\n"); + printf(_("-n flag was given: Nothing changed\n")); exit(0); } @@ -1515,12 +1473,12 @@ write_partitions(char *dev, int fd, struct disk_desc *z) { } if (save_sector_file) { if (!save_sectors(dev, fd)) { - fatal("Failed saving the old sectors - aborting\n"); + fatal(_("Failed saving the old sectors - aborting\n")); return 0; } } if (!write_sectors(dev, fd)) { - error("Failed writing the partition on %s\n", dev); + error(_("Failed writing the partition on %s\n"), dev); return 0; } return 1; @@ -1597,7 +1555,7 @@ read_stdin(unsigned char **fields, unsigned char *line, int fieldssize, int line return RD_EOF; } if (!(lp = index(lp, '\n'))) - fatal("long or incomplete input line - quitting\n"); + fatal(_("long or incomplete input line - quitting\n")); *lp = 0; /* remove comments, if any */ @@ -1633,20 +1591,20 @@ read_stdin(unsigned char **fields, unsigned char *line, int fieldssize, int line while(isalnum(*ip)) /* 0x07FF */ ip++; } else - fatal("input error: `=' expected after %s field\n", + fatal(_("input error: `=' expected after %s field\n"), d->fldname); if (fno <= d->fldno) fno = d->fldno + 1; if(*ip == 0) return fno; if(*ip != ',' && *ip != ';') - fatal("input error: unexpected character %c after %s field\n", + fatal(_("input error: unexpected character %c after %s field\n"), *ip, d->fldname); *ip = 0; goto nxtfld; } } - fatal("unrecognized input: %s\n", ip); + fatal(_("unrecognized input: %s\n"), ip); } /* split line into fields */ @@ -1678,11 +1636,11 @@ get_ul(char *u, unsigned long *up, unsigned long def, int base) { errno = 0; *up = strtoul(u, &nu, base); if (errno == ERANGE) { - printf("number too big\n"); + printf(_("number too big\n")); return -1; } if (*nu) { - printf("trailing junk after number\n"); + printf(_("trailing junk after number\n")); return -1; } } else @@ -1783,7 +1741,7 @@ max_length(int pno, int is_extended, struct part_desc *ep, int format, int compute_start_sect(struct part_desc *p, struct part_desc *ep) { unsigned long base; - int inc = (DOS && sectors) ? sectors : 1; + int inc = (DOS && B.sectors) ? B.sectors : 1; int delta; if (ep && p->start + p->size >= ep->start + 1) @@ -1798,7 +1756,7 @@ compute_start_sect(struct part_desc *p, struct part_desc *ep) { if (is_extended(p->p.sys_type) && boxes == ONESECTOR) p->size = inc; else if ((int)(p->size) <= 0) { - warn("no room for partition descriptor\n"); + warn(_("no room for partition descriptor\n")); return 0; } } @@ -1812,8 +1770,8 @@ compute_start_sect(struct part_desc *p, struct part_desc *ep) { p->p.end_chs = zero_chs; } else { p->p.start_sect = p->start - base; - p->p.begin_chs = ulong_to_chs(p->start); - p->p.end_chs = ulong_to_chs(p->start + p->size - 1); + p->p.begin_chs = ulong_to_chs(p->start,B); + p->p.end_chs = ulong_to_chs(p->start + p->size - 1,B); } p->p.nr_sects = p->size; return 1; @@ -1823,7 +1781,7 @@ compute_start_sect(struct part_desc *p, struct part_desc *ep) { int build_surrounding_extended(struct part_desc *p, struct part_desc *ep, struct disk_desc *z) { - int inc = (DOS && sectors) ? sectors : 1; + int inc = (DOS && B.sectors) ? B.sectors : 1; int format = F_SECTOR; struct part_desc *p0 = &(z->partitions[0]), *eep = ep->ep; @@ -1831,7 +1789,7 @@ build_surrounding_extended(struct part_desc *p, struct part_desc *ep, ep->start = first_free(ep-p0, 1, eep, format, p->start, z); ep->size = max_length(ep-p0, 1, eep, format, ep->start, z); if (ep->start > p->start || ep->start + ep->size < p->start + p->size) { - warn("cannot build surrounding extended partition\n"); + warn(_("cannot build surrounding extended partition\n")); return 0; } } else { @@ -1882,7 +1840,7 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive, if (fno == RD_EOF) { return -1; } else if (fno > 10 && *(fields[10]) != 0) { - printf("too many input fields\n"); + printf(_("too many input fields\n")); return 0; } @@ -1893,7 +1851,7 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive, /* use specified format, but round to cylinders if F_MEGABYTE specified */ format = 0; - if (cylindersize && specified_format == F_MEGABYTE) + if (B.cylindersize && specified_format == F_MEGABYTE) format = F_CYLINDER; orig = (one_only ? &(oldp.partitions[pno]) : 0); @@ -1916,7 +1874,7 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive, } if (ml == 0 && pno >= 4) { /* no free blocks left - don't read any further */ - warn("No room for more\n"); + warn(_("No room for more\n")); return -1; } } @@ -1935,7 +1893,7 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive, else if (get_ul(fields[2], &ul, LINUX_NATIVE, 16)) return 0; if (ul > 255) { - warn("Illegal type\n"); + warn(_("Illegal type\n")); return 0; } p.p.sys_type = ul; @@ -1967,12 +1925,12 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive, p.size -= (p.size % unitsize(format)); } if (p.size > ml1) { - warn("Warning: exceeds max allowable size (%lu)\n", ml1 / unitsize(0)); + warn(_("Warning: exceeds max allowable size (%lu)\n"), ml1 / unitsize(0)); if (!force) return 0; } if (p.size == 0 && pno >= 4 && (fno < 2 || !*(fields[1]))) { - warn("Warning: empty partition\n"); + warn(_("Warning: empty partition\n")); if (!force) return 0; } @@ -1986,7 +1944,7 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive, } if (p.start < ff1 && p.size > 0) { - warn("Warning: bad partition start (earliest %lu)\n", + warn(_("Warning: bad partition start (earliest %lu)\n"), (ff1 + unitsize(0) - 1) / unitsize(0)); if (!force) return 0; @@ -1999,7 +1957,7 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive, else if (!strcmp(fields[3], "*") || !strcmp(fields[3], "+")) ul = 0x80; else { - warn("unrecognized bootable flag - choose - or *\n"); + warn(_("unrecognized bootable flag - choose - or *\n")); return 0; } p.p.bootable = ul; @@ -2016,31 +1974,31 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive, if (fno < 5) { bb = aa; } else if (fno < 7) { - warn("partial c,h,s specification?\n"); + warn(_("partial c,h,s specification?\n")); return 0; } else if(get_ul(fields[4], &bb.c, aa.c, 0) || get_ul(fields[5], &bb.h, aa.h, 0) || get_ul(fields[6], &bb.s, aa.s, 0)) return 0; - p.p.begin_chs = longchs_to_chs(bb); + p.p.begin_chs = longchs_to_chs(bb,B); } { longchs aa = chs_to_longchs(p.p.end_chs), bb; if (fno < 8) { bb = aa; } else if (fno < 10) { - warn("partial c,h,s specification?\n"); + warn(_("partial c,h,s specification?\n")); return 0; } else if(get_ul(fields[7], &bb.c, aa.c, 0) || get_ul(fields[8], &bb.h, aa.h, 0) || get_ul(fields[9], &bb.s, aa.s, 0)) return 0; - p.p.end_chs = longchs_to_chs(bb); + p.p.end_chs = longchs_to_chs(bb, B); } if (pno > 3 && p.size && show_extended && p.p.sys_type != EMPTY_PARTITION && (is_extended(p.p.sys_type) != (pct == 1))) { - warn("Extended partition not where expected\n"); + warn(_("Extended partition not where expected\n")); if (!force) return 0; } @@ -2050,7 +2008,7 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive, z->partno += 4; /* reqd for out_partition() */ if (interactive) - out_partition(dev, 0, &(z->partitions[pno]), z); + out_partition(dev, 0, &(z->partitions[pno]), z, B); return 1; } @@ -2072,7 +2030,7 @@ read_partition(char *dev, int interactive, int pno, struct part_desc *ep, while (!(i = read_line(pno, ep, dev, interactive, z))) if (!interactive) - fatal("bad input\n"); + fatal(_("bad input\n")); if (i < 0) { p->ep = ep; return 0; @@ -2094,7 +2052,7 @@ read_partition_chain(char *dev, int interactive, struct part_desc *ep, while (1) { base = z->partno; if (base+4 > SIZE(z->partitions)) { - printf("too many partitions\n"); + printf(_("too many partitions\n")); break; } for (i=0; i<4; i++) @@ -2127,11 +2085,9 @@ read_input(char *dev, int interactive, struct disk_desc *z) { z->partno = 0; if (interactive) - warn(" -Input in the following format; absent fields get a default value. -<start> <size> <type [E,S,L,X,hex]> <bootable [-,*]> <c,h,s> <c,h,s> -Usually you only need to specify <start> and <size> (and perhaps <type>). -"); + warn(_("Input in the following format; absent fields get a default value.\n" + "<start> <size> <type [E,S,L,X,hex]> <bootable [-,*]> <c,h,s> <c,h,s>\n" + "Usually you only need to specify <start> and <size> (and perhaps <type>).\n")); eof = 0; for (i=0; i<4; i++) @@ -2149,54 +2105,51 @@ Usually you only need to specify <start> and <size> (and perhaps <type>). */ static void version(void) { - printf(PROGNAME " version " VERSION " (aeb@cwi.nl, " DATE ")\n"); + printf("%s %s %s (aeb@cwi.nl, %s)\n", PROGNAME, _("version"), VERSION, DATE); } static void usage(void) { version(); - printf("Usage: - " PROGNAME " [options] device ... -device: something like /dev/hda or /dev/sda -useful options: - -s [or --show-size]: list size of a partition - -c [or --id]: print or change partition Id - -l [or --list]: list partitions of each device - -d [or --dump]: idem, but in a format suitable for later input - -i [or --increment]: number cylinders etc. from 1 instead of from 0 - -uS, -uB, -uC, -uM: accept/report in units of sectors/blocks/cylinders/MB - -T [or --list-types]:list the known partition types - -D [or --DOS]: for DOS-compatibility: waste a little space - -R [or --re-read]: make kernel reread partition table - -N# : change only the partition with number # - -n : do not actually write to disk - -O file : save the sectors that will be overwritten to file - -I file : restore these sectors again - -v [or --version]: print version - -? [or --help]: print this message -dangerous options: - -g [or --show-geometry]: print the kernel's idea of the geometry - -x [or --show-extended]: also list extended partitions on output - or expect descriptors for them on input - -L [or --Linux]: do not complain about things irrelevant for Linux - -q [or --quiet]: suppress warning messages - You can override the detected geometry using: - -C# [or --cylinders #]:set the number of cylinders to use - -H# [or --heads #]: set the number of heads to use - -S# [or --sectors #]: set the number of sectors to use - You can disable all consistency checking with: - -f [or --force]: do what I say, even if it is stupid -"); + printf(_("Usage: %s [options] device ...\n"), PROGNAME); + puts (_("device: something like /dev/hda or /dev/sda")); + puts (_("useful options:")); + puts (_(" -s [or --show-size]: list size of a partition")); + puts (_(" -c [or --id]: print or change partition Id")); + puts (_(" -l [or --list]: list partitions of each device")); + puts (_(" -d [or --dump]: idem, but in a format suitable for later input")); + puts (_(" -i [or --increment]: number cylinders etc. from 1 instead of from 0")); + puts (_(" -uS, -uB, -uC, -uM: accept/report in units of sectors/blocks/cylinders/MB")); + puts (_(" -T [or --list-types]:list the known partition types")); + puts (_(" -D [or --DOS]: for DOS-compatibility: waste a little space")); + puts (_(" -R [or --re-read]: make kernel reread partition table")); + puts (_(" -N# : change only the partition with number #")); + puts (_(" -n : do not actually write to disk")); + puts (_(" -O file : save the sectors that will be overwritten to file")); + puts (_(" -I file : restore these sectors again")); + puts (_(" -v [or --version]: print version")); + puts (_(" -? [or --help]: print this message")); + puts (_("dangerous options:")); + puts (_(" -g [or --show-geometry]: print the kernel's idea of the geometry")); + puts (_(" -x [or --show-extended]: also list extended partitions on output\n" + " or expect descriptors for them on input")); + puts (_(" -L [or --Linux]: do not complain about things irrelevant for Linux")); + puts (_(" -q [or --quiet]: suppress warning messages")); + puts (_(" You can override the detected geometry using:")); + puts (_(" -C# [or --cylinders #]:set the number of cylinders to use")); + puts (_(" -H# [or --heads #]: set the number of heads to use")); + puts (_(" -S# [or --sectors #]: set the number of sectors to use")); + puts (_("You can disable all consistency checking with:")); + puts (_(" -f [or --force]: do what I say, even if it is stupid")); exit(1); } static void activate_usage(char *progn) { - printf("Usage: - %s device list active partitions on device - %s device n1 n2 ... activate partitions n1 ..., inactivate the rest - %s device activate partition n, inactivate the other ones -", progn, progn, PROGNAME " -An"); + puts (_("Usage:")); + printf(_("%s device list active partitions on device\n"), progn); + printf(_("%s device n1 n2 ... activate partitions n1 ..., inactivate the rest\n"), progn); + printf(_("%s -An device activate partition n, inactivate the other ones\n"), PROGNAME); exit(1); } @@ -2310,8 +2263,12 @@ main(int argc, char **argv) { char *activatearg = 0; char *unhidearg = 0; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + if (argc < 1) - fatal("no command?\n"); + fatal(_("no command?\n")); if ((progn = rindex(argv[0], '/')) == NULL) progn = argv[0]; else @@ -2358,11 +2315,11 @@ main(int argc, char **argv) { activatearg = optarg; activate = 1; break; case 'C': - specified_cylinders = atoi(optarg); break; + U.cylinders = atoi(optarg); break; case 'D': DOS = 1; break; case 'H': - specified_heads = atoi(optarg); break; + U.heads = atoi(optarg); break; case 'L': Linux = 1; break; case 'N': @@ -2374,7 +2331,7 @@ main(int argc, char **argv) { case 'R': opt_reread = 1; break; case 'S': - specified_sectors = atoi(optarg); break; + U.sectors = atoi(optarg); break; case 'T': list_types(); exit(0); @@ -2434,7 +2391,7 @@ main(int argc, char **argv) { } if (opt_size) - printf("total: %d blocks\n", total_size); + printf(_("total: %d blocks\n"), total_size); exit(exit_status); } @@ -2471,18 +2428,18 @@ main(int argc, char **argv) { } if (do_id) { if ((do_id & PRINT_ID) != 0 && optind != argc-2) - fatal("usage: sfdisk --print-id device partition-number\n"); + fatal(_("usage: sfdisk --print-id device partition-number\n")); else if ((do_id & CHANGE_ID) != 0 && optind != argc-3) - fatal("usage: sfdisk --change-id device partition-number Id\n"); + fatal(_("usage: sfdisk --change-id device partition-number Id\n")); else if (optind != argc-3 && optind != argc-2) - fatal("usage: sfdisk --id device partition-number [Id]\n"); + fatal(_("usage: sfdisk --id device partition-number [Id]\n")); do_change_id(argv[optind], argv[optind+1], (optind == argc-2) ? 0 : argv[optind+2]); exit(exit_status); } if (optind != argc-1) - fatal("can specify only one device (except with -l or -s)\n"); + fatal(_("can specify only one device (except with -l or -s)\n")); dev = argv[optind]; if (opt_reread) @@ -2507,7 +2464,7 @@ my_open (char *dev, int rw, int silent) { fd = open(dev, mode); if (fd < 0 && !silent) { perror(dev); - fatal("cannot open %s %s\n", dev, rw ? "read-write" : "for reading"); + fatal(_("cannot open %s %s\n"), dev, rw ? _("read-write") : _("for reading")); } return fd; } @@ -2532,7 +2489,7 @@ do_list (char *dev, int silent) { if (verify) { if (partitions_ok(z)) - warn("%s: OK\n", dev); + warn(_("%s: OK\n"), dev); else exit_status = 1; } @@ -2549,16 +2506,17 @@ do_geom (char *dev, int silent) { /* get_cylindersize(dev, fd, silent); */ if (!ioctl(fd, HDIO_GETGEO, &g)) - printf("%s: %d cylinders, %d heads, %d sectors/track\n", + printf(_("%s: %d cylinders, %d heads, %d sectors/track\n"), dev, g.cylinders, g.heads, g.sectors); else - printf("%s: unknown geometry\n", dev); + printf(_("%s: unknown geometry\n"), dev); } /* for compatibility with earlier fdisk: provide option -s */ void do_size (char *dev, int silent) { - int fd, size; + int fd; + long size; fd = my_open(dev, 0, silent); if (fd < 0) @@ -2567,7 +2525,7 @@ do_size (char *dev, int silent) { if(ioctl(fd, BLKGETSIZE, &size)) { if(!silent) { perror(dev); - fatal("BLKGETSIZE ioctl failed for %s\n", dev); + fatal(_("BLKGETSIZE ioctl failed for %s\n"), dev); } return; } @@ -2579,9 +2537,9 @@ do_size (char *dev, int silent) { return; if (silent) - printf("%s: %9d\n", dev, size); + printf("%s: %9ld\n", dev, size); else - printf("%d\n", size); + printf("%ld\n", size); total_size += size; } @@ -2644,7 +2602,7 @@ do_activate (char **av, int ac, char *arg) { else printf("%s#%d\n", dev, pno); if (z->partitions[pno].p.bootable != 0x80) - warn("bad active byte: 0x%x instead of 0x80\n", + warn(_("bad active byte: 0x%x instead of 0x80\n"), z->partitions[pno].p.bootable); } } @@ -2661,7 +2619,7 @@ do_activate (char **av, int ac, char *arg) { /* then write to disk */ if(write_partitions(dev, fd, z)) - warn("Done\n\n"); + warn(_("Done\n\n")); else exit_status = 1; } @@ -2670,8 +2628,8 @@ do_activate (char **av, int ac, char *arg) { if (z->partitions[pno].p.bootable) i++; if (i != 1) - warn("You have %d active primary partitions. This does not matter for LILO,\n" - "but the DOS MBR will only boot a disk with 1 active partition.\n", i); + warn(_("You have %d active primary partitions. This does not matter for LILO,\n" + "but the DOS MBR will only boot a disk with 1 active partition.\n"), i); } void @@ -2684,7 +2642,7 @@ set_unhidden (struct disk_desc *z, char *pnam) { if (id == 0x11 || id == 0x14 || id == 0x16 || id == 0x17) id -= 0x10; else - fatal("partition %s has id %x and is not hidden\n", pnam, id); + fatal(_("partition %s has id %x and is not hidden\n"), pnam, id); z->partitions[pno].p.sys_type = id; } @@ -2714,7 +2672,7 @@ do_unhide (char **av, int ac, char *arg) { /* then write to disk */ if(write_partitions(dev, fd, z)) - warn("Done\n\n"); + warn(_("Done\n\n")); else exit_status = 1; } @@ -2740,11 +2698,11 @@ void do_change_id(char *dev, char *pnam, char *id) { } i = strtoul(id, NULL, 16); if (i > 255) - fatal("Bad Id %x\n", i); + fatal(_("Bad Id %x\n"), i); z->partitions[pno].p.sys_type = i; if(write_partitions(dev, fd, z)) - warn("Done\n\n"); + warn(_("Done\n\n")); else exit_status = 1; } @@ -2755,7 +2713,7 @@ do_reread(char *dev) { fd = my_open(dev, 0, 0); if(reread_ioctl(fd)) - printf("This disk is currently in use.\n"); + printf(_("This disk is currently in use.\n")); } /* @@ -2772,26 +2730,26 @@ do_fdisk(char *dev){ if (stat(dev, &statbuf) < 0) { perror(dev); - fatal("Fatal error: cannot find %s\n", dev); + fatal(_("Fatal error: cannot find %s\n"), dev); } if (!S_ISBLK(statbuf.st_mode)) { - warn("Warning: %s is not a block device\n", dev); + warn(_("Warning: %s is not a block device\n"), dev); + no_reread = 1; } fd = my_open(dev, !no_write, 0); if(!no_write && !no_reread) { - warn("Checking that no-one is using this disk right now ...\n"); + warn(_("Checking that no-one is using this disk right now ...\n")); if(reread_ioctl(fd)) { - printf(" -This disk is currently in use - repartitioning is probably a bad idea. -Umount all file systems, and swapoff all swap partitions on this disk. -Use the --no-reread flag to suppress this check.\n"); + printf(_("\nThis disk is currently in use - repartitioning is probably a bad idea." + "Umount all file systems, and swapoff all swap partitions on this disk." + "Use the --no-reread flag to suppress this check.\n")); if (!force) { - printf("Use the --force flag to overrule all checks.\n"); + printf(_("Use the --force flag to overrule all checks.\n")); exit(1); } } else - warn("OK"); + warn(_("OK")); } z = &oldp; @@ -2800,11 +2758,11 @@ Use the --no-reread flag to suppress this check.\n"); get_cylindersize(dev, fd, 0); get_partitions(dev, fd, z); - printf("Old situation:\n"); + printf(_("Old situation:\n")); out_partitions(dev, z); if (one_only && (one_only_pno = linux_to_index(one_only, z)) < 0) - fatal("Partition %d does not exist, cannot change it\n", one_only); + fatal(_("Partition %d does not exist, cannot change it\n"), one_only); z = &newp; @@ -2812,35 +2770,35 @@ Use the --no-reread flag to suppress this check.\n"); read_input(dev, interactive, z); - printf("New situation:\n"); + printf(_("New situation:\n")); out_partitions(dev, z); if (!partitions_ok(z) && !force) { if(!interactive) - fatal("I don't like these partitions - nothing changed.\n" - "(If you really want this, use the --force option.)\n"); + fatal(_("I don't like these partitions - nothing changed.\n" + "(If you really want this, use the --force option.)\n")); else - printf("I don't like this - probably you should answer No\n"); + printf(_("I don't like this - probably you should answer No\n")); } ask: if (interactive) { if (no_write) - printf("Are you satisfied with this? [ynq] "); + printf(_("Are you satisfied with this? [ynq] ")); else - printf("Do you want to write this to disk? [ynq] "); + printf(_("Do you want to write this to disk? [ynq] ")); answer = c = getchar(); while (c != '\n' && c != EOF) c = getchar(); if (c == EOF) - printf("\nsfdisk: premature end of input\n"); + printf(_("\nsfdisk: premature end of input\n")); if (c == EOF || answer == 'q' || answer == 'Q') { - fatal("Quitting - nothing changed\n"); + fatal(_("Quitting - nothing changed\n")); } else if (answer == 'n' || answer == 'N') { continue; } else if (answer == 'y' || answer == 'Y') { break; } else { - printf("Please answer one of y,n,q\n"); + printf(_("Please answer one of y,n,q\n")); goto ask; } } else @@ -2848,15 +2806,15 @@ Use the --no-reread flag to suppress this check.\n"); } if(write_partitions(dev, fd, z)) - printf("Successfully wrote the new partition table\n\n"); + printf(_("Successfully wrote the new partition table\n\n")); else exit_status = 1; reread_disk_partition(dev, fd); - warn("If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)\n" + warn(_("If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)\n" "to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1\n" - "(See fdisk(8).)\n"); + "(See fdisk(8).)\n")); sync(); /* superstition */ sleep(3); |