static int connect_ring(struct backend_info *be)
{
struct xenbus_device *dev = be->dev;
- unsigned long ring_ref;
- unsigned int evtchn;
- char protocol[64] = "";
+ unsigned int ring_ref, evtchn;
+ char *protocol;
int err;
DPRINTK("%s", dev->otherend);
- err = xenbus_gather(XBT_NIL, dev->otherend, "ring-ref", "%lu", &ring_ref,
+ err = xenbus_gather(XBT_NIL, dev->otherend, "ring-ref", "%u", &ring_ref,
"event-channel", "%u", &evtchn, NULL);
if (err) {
xenbus_dev_fatal(dev, err,
be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE;
err = xenbus_gather(XBT_NIL, dev->otherend, "protocol",
- "%63s", protocol, NULL);
+ NULL, &protocol, NULL);
if (err)
- strcpy(protocol, "unspecified, assuming native");
+ protocol = NULL;
else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_NATIVE))
be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE;
else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_32))
be->blkif->blk_protocol = BLKIF_PROTOCOL_X86_64;
else {
xenbus_dev_fatal(dev, err, "unknown fe protocol %s", protocol);
+ kfree(protocol);
return -1;
}
printk(KERN_INFO
- "blkback: ring-ref %ld, event-channel %d, protocol %d (%s)\n",
- ring_ref, evtchn, be->blkif->blk_protocol, protocol);
+ "blkback: ring-ref %u, event-channel %u, protocol %d (%s)\n",
+ ring_ref, evtchn, be->blkif->blk_protocol,
+ protocol ?: "unspecified, assuming native");
+ kfree(protocol);
/* Map the shared frame, irq etc. */
err = blkif_map(be->blkif, ring_ref, evtchn);
if (err) {
- xenbus_dev_fatal(dev, err, "mapping ring-ref %lu port %u",
+ xenbus_dev_fatal(dev, err, "mapping ring-ref %u port %u",
ring_ref, evtchn);
return err;
}
*/
err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
"sectors", "%Lu", §ors);
- if (XENBUS_EXIST_ERR(err))
+ if (err != 1)
return;
printk(KERN_INFO "Setting capacity to %Lu\n",
sectors);
return;
}
- err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
- "feature-barrier", "%d", &info->feature_barrier,
- NULL);
- if (err)
+ err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
+ "feature-barrier", "%d", &info->feature_barrier);
+ if (err <= 0)
info->feature_barrier = 0;
err = xlvbd_add(sectors, info->vdevice, binfo, sector_size, info);
* and disk info to xenstore
*/
err = xenbus_gather(XBT_NIL, dev->nodename, "info", "%lu", &info,
- NULL);
+ "sectors", "%Lu", &be->blkif->sectors, NULL);
if (XENBUS_EXIST_ERR(err))
return;
if (err) {
DPRINTK("Userspace update on disk info, %lu\n",info);
- err = xenbus_gather(XBT_NIL, dev->nodename, "sectors", "%llu",
- &be->blkif->sectors, NULL);
-
/* Associate tap dev with domid*/
be->blkif->dev_num = dom_to_devid(be->blkif->domid, be->xenbus_id,
be->blkif);
static int connect_ring(struct backend_info *be)
{
struct xenbus_device *dev = be->dev;
- unsigned long ring_ref;
- unsigned int evtchn;
- char protocol[64];
+ unsigned int ring_ref, evtchn;
+ char *protocol;
int err;
DPRINTK("%s\n", dev->otherend);
- err = xenbus_gather(XBT_NIL, dev->otherend, "ring-ref", "%lu",
+ err = xenbus_gather(XBT_NIL, dev->otherend, "ring-ref", "%u",
&ring_ref, "event-channel", "%u", &evtchn, NULL);
if (err) {
xenbus_dev_fatal(dev, err,
be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE;
err = xenbus_gather(XBT_NIL, dev->otherend, "protocol",
- "%63s", protocol, NULL);
+ NULL, &protocol, NULL);
if (err)
- strcpy(protocol, "unspecified, assuming native");
+ protocol = NULL;
else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_NATIVE))
be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE;
else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_32))
be->blkif->blk_protocol = BLKIF_PROTOCOL_X86_64;
else {
xenbus_dev_fatal(dev, err, "unknown fe protocol %s", protocol);
+ kfree(protocol);
return -1;
}
printk(KERN_INFO
- "blktap: ring-ref %ld, event-channel %d, protocol %d (%s)\n",
- ring_ref, evtchn, be->blkif->blk_protocol, protocol);
+ "blktap: ring-ref %u, event-channel %u, protocol %d (%s)\n",
+ ring_ref, evtchn, be->blkif->blk_protocol,
+ protocol ?: "unspecified, assuming native");
+ kfree(protocol);
/* Map the shared frame, irq etc. */
err = tap_blkif_map(be->blkif, dev, ring_ref, evtchn);
if (err) {
- xenbus_dev_fatal(dev, err, "mapping ring-ref %lu port %u",
+ xenbus_dev_fatal(dev, err, "mapping ring-ref %u port %u",
ring_ref, evtchn);
return err;
}
err = xenbus_transaction_start(&xbt);
if (err)
return;
- if (!xenbus_scanf(xbt, "control", "sysrq", "%c", &sysrq_key)) {
+ if (xenbus_scanf(xbt, "control", "sysrq", "%c", &sysrq_key) <= 0) {
printk(KERN_ERR "Unable to read sysrq code in "
"control/sysrq\n");
xenbus_transaction_end(xbt, 1);
{
netif_t *netif = be->netif;
struct xenbus_device *dev = be->dev;
- unsigned long tx_ring_ref, rx_ring_ref;
+ unsigned int tx_ring_ref, rx_ring_ref;
unsigned int evtchn, rx_copy;
int err;
int val;
DPRINTK("");
err = xenbus_gather(XBT_NIL, dev->otherend,
- "tx-ring-ref", "%lu", &tx_ring_ref,
- "rx-ring-ref", "%lu", &rx_ring_ref,
+ "tx-ring-ref", "%u", &tx_ring_ref,
+ "rx-ring-ref", "%u", &rx_ring_ref,
"event-channel", "%u", &evtchn, NULL);
if (err) {
xenbus_dev_fatal(dev, err,
err = netif_map(be, tx_ring_ref, rx_ring_ref, evtchn);
if (err) {
xenbus_dev_fatal(dev, err,
- "mapping shared-frames %lu/%lu port %u",
+ "mapping shared-frames %u/%u port %u",
tx_ring_ref, rx_ring_ref, evtchn);
return err;
}
static int scsiback_map(struct backend_info *be)
{
struct xenbus_device *dev = be->dev;
- unsigned long ring_ref;
- unsigned int evtchn;
+ unsigned int ring_ref, evtchn;
int err;
char name[TASK_COMM_LEN];
err = xenbus_gather(XBT_NIL, dev->otherend,
- "ring-ref", "%lu", &ring_ref,
+ "ring-ref", "%u", &ring_ref,
"event-channel", "%u", &evtchn, NULL);
if (err) {
xenbus_dev_fatal(dev, err, "reading %s ring", dev->otherend);
static int connect_ring(struct backend_info *be)
{
struct xenbus_device *dev = be->dev;
- unsigned long ring_ref;
- unsigned int evtchn;
+ unsigned int ring_ref, evtchn;
int err;
err = xenbus_gather(XBT_NIL, dev->otherend,
- "ring-ref", "%lu", &ring_ref,
+ "ring-ref", "%u", &ring_ref,
"event-channel", "%u", &evtchn, NULL);
if (err) {
xenbus_dev_error(dev, err,
err = tpmif_map(be->tpmif, ring_ref, evtchn);
if (err) {
xenbus_dev_error(dev, err,
- "mapping shared-frame %lu port %u",
+ "mapping shared-frame %u port %u",
ring_ref, evtchn);
return err;
}
static int connect_rings(usbif_t *usbif)
{
struct xenbus_device *dev = usbif->xbdev;
- unsigned long urb_ring_ref;
- unsigned long conn_ring_ref;
- unsigned int evtchn;
+ unsigned int urb_ring_ref, conn_ring_ref, evtchn;
int err;
err = xenbus_gather(XBT_NIL, dev->otherend,
- "urb-ring-ref", "%lu", &urb_ring_ref,
- "conn-ring-ref", "%lu", &conn_ring_ref,
+ "urb-ring-ref", "%u", &urb_ring_ref,
+ "conn-ring-ref", "%u", &conn_ring_ref,
"event-channel", "%u", &evtchn, NULL);
if (err) {
xenbus_dev_fatal(dev, err,
return err;
}
- printk("usbback: urb-ring-ref %ld, conn-ring-ref %ld, event-channel %d\n",
+ printk("usbback: urb-ring-ref %u, conn-ring-ref %u,"
+ " event-channel %u\n",
urb_ring_ref, conn_ring_ref, evtchn);
err = usbif_map(usbif, urb_ring_ref, conn_ring_ref, evtchn);
if (err) {
xenbus_dev_fatal(dev, err,
- "mapping urb-ring-ref %lu conn-ring-ref %lu port %u",
+ "mapping urb-ring-ref %u conn-ring-ref %u port %u",
urb_ring_ref, conn_ring_ref, evtchn);
return err;
}
enum xenbus_state xenbus_read_driver_state(const char *path)
{
- enum xenbus_state result;
- int err = xenbus_gather(XBT_NIL, path, "state", "%d", &result, NULL);
- if (err)
+ int result;
+
+ if (xenbus_scanf(XBT_NIL, path, "state", "%d", &result) != 1)
result = XenbusStateUnknown;
return result;
static void xenbus_reset_state_changed(struct xenbus_watch *w, const char **v, unsigned int l)
{
- xenbus_scanf(XBT_NIL, v[XS_WATCH_PATH], "", "%i", &be_state);
+ if (xenbus_scanf(XBT_NIL, v[XS_WATCH_PATH], "", "%i", &be_state) != 1)
+ be_state = XenbusStateUnknown;
printk(KERN_INFO "XENBUS: %s %s\n", v[XS_WATCH_PATH], xenbus_strstate(be_state));
wake_up(&be_state_wq);
}