We produced an error message when all four flags were used; and we would
only catch such flags if they were produced in the right order (which
was different from the order in the manpage).
Thanks to Fan Zhang for catching these.
int nofork=0;
u64 size64;
u32 flags;
int nofork=0;
u64 size64;
u32 flags;
err("Cannot open NBD: %m\nPlease ensure the 'nbd' module is loaded.");
++argv; --argc; /* skip device */
err("Cannot open NBD: %m\nPlease ensure the 'nbd' module is loaded.");
++argv; --argc; /* skip device */
- if (argc>3) goto errmsg;
- if (argc) {
- if(strncmp(argv[0], "-swap", 5)==0) {
- swap=1;
- ++argv;--argc;
+ if (argc>4) goto errmsg;
+ for(i=0; i<4; i++) {
+ if (argc) {
+ if(strncmp(argv[0], "-swap", 5)==0) {
+ swap=1;
+ ++argv;--argc;
+ }
- }
- if (argc) {
- if(strncmp(argv[0], "-persist", 8)==0) {
- cont=1;
- ++argv;--argc;
+ if (argc) {
+ if(strncmp(argv[0], "-persist", 8)==0) {
+ cont=1;
+ ++argv;--argc;
+ }
- }
- if (argc) {
- if(strncmp(argv[0], "-sdp", 4)==0) {
- sdp=1;
- ++argv;--argc;
+ if (argc) {
+ if(strncmp(argv[0], "-sdp", 4)==0) {
+ sdp=1;
+ ++argv;--argc;
+ }
- }
- if (argc) {
- if(strncmp(argv[0], "-nofork", 7)==0) {
- nofork=1;
- ++argv;--argc;
+ if (argc) {
+ if(strncmp(argv[0], "-nofork", 7)==0) {
+ nofork=1;
+ ++argv;--argc;
+ }
}
}
if(argc) goto errmsg;
}
}
if(argc) goto errmsg;