Commit 1062e481 authored by Paolo \'Blaisorblade\' Giarrusso's avatar Paolo \'Blaisorblade\' Giarrusso Committed by Linus Torvalds

[PATCH] uml: allow free ubd flag ordering

When parsing the <flags> section in ubd<n><flags>=file[,file2], instead of
requiring that the flags are specified in a certain order, just make the code
smarter.
Signed-off-by: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent fd9f92df
...@@ -250,7 +250,7 @@ static int ubd_setup_common(char *str, int *index_out) ...@@ -250,7 +250,7 @@ static int ubd_setup_common(char *str, int *index_out)
struct ubd *dev; struct ubd *dev;
struct openflags flags = global_openflags; struct openflags flags = global_openflags;
char *backing_file; char *backing_file;
int n, err; int n, err, i;
if(index_out) *index_out = -1; if(index_out) *index_out = -1;
n = *str; n = *str;
...@@ -312,29 +312,40 @@ static int ubd_setup_common(char *str, int *index_out) ...@@ -312,29 +312,40 @@ static int ubd_setup_common(char *str, int *index_out)
dev = &ubd_dev[n]; dev = &ubd_dev[n];
if(dev->file != NULL){ if(dev->file != NULL){
printk(KERN_ERR "ubd_setup : device already configured\n"); printk(KERN_ERR "ubd_setup : device already configured\n");
goto out2; goto out;
} }
if(index_out) *index_out = n; if (index_out)
*index_out = n;
if (*str == 'r'){
flags.w = 0; for (i = 0; i < 4; i++) {
str++; switch (*str) {
} case 'r':
if (*str == 's'){ flags.w = 0;
flags.s = 1; break;
str++; case 's':
} flags.s = 1;
if (*str == 'd'){ break;
dev->no_cow = 1; case 'd':
dev->no_cow = 1;
break;
case '=':
str++;
goto break_loop;
default:
printk(KERN_ERR "ubd_setup : Expected '=' or flag letter (r,s or d)\n");
goto out;
}
str++; str++;
} }
if(*str++ != '='){ if (*str == '=')
printk(KERN_ERR "ubd_setup : Too many flags specified\n");
else
printk(KERN_ERR "ubd_setup : Expected '='\n"); printk(KERN_ERR "ubd_setup : Expected '='\n");
goto out2; goto out;
}
break_loop:
err = 0; err = 0;
backing_file = strchr(str, ','); backing_file = strchr(str, ',');
...@@ -354,7 +365,7 @@ static int ubd_setup_common(char *str, int *index_out) ...@@ -354,7 +365,7 @@ static int ubd_setup_common(char *str, int *index_out)
dev->file = str; dev->file = str;
dev->cow.file = backing_file; dev->cow.file = backing_file;
dev->boot_openflags = flags; dev->boot_openflags = flags;
out2: out:
spin_unlock(&ubd_lock); spin_unlock(&ubd_lock);
return(err); return(err);
} }
...@@ -385,8 +396,7 @@ __uml_help(ubd_setup, ...@@ -385,8 +396,7 @@ __uml_help(ubd_setup,
" machine by running 'dd' on the device. <n> must be in the range\n" " machine by running 'dd' on the device. <n> must be in the range\n"
" 0 to 7. Appending an 'r' to the number will cause that device\n" " 0 to 7. Appending an 'r' to the number will cause that device\n"
" to be mounted read-only. For example ubd1r=./ext_fs. Appending\n" " to be mounted read-only. For example ubd1r=./ext_fs. Appending\n"
" an 's' (has to be _after_ 'r', if there is one) will cause data\n" " an 's' will cause data to be written to disk on the host immediately.\n\n"
" to be written to disk on the host immediately.\n\n"
); );
static int fakehd_set = 0; static int fakehd_set = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment