summaryrefslogtreecommitdiffstats
path: root/fdisk/fdisk.c
diff options
context:
space:
mode:
authorFrancesco Cosoleto2011-12-15 20:02:42 +0100
committerKarel Zak2011-12-16 14:04:03 +0100
commit97a2f1b8bac177eb7ccfb21d3f6be9c654fba0c8 (patch)
tree88a690c35a2a14d993f1002fd052e5a042f59a43 /fdisk/fdisk.c
parentfdisk: rename try() and tryprocpt() functions (diff)
downloadkernel-qcow2-util-linux-97a2f1b8bac177eb7ccfb21d3f6be9c654fba0c8.tar.gz
kernel-qcow2-util-linux-97a2f1b8bac177eb7ccfb21d3f6be9c654fba0c8.tar.xz
kernel-qcow2-util-linux-97a2f1b8bac177eb7ccfb21d3f6be9c654fba0c8.zip
fdisk: get rid of type_open global variable
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Diffstat (limited to 'fdisk/fdisk.c')
-rw-r--r--fdisk/fdisk.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index a8a18009a..ab2e68d49 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -230,9 +230,6 @@ get_random_id(void) {
return (unsigned int)(tv.tv_sec + (tv.tv_usec << 12) + getpid());
}
-/* normally O_RDWR, -l option gives O_RDONLY */
-static int type_open = O_RDWR;
-
/*
* Raw disk label. For DOS-type partition tables the MBR,
* with descriptions of the primary partitions.
@@ -1120,7 +1117,7 @@ get_boot(enum action what) {
goto got_dos_table; /* skip reading disk */
if (what != try_only) {
- if ((fd = open(disk_device, type_open)) < 0) {
+ if ((fd = open(disk_device, O_RDWR)) < 0) {
if ((fd = open(disk_device, O_RDONLY)) < 0)
fatal(unable_to_open);
else
@@ -2810,7 +2807,7 @@ print_partition_table_from_option(char *device)
if (setjmp(listingbuf))
return;
gpt_warning(device);
- if ((fd = open(disk_device, type_open)) >= 0) {
+ if ((fd = open(disk_device, O_RDONLY)) >= 0) {
gb = get_boot(try_only);
if (gb > 0) { /* I/O error */
} else if (gb < 0) { /* no DOS signature */
@@ -3072,7 +3069,6 @@ main(int argc, char **argv) {
if (optl) {
nowarn = 1;
- type_open = O_RDONLY;
if (argc > optind) {
int k;
/* avoid gcc warning:
@@ -3091,7 +3087,6 @@ main(int argc, char **argv) {
unsigned long long size;
nowarn = 1;
- type_open = O_RDONLY;
opts = argc - optind;
if (opts <= 0)
@@ -3099,7 +3094,7 @@ main(int argc, char **argv) {
for (j = optind; j < argc; j++) {
disk_device = argv[j];
- if ((fd = open(disk_device, type_open)) < 0)
+ if ((fd = open(disk_device, O_RDONLY)) < 0)
fatal(unable_to_open);
if (blkdev_get_sectors(fd, &size) == -1)
fatal(ioctl_error);