Revision b6353bea qemu-nbd.c

b/qemu-nbd.c
114 114
    int ext_partnum = 4;
115 115

  
116 116
    if (bdrv_read(bs, 0, data, 1))
117
        errx(EINVAL, "error while reading");
117
        errx(EXIT_FAILURE, "error while reading");
118 118

  
119 119
    if (data[510] != 0x55 || data[511] != 0xaa) {
120 120
        errno = -EINVAL;
......
133 133
            int j;
134 134

  
135 135
            if (bdrv_read(bs, mbr[i].start_sector_abs, data1, 1))
136
                errx(EINVAL, "error while reading");
136
                errx(EXIT_FAILURE, "error while reading");
137 137

  
138 138
            for (j = 0; j < 4; j++) {
139 139
                read_partition(&data1[446 + 16 * j], &ext[j]);
......
240 240
        case 'p':
241 241
            li = strtol(optarg, &end, 0);
242 242
            if (*end) {
243
                errx(EINVAL, "Invalid port `%s'", optarg);
243
                errx(EXIT_FAILURE, "Invalid port `%s'", optarg);
244 244
            }
245 245
            if (li < 1 || li > 65535) {
246
                errx(EINVAL, "Port out of range `%s'", optarg);
246
                errx(EXIT_FAILURE, "Port out of range `%s'", optarg);
247 247
            }
248 248
            port = (uint16_t)li;
249 249
            break;
250 250
        case 'o':
251 251
                dev_offset = strtoll (optarg, &end, 0);
252 252
            if (*end) {
253
                errx(EINVAL, "Invalid offset `%s'", optarg);
253
                errx(EXIT_FAILURE, "Invalid offset `%s'", optarg);
254 254
            }
255 255
            if (dev_offset < 0) {
256
                errx(EINVAL, "Offset must be positive `%s'", optarg);
256
                errx(EXIT_FAILURE, "Offset must be positive `%s'", optarg);
257 257
            }
258 258
            break;
259 259
        case 'r':
......
263 263
        case 'P':
264 264
            partition = strtol(optarg, &end, 0);
265 265
            if (*end)
266
                errx(EINVAL, "Invalid partition `%s'", optarg);
266
                errx(EXIT_FAILURE, "Invalid partition `%s'", optarg);
267 267
            if (partition < 1 || partition > 8)
268
                errx(EINVAL, "Invalid partition %d", partition);
268
                errx(EXIT_FAILURE, "Invalid partition %d", partition);
269 269
            break;
270 270
        case 'k':
271 271
            socket = optarg;
272 272
            if (socket[0] != '/')
273
                errx(EINVAL, "socket path must be absolute\n");
273
                errx(EXIT_FAILURE, "socket path must be absolute\n");
274 274
            break;
275 275
        case 'd':
276 276
            disconnect = true;
......
281 281
        case 'e':
282 282
            shared = strtol(optarg, &end, 0);
283 283
            if (*end) {
284
                errx(EINVAL, "Invalid shared device number '%s'", optarg);
284
                errx(EXIT_FAILURE, "Invalid shared device number '%s'", optarg);
285 285
            }
286 286
            if (shared < 1) {
287
                errx(EINVAL, "Shared device number must be greater than 0\n");
287
                errx(EXIT_FAILURE, "Shared device number must be greater than 0\n");
288 288
            }
289 289
            break;
290 290
	case 't':
......
302 302
            exit(0);
303 303
            break;
304 304
        case '?':
305
            errx(EINVAL, "Try `%s --help' for more information.",
305
            errx(EXIT_FAILURE, "Try `%s --help' for more information.",
306 306
                 argv[0]);
307 307
        }
308 308
    }
309 309

  
310 310
    if ((argc - optind) != 1) {
311
        errx(EINVAL, "Invalid number of argument.\n"
311
        errx(EXIT_FAILURE, "Invalid number of argument.\n"
312 312
             "Try `%s --help' for more information.",
313 313
             argv[0]);
314 314
    }
......
316 316
    if (disconnect) {
317 317
        fd = open(argv[optind], O_RDWR);
318 318
        if (fd == -1)
319
            errx(errno, "Cannot open %s", argv[optind]);
319
            errx(EXIT_FAILURE, "Cannot open %s", argv[optind]);
320 320

  
321 321
        nbd_disconnect(fd);
322 322

  
......
340 340

  
341 341
    if (partition != -1 &&
342 342
        find_partition(bs, partition, &dev_offset, &fd_size))
343
        errx(errno, "Could not find partition %d", partition);
343
        errx(EXIT_FAILURE, "Could not find partition %d", partition);
344 344

  
345 345
    if (device) {
346 346
        pid_t pid;
......
349 349
        if (!verbose) {
350 350
            /* detach client and server */
351 351
            if (daemon(0, 0) == -1) {
352
                errx(errno, "Failed to daemonize");
352
                errx(EXIT_FAILURE, "Failed to daemonize");
353 353
            }
354 354
        }
355 355

  
......
429 429

  
430 430
    data = qemu_memalign(512, NBD_BUFFER_SIZE);
431 431
    if (data == NULL)
432
        errx(ENOMEM, "Cannot allocate data buffer");
432
        errx(EXIT_FAILURE, "Cannot allocate data buffer");
433 433

  
434 434
    do {
435 435

  

Also available in: Unified diff