util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Francesco Cosoleto <cosoleto@gmail.com>
To: util-linux@vger.kernel.org
Cc: Francesco Cosoleto <cosoleto@gmail.com>
Subject: [PATCH 06/13] fdisk: get rid of type_open global variable
Date: Thu, 15 Dec 2011 20:02:42 +0100	[thread overview]
Message-ID: <1323975769-21929-6-git-send-email-cosoleto@gmail.com> (raw)
In-Reply-To: <1323975769-21929-1-git-send-email-cosoleto@gmail.com>

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
---
 fdisk/fdisk.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index a8a1800..ab2e68d 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);
-- 
1.7.7


  parent reply	other threads:[~2011-12-15 19:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-15 19:02 [PATCH 01/13] fdisk: remove unused 'require' member in enum action Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 02/13] fdisk: remove possibly_osf_label variable that is only assigned Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 03/13] fdisk: move code for renaming SGI bootfile to SGI module Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 04/13] fdisk: drop one parameter from try() function Francesco Cosoleto
2011-12-16 13:18   ` Karel Zak
2011-12-22  2:24   ` Guillem Jover
2011-12-22 15:26     ` Francesco Cosoleto
2012-01-04 13:36       ` Karel Zak
2011-12-15 19:02 ` [PATCH 05/13] fdisk: rename try() and tryprocpt() functions Francesco Cosoleto
2011-12-15 19:02 ` Francesco Cosoleto [this message]
2011-12-15 19:02 ` [PATCH 07/13] fdisk: get rid of get_boot(create_empty_sun) call Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 08/13] fdisk: remove unused guess_device_type() function Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 09/13] fdisk: don't use get_existing_partition() if disk label isn't dos Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 10/13] fdisk: avoid an intermediate variable in command_prompt() Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 11/13] fdisk: Fix bad invalid flag 0x00000 warning message Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 12/13] fdisk: improve some messages Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 13/13] tests: update fdisk tests Francesco Cosoleto
2011-12-16 13:12 ` [PATCH 01/13] fdisk: remove unused 'require' member in enum action Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1323975769-21929-6-git-send-email-cosoleto@gmail.com \
    --to=cosoleto@gmail.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).