Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Unified Diff: gpt.c

Issue 1133004: Stop using O_EXCL by default when opening the device for writing. (Closed)
Patch Set: D'oh! Of course. Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpt.8 ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpt.c
diff --git a/gpt.c b/gpt.c
index a09df130c579e2010d99014ccfde961ef7097ff8..c1bf9445c2388cf775a09d414ecd4e5c224a1029 100644
--- a/gpt.c
+++ b/gpt.c
@@ -60,7 +60,7 @@ off_t mediasz;
u_int parts;
u_int secsz;
-int readonly, verbose;
+int readonly, exclusive = O_EXCL, verbose;
static uint32_t crc32_tab[] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
@@ -557,7 +557,7 @@ gpt_open(const char *dev)
struct stat sb;
int fd, mode;
- mode = readonly ? O_RDONLY : O_RDWR|O_EXCL;
+ mode = readonly ? O_RDONLY : O_RDWR|exclusive;
strlcpy(device_path, dev, sizeof(device_path));
device_name = device_path;
@@ -666,7 +666,7 @@ usage(void)
{
fprintf(stderr,
- "usage: %s [-rv] [-p nparts] command [options] device ...\n",
+ "usage: %s [-rSv] [-p nparts] command [options] device ...\n",
getprogname());
exit(1);
}
@@ -694,7 +694,7 @@ main(int argc, char *argv[])
int ch, i;
/* Get the generic options */
- while ((ch = getopt(argc, argv, "+p:rv")) != -1) {
+ while ((ch = getopt(argc, argv, "+p:rSv")) != -1) {
switch(ch) {
case 'p':
if (parts > 0)
@@ -706,6 +706,9 @@ main(int argc, char *argv[])
case 'r':
readonly = 1;
break;
+ case 'S':
+ exclusive = 0;
+ break;
case 'v':
verbose++;
break;
« no previous file with comments | « gpt.8 ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698