Fix code style
parent
442a9d838d
commit
64c5c4ca26
|
@ -36,13 +36,10 @@
|
|||
|
||||
#include <linux/nbd-netlink.h>
|
||||
|
||||
#define fail(...) \
|
||||
do { \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
exit(1); \
|
||||
} while (0)
|
||||
#define fail(...) { fprintf(stderr, __VA_ARGS__); exit(1); }
|
||||
|
||||
struct netlink_ctx {
|
||||
struct netlink_ctx
|
||||
{
|
||||
struct nl_sock *sk;
|
||||
int driver_id;
|
||||
};
|
||||
|
@ -112,11 +109,8 @@ static int netlink_status_cb(struct nl_msg *sk_msg, void *devnum)
|
|||
return NL_OK;
|
||||
}
|
||||
|
||||
static int netlink_configure(const int *sockfd, int sock_size,
|
||||
int dev_num, uint64_t size,
|
||||
uint64_t blocksize, uint64_t flags,
|
||||
uint64_t cflags, uint64_t timeout,
|
||||
uint64_t conn_timeout)
|
||||
static int netlink_configure(const int *sockfd, int sock_size, int dev_num, uint64_t size,
|
||||
uint64_t blocksize, uint64_t flags, uint64_t cflags, uint64_t timeout, uint64_t conn_timeout)
|
||||
{
|
||||
struct netlink_ctx ctx;
|
||||
struct nlattr *msg_attr, *msg_opt_attr;
|
||||
|
@ -133,7 +127,7 @@ static int netlink_configure(const int *sockfd, int sock_size,
|
|||
if (!msg)
|
||||
{
|
||||
netlink_sock_free(&ctx);
|
||||
fail("Failed to allocate netlking message\n");
|
||||
fail("Failed to allocate netlink message\n");
|
||||
}
|
||||
|
||||
genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ, ctx.driver_id, 0, 0, NBD_CMD_CONNECT, 0);
|
||||
|
@ -180,7 +174,7 @@ static int netlink_configure(const int *sockfd, int sock_size,
|
|||
|
||||
nla_nest_end(msg, msg_attr);
|
||||
|
||||
if((err = nl_send_sync(ctx.sk, msg)) < 0)
|
||||
if ((err = nl_send_sync(ctx.sk, msg)) < 0)
|
||||
{
|
||||
netlink_sock_free(&ctx);
|
||||
return err;
|
||||
|
@ -208,7 +202,7 @@ static void netlink_disconnect(uint32_t dev_num)
|
|||
if (!msg)
|
||||
{
|
||||
netlink_sock_free(&ctx);
|
||||
fail("Failed to allocate netlking message\n");
|
||||
fail("Failed to allocate netlink message\n");
|
||||
}
|
||||
|
||||
genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ, ctx.driver_id, 0, 0, NBD_CMD_DISCONNECT, 0);
|
||||
|
@ -234,19 +228,14 @@ nla_put_failure:
|
|||
|
||||
#else
|
||||
|
||||
static int netlink_configure(const int *sockfd, int sock_size,
|
||||
int dev_num, uint64_t size,
|
||||
uint64_t blocksize, uint64_t flags,
|
||||
uint64_t cflags, uint64_t timeout,
|
||||
uint64_t conn_timeout)
|
||||
static int netlink_configure(const int *sockfd, int sock_size, int dev_num, uint64_t size,
|
||||
uint64_t blocksize, uint64_t flags, uint64_t cflags, uint64_t timeout, uint64_t conn_timeout)
|
||||
{
|
||||
fprintf(stderr, "netlink is not supported\n");
|
||||
exit(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void netlink_disconnect(uint32_t dev_num)
|
||||
{
|
||||
fprintf(stderr, "netlink is not supported\n");
|
||||
|
@ -396,7 +385,7 @@ public:
|
|||
" is returned after no I/O is performed on device.\n"
|
||||
" By default is not set.\n"
|
||||
" --nbd_destroy_on_disconnect 1\n"
|
||||
" Delete the nbd device on disconnect\n."
|
||||
" Delete the nbd device on disconnect.\n"
|
||||
" --nbd_disconnect_on_close 1\n"
|
||||
" Disconnect the nbd device on close by last opener.\n"
|
||||
" --nbd_ro 1\n"
|
||||
|
@ -560,13 +549,12 @@ public:
|
|||
#endif
|
||||
|
||||
int err = netlink_configure(sockfd + 1, 1, devnum, device_size, 4096, flags, cflags, nbd_timeout, nbd_lease);
|
||||
if (err < 0) {
|
||||
if (err == -NLE_BUSY) {
|
||||
if (err < 0)
|
||||
{
|
||||
if (err == -NLE_BUSY)
|
||||
errno = EBUSY;
|
||||
} else {
|
||||
else
|
||||
errno = EIO;
|
||||
}
|
||||
|
||||
perror("netlink_configure");
|
||||
exit(1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue