|
--- vmnet-only/bridge.c |
|
+++ vmnet-only/bridge.c |
|
@@ -105,8 +105,6 @@ static Bool VNetBridgeCycleDetect(VNetJack *this, int generation); |
|
static Bool VNetBridgeIsDeviceWireless(struct net_device *dev); |
|
static void VNetBridgePortsChanged(VNetJack *this); |
|
static int VNetBridgeIsBridged(VNetJack *this); |
|
-static int VNetBridgeProcRead(char *page, char **start, off_t off, |
|
- int count, int *eof, void *data); |
|
static void VNetBridgeComputeHeaderPosIPv6(struct sk_buff *skb); |
|
static PacketStatus VNetCallSMACFunc(struct SMACState *state, |
|
struct sk_buff **skb, void *startOfData, |
|
@@ -225,6 +223,53 @@ VNetBridgeDevCompatible(VNetBridge *bridge, // IN: Bridge |
|
/* |
|
*---------------------------------------------------------------------- |
|
* |
|
+ * VNetBridgeProcShow -- |
|
+ * |
|
+ * Callback for read operation on this bridge entry in vnets proc fs. |
|
+ * |
|
+ * Results: |
|
+ * Length of read operation. |
|
+ * |
|
+ * Side effects: |
|
+ * None. |
|
+ * |
|
+ *---------------------------------------------------------------------- |
|
+ */ |
|
+ |
|
+int |
|
+VNetBridgeProcShow(struct seq_file *seqf, // IN/OUT: buffer to write into |
|
+ void *data) // IN: client data - pointer to bridge |
|
+{ |
|
+ VNetBridge *bridge = (VNetBridge*)data; |
|
+ |
|
+ if (!bridge) { |
|
+ return 0; |
|
+ } |
|
+ |
|
+ VNetPrintPort(&bridge->port, seqf); |
|
+ |
|
+ seq_printf(seqf, "dev %s ", bridge->name); |
|
+ |
|
+ seq_printf(seqf, "\n"); |
|
+ |
|
+ return 0; |
|
+} |
|
+ |
|
+static int proc_bridge_open(struct inode *inode, struct file *file) |
|
+{ |
|
+ return single_open(file, VNetBridgeProcShow, PDE_DATA(inode)); |
|
+} |
|
+ |
|
+static const struct file_operations proc_bridge_fops = { |
|
+ .open = proc_bridge_open, |
|
+ .read = seq_read, |
|
+ .llseek = seq_lseek, |
|
+ .release = seq_release, |
|
+}; |
|
+ |
|
+/* |
|
+ *---------------------------------------------------------------------- |
|
+ * |
|
* VNetBridge_Create -- |
|
* |
|
* Creates a bridge. Allocates struct, allocates internal device, |
|
@@ -319,17 +364,14 @@ VNetBridge_Create(const char *devName, // IN: name of device (e.g., "eth0") |
|
* Make proc entry for this jack. |
|
*/ |
|
|
|
- retval = VNetProc_MakeEntry(bridge->port.jack.name, S_IFREG, |
|
- &bridge->port.jack.procEntry); |
|
+ retval = VNetProc_MakeEntryOps(bridge->port.jack.name, S_IFREG, |
|
+ &bridge->port.jack.procEntry, &proc_bridge_fops, bridge); |
|
if (retval) { |
|
if (retval == -ENXIO) { |
|
bridge->port.jack.procEntry = NULL; |
|
} else { |
|
goto out; |
|
} |
|
- } else { |
|
- bridge->port.jack.procEntry->read_proc = VNetBridgeProcRead; |
|
- bridge->port.jack.procEntry->data = bridge; |
|
} |
|
|
|
/* |
|
@@ -1719,45 +1761,3 @@ VNetBridgeReceiveFromDev(struct sk_buff *skb, // IN: packet to receive |
|
return 0; |
|
} |
|
|
|
- |
|
-/* |
|
- *---------------------------------------------------------------------- |
|
- * |
|
- * VNetBridgeProcRead -- |
|
- * |
|
- * Callback for read operation on this bridge entry in vnets proc fs. |
|
- * |
|
- * Results: |
|
- * Length of read operation. |
|
- * |
|
- * Side effects: |
|
- * None. |
|
- * |
|
- *---------------------------------------------------------------------- |
|
- */ |
|
- |
|
-int |
|
-VNetBridgeProcRead(char *page, // IN/OUT: buffer to write into |
|
- char **start, // OUT: 0 if file < 4k, else offset into page |
|
- off_t off, // IN: (unused) offset of read into the file |
|
- int count, // IN: (unused) maximum number of bytes to read |
|
- int *eof, // OUT: TRUE if there is nothing more to read |
|
- void *data) // IN: client data - pointer to bridge |
|
-{ |
|
- VNetBridge *bridge = (VNetBridge*)data; |
|
- int len = 0; |
|
- |
|
- if (!bridge) { |
|
- return len; |
|
- } |
|
- |
|
- len += VNetPrintPort(&bridge->port, page+len); |
|
- |
|
- len += sprintf(page+len, "dev %s ", bridge->name); |
|
- |
|
- len += sprintf(page+len, "\n"); |
|
- |
|
- *start = 0; |
|
- *eof = 1; |
|
- return len; |
|
-} |
|
--- vmnet-only/driver.c |
|
+++ vmnet-only/driver.c |
|
@@ -1785,21 +1785,17 @@ VNetSetMACUnique(VNetPort *port, // IN: |
|
*---------------------------------------------------------------------- |
|
*/ |
|
|
|
-int |
|
+void |
|
VNetPrintJack(const VNetJack *jack, // IN: jack |
|
- char *buf) // OUT: info about jack |
|
+ struct seq_file *seqf) // OUT: info about jack |
|
{ |
|
- int len = 0; |
|
- |
|
read_lock(&vnetPeerLock); |
|
if (!jack->peer) { |
|
- len += sprintf(buf+len, "connected not "); |
|
+ seq_printf(seqf, "connected not "); |
|
} else { |
|
- len += sprintf(buf+len, "connected %s ", jack->peer->name); |
|
+ seq_printf(seqf, "connected %s ", jack->peer->name); |
|
} |
|
read_unlock(&vnetPeerLock); |
|
- |
|
- return len; |
|
} |
|
|
|
|
|
@@ -1819,52 +1815,48 @@ VNetPrintJack(const VNetJack *jack, // IN: jack |
|
*---------------------------------------------------------------------- |
|
*/ |
|
|
|
-int |
|
+void |
|
VNetPrintPort(const VNetPort *port, // IN: port |
|
- char *buf) // OUT: info about port |
|
+ struct seq_file *seqf) // OUT: info about port |
|
{ |
|
- int len = 0; |
|
+ VNetPrintJack(&port->jack, seqf); |
|
|
|
- len += VNetPrintJack(&port->jack, buf+len); |
|
- |
|
- len += sprintf(buf+len, "mac %02x:%02x:%02x:%02x:%02x:%02x ", |
|
+ seq_printf(seqf, "mac %02x:%02x:%02x:%02x:%02x:%02x ", |
|
port->paddr[0], port->paddr[1], port->paddr[2], |
|
port->paddr[3], port->paddr[4], port->paddr[5]); |
|
|
|
- len += sprintf(buf+len, "ladrf %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ", |
|
+ seq_printf(seqf, "ladrf %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ", |
|
port->ladrf[0], port->ladrf[1], port->ladrf[2], |
|
port->ladrf[3], port->ladrf[4], port->ladrf[5], |
|
port->ladrf[6], port->ladrf[7]); |
|
|
|
- len += sprintf(buf+len, "flags IFF_RUNNING"); |
|
+ seq_printf(seqf, "flags IFF_RUNNING"); |
|
|
|
if (port->flags & IFF_UP) { |
|
- len += sprintf(buf+len, ",IFF_UP"); |
|
+ seq_printf(seqf, ",IFF_UP"); |
|
} |
|
|
|
if (port->flags & IFF_BROADCAST) { |
|
- len += sprintf(buf+len, ",IFF_BROADCAST"); |
|
+ seq_printf(seqf, ",IFF_BROADCAST"); |
|
} |
|
|
|
if (port->flags & IFF_DEBUG) { |
|
- len += sprintf(buf+len, ",IFF_DEBUG"); |
|
+ seq_printf(seqf, ",IFF_DEBUG"); |
|
} |
|
|
|
if (port->flags & IFF_PROMISC) { |
|
- len += sprintf(buf+len, ",IFF_PROMISC"); |
|
+ seq_printf(seqf, ",IFF_PROMISC"); |
|
} |
|
|
|
if (port->flags & IFF_MULTICAST) { |
|
- len += sprintf(buf+len, ",IFF_MULTICAST"); |
|
+ seq_printf(seqf, ",IFF_MULTICAST"); |
|
} |
|
|
|
if (port->flags & IFF_ALLMULTI) { |
|
- len += sprintf(buf+len, ",IFF_ALLMULTI"); |
|
+ seq_printf(seqf, ",IFF_ALLMULTI"); |
|
} |
|
|
|
- len += sprintf(buf+len, " "); |
|
- |
|
- return len; |
|
+ seq_printf(seqf, " "); |
|
} |
|
|
|
|
|
--- vmnet-only/hub.c |
|
+++ vmnet-only/hub.c |
|
@@ -25,6 +25,7 @@ |
|
#include <linux/sched.h> |
|
#include <linux/slab.h> |
|
#include <linux/poll.h> |
|
+#include <linux/seq_file.h> |
|
|
|
#include <linux/netdevice.h> |
|
#include <linux/etherdevice.h> |
|
@@ -71,8 +72,6 @@ static void VNetHubReceive(VNetJack *this, struct sk_buff *skb); |
|
static Bool VNetHubCycleDetect(VNetJack *this, int generation); |
|
static void VNetHubPortsChanged(VNetJack *this); |
|
static int VNetHubIsBridged(VNetJack *this); |
|
-static int VNetHubProcRead(char *page, char **start, off_t off, |
|
- int count, int *eof, void *data); |
|
|
|
static VNetHub *vnetHub; |
|
static DEFINE_SPINLOCK(vnetHubLock); |
|
@@ -241,6 +240,53 @@ VNetHub_AllocPvn(uint8 id[]) // IN: the PVN ID to alloc on |
|
/* |
|
*---------------------------------------------------------------------- |
|
* |
|
+ * VNetHubProcShow -- |
|
+ * |
|
+ * Callback for read operation on hub entry in vnets proc fs. |
|
+ * |
|
+ * Results: |
|
+ * Length of read operation. |
|
+ * |
|
+ * Side effects: |
|
+ * None. |
|
+ * |
|
+ *---------------------------------------------------------------------- |
|
+ */ |
|
+ |
|
+int |
|
+VNetHubProcShow(struct seq_file *seqf, // IN/OUT: buffer to write into |
|
+ void *data) // IN: client data - not used |
|
+{ |
|
+ VNetJack *jack = (VNetJack*)data; |
|
+ VNetHub *hub; |
|
+ |
|
+ if (!jack || !jack->private) { |
|
+ return 0; |
|
+ } |
|
+ hub = (VNetHub*)jack->private; |
|
+ |
|
+ VNetPrintJack(jack, seqf); |
|
+ |
|
+ seq_printf(seqf, "tx %u ", hub->stats[jack->index].tx); |
|
+ seq_printf(seqf, "\n"); |
|
+ return 0; |
|
+} |
|
+ |
|
+static int proc_hub_open(struct inode *inode, struct file *file) |
|
+{ |
|
+ return single_open(file, VNetHubProcShow, PDE_DATA(inode)); |
|
+} |
|
+ |
|
+static const struct file_operations proc_hub_fops = { |
|
+ .open = proc_hub_open, |
|
+ .read = seq_read, |
|
+ .llseek = seq_lseek, |
|
+ .release = seq_release, |
|
+}; |
|
+ |
|
+/* |
|
+ *---------------------------------------------------------------------- |
|
+ * |
|
* VNetHubAlloc -- |
|
* |
|
* Allocate a jack on this hub. |
|
@@ -354,7 +400,7 @@ VNetHubAlloc(Bool allocPvn, // IN: TRUE for PVN, FALSE for vnet |
|
* Make proc entry for this jack. |
|
*/ |
|
|
|
- retval = VNetProc_MakeEntry(jack->name, S_IFREG, &jack->procEntry); |
|
+ retval = VNetProc_MakeEntryOps(jack->name, S_IFREG, &jack->procEntry, &proc_hub_fops, jack); |
|
if (retval) { |
|
if (retval == -ENXIO) { |
|
jack->procEntry = NULL; |
|
@@ -362,9 +408,6 @@ VNetHubAlloc(Bool allocPvn, // IN: TRUE for PVN, FALSE for vnet |
|
hub->used[i] = FALSE; |
|
return NULL; |
|
} |
|
- } else { |
|
- jack->procEntry->read_proc = VNetHubProcRead; |
|
- jack->procEntry->data = jack; |
|
} |
|
|
|
/* |
|
@@ -686,46 +729,3 @@ VNetHubIsBridged(VNetJack *this) |
|
} |
|
|
|
|
|
-/* |
|
- *---------------------------------------------------------------------- |
|
- * |
|
- * VNetHubProcRead -- |
|
- * |
|
- * Callback for read operation on hub entry in vnets proc fs. |
|
- * |
|
- * Results: |
|
- * Length of read operation. |
|
- * |
|
- * Side effects: |
|
- * None. |
|
- * |
|
- *---------------------------------------------------------------------- |
|
- */ |
|
- |
|
-int |
|
-VNetHubProcRead(char *page, // IN/OUT: buffer to write into |
|
- char **start, // OUT: 0 if file < 4k, else offset into page |
|
- off_t off, // IN: offset of read into the file |
|
- int count, // IN: maximum number of bytes to read |
|
- int *eof, // OUT: TRUE if there is nothing more to read |
|
- void *data) // IN: client data - not used |
|
-{ |
|
- VNetJack *jack = (VNetJack*)data; |
|
- VNetHub *hub; |
|
- int len = 0; |
|
- |
|
- if (!jack || !jack->private) { |
|
- return len; |
|
- } |
|
- hub = (VNetHub*)jack->private; |
|
- |
|
- len += VNetPrintJack(jack, page+len); |
|
- |
|
- len += sprintf(page+len, "tx %u ", hub->stats[jack->index].tx); |
|
- |
|
- len += sprintf(page+len, "\n"); |
|
- |
|
- *start = 0; |
|
- *eof = 1; |
|
- return len; |
|
-} |
|
--- vmnet-only/netif.c |
|
+++ vmnet-only/netif.c |
|
@@ -62,8 +62,6 @@ static int VNetNetifStartXmit(struct sk_buff *skb, struct net_device *dev); |
|
static struct net_device_stats *VNetNetifGetStats(struct net_device *dev); |
|
static int VNetNetifSetMAC(struct net_device *dev, void *addr); |
|
static void VNetNetifSetMulticast(struct net_device *dev); |
|
-static int VNetNetIfProcRead(char *page, char **start, off_t off, |
|
- int count, int *eof, void *data); |
|
|
|
/* |
|
*---------------------------------------------------------------------- |
|
@@ -116,6 +114,53 @@ VNetNetIfSetup(struct net_device *dev) // IN: |
|
|
|
} |
|
|
|
+/* |
|
+ *---------------------------------------------------------------------- |
|
+ * |
|
+ * VNetNetIfProcShow -- |
|
+ * |
|
+ * Callback for read operation on this netif entry in vnets proc fs. |
|
+ * |
|
+ * Results: |
|
+ * Length of read operation. |
|
+ * |
|
+ * Side effects: |
|
+ * None. |
|
+ * |
|
+ *---------------------------------------------------------------------- |
|
+ */ |
|
+ |
|
+int |
|
+VNetNetIfProcShow(struct seq_file *seqf, // IN/OUT: buffer to write into |
|
+ void *data) // IN: client data |
|
+{ |
|
+ VNetNetIF *netIf = data; |
|
+ |
|
+ if (!netIf) { |
|
+ return 0; |
|
+ } |
|
+ |
|
+ VNetPrintPort(&netIf->port, seqf); |
|
+ |
|
+ seq_printf(seqf, "dev %s ", netIf->dev->name); |
|
+ |
|
+ seq_printf(seqf, "\n"); |
|
+ |
|
+ return 0; |
|
+} |
|
+ |
|
+static int proc_netif_open(struct inode *inode, struct file *file) |
|
+{ |
|
+ return single_open(file, VNetNetIfProcShow, PDE_DATA(inode)); |
|
+} |
|
+ |
|
+static const struct file_operations proc_netif_fops = { |
|
+ .open = proc_netif_open, |
|
+ .read = seq_read, |
|
+ .llseek = seq_lseek, |
|
+ .release = seq_release, |
|
+}; |
|
+ |
|
|
|
/* |
|
*---------------------------------------------------------------------- |
|
@@ -180,16 +225,13 @@ VNetNetIf_Create(char *devName, // IN: |
|
* Make proc entry for this jack. |
|
*/ |
|
|
|
- retval = VNetProc_MakeEntry(netIf->port.jack.name, S_IFREG, |
|
- &netIf->port.jack.procEntry); |
|
+ retval = VNetProc_MakeEntryOps(netIf->port.jack.name, S_IFREG, |
|
+ &netIf->port.jack.procEntry, &proc_netif_fops, netIf); |
|
if (retval) { |
|
netIf->port.jack.procEntry = NULL; |
|
if (retval != -ENXIO) { |
|
goto outFreeDev; |
|
} |
|
- } else { |
|
- netIf->port.jack.procEntry->read_proc = VNetNetIfProcRead; |
|
- netIf->port.jack.procEntry->data = netIf; |
|
} |
|
|
|
/* |
|
@@ -553,45 +595,3 @@ VNetNetifGetStats(struct net_device *dev) // IN: |
|
return &netIf->stats; |
|
} |
|
|
|
- |
|
-/* |
|
- *---------------------------------------------------------------------- |
|
- * |
|
- * VNetNetIfProcRead -- |
|
- * |
|
- * Callback for read operation on this netif entry in vnets proc fs. |
|
- * |
|
- * Results: |
|
- * Length of read operation. |
|
- * |
|
- * Side effects: |
|
- * None. |
|
- * |
|
- *---------------------------------------------------------------------- |
|
- */ |
|
- |
|
-int |
|
-VNetNetIfProcRead(char *page, // IN/OUT: buffer to write into |
|
- char **start, // OUT: 0 if file < 4k, else offset into page |
|
- off_t off, // IN: (unused) offset of read into the file |
|
- int count, // IN: (unused) maximum number of bytes to read |
|
- int *eof, // OUT: TRUE if there is nothing more to read |
|
- void *data) // IN: client data |
|
-{ |
|
- VNetNetIF *netIf = data; |
|
- int len = 0; |
|
- |
|
- if (!netIf) { |
|
- return len; |
|
- } |
|
- |
|
- len += VNetPrintPort(&netIf->port, page+len); |
|
- |
|
- len += sprintf(page+len, "dev %s ", netIf->dev->name); |
|
- |
|
- len += sprintf(page+len, "\n"); |
|
- |
|
- *start = 0; |
|
- *eof = 1; |
|
- return len; |
|
-} |
|
--- vmnet-only/procfs.c |
|
+++ vmnet-only/procfs.c |
|
@@ -45,10 +45,6 @@ |
|
|
|
#if defined(CONFIG_PROC_FS) |
|
|
|
-static int VNetProcMakeEntryInt(VNetProcEntry *parent, char *name, int mode, |
|
- VNetProcEntry **ret); |
|
-static void VNetProcRemoveEntryInt(VNetProcEntry *node, VNetProcEntry *parent); |
|
- |
|
static VNetProcEntry *base = NULL; |
|
|
|
|
|
@@ -71,7 +67,12 @@ static VNetProcEntry *base = NULL; |
|
int |
|
VNetProc_Init(void) |
|
{ |
|
- return VNetProcMakeEntryInt(NULL, "vmnet", S_IFDIR, &base); |
|
+ base = proc_mkdir("vmnet", NULL); |
|
+ if(IS_ERR(base)) { |
|
+ base = NULL; |
|
+ return PTR_ERR(base); |
|
+ } |
|
+ return 0; |
|
} |
|
|
|
|
|
@@ -94,14 +95,14 @@ VNetProc_Init(void) |
|
void |
|
VNetProc_Cleanup(void) |
|
{ |
|
- VNetProcRemoveEntryInt(base, NULL); |
|
+ proc_remove(base); |
|
base = NULL; |
|
} |
|
|
|
/* |
|
*---------------------------------------------------------------------- |
|
* |
|
- * VNetProcMakeEntryInt -- |
|
+ * VNetProc_MakeEntryOps -- |
|
* |
|
* Make an entry in the vnets proc file system. |
|
* |
|
@@ -116,72 +117,21 @@ VNetProc_Cleanup(void) |
|
*/ |
|
|
|
int |
|
-VNetProcMakeEntryInt(VNetProcEntry *parent, // IN: |
|
- char *name, // IN: |
|
+VNetProc_MakeEntryOps(char *name, // IN: |
|
int mode, // IN: |
|
- VNetProcEntry **ret) // OUT: |
|
+ VNetProcEntry **ret, |
|
+ const struct file_operations *fops, |
|
+ void *data |
|
+ ) // OUT: |
|
{ |
|
VNetProcEntry *ent; |
|
- ent = create_proc_entry(name, mode, parent); |
|
+ ent = proc_create_data(name, mode, base, fops, data); |
|
*ret = ent; |
|
if (!ent) |
|
return -ENOMEM; |
|
return 0; |
|
} |
|
|
|
- |
|
-/* |
|
- *---------------------------------------------------------------------- |
|
- * |
|
- * VNetProcRemoveEntryInt -- |
|
- * |
|
- * Remove a previously installed proc entry. |
|
- * |
|
- * Results: |
|
- * None. |
|
- * |
|
- * Side effects: |
|
- * None. |
|
- * |
|
- *---------------------------------------------------------------------- |
|
- */ |
|
- |
|
-void |
|
-VNetProcRemoveEntryInt(VNetProcEntry *node, |
|
- VNetProcEntry *parent) |
|
-{ |
|
- if (node) { |
|
- remove_proc_entry(node->name, parent); |
|
- } |
|
-} |
|
- |
|
- |
|
-/* |
|
- *---------------------------------------------------------------------- |
|
- * |
|
- * VNetProc_MakeEntry -- |
|
- * |
|
- * Make an entry in the vnets proc file system. |
|
- * |
|
- * Results: |
|
- * errno. If errno is 0 and ret is non NULL then ret is filled |
|
- * in with the resulting proc entry. |
|
- * |
|
- * Side effects: |
|
- * None. |
|
- * |
|
- *---------------------------------------------------------------------- |
|
- */ |
|
- |
|
-int |
|
-VNetProc_MakeEntry(char *name, // IN: |
|
- int mode, // IN: |
|
- VNetProcEntry **ret) // OUT: |
|
-{ |
|
- return VNetProcMakeEntryInt(base, name, mode, ret); |
|
-} |
|
- |
|
- |
|
/* |
|
*---------------------------------------------------------------------- |
|
* |
|
@@ -201,7 +151,8 @@ VNetProc_MakeEntry(char *name, // IN: |
|
void |
|
VNetProc_RemoveEntry(VNetProcEntry *node) |
|
{ |
|
- VNetProcRemoveEntryInt(node, base); |
|
+ if(node) |
|
+ proc_remove(node); |
|
} |
|
|
|
|
|
@@ -253,31 +204,6 @@ VNetProc_Cleanup(void) |
|
} |
|
|
|
|
|
-/* |
|
- *---------------------------------------------------------------------- |
|
- * |
|
- * VNetProc_MakeEntry -- |
|
- * |
|
- * Make an entry in the vnets proc file system. |
|
- * |
|
- * Results: |
|
- * errno. If errno is 0 and ret is non NULL then ret is filled |
|
- * in with the resulting proc entry. |
|
- * |
|
- * Side effects: |
|
- * None. |
|
- * |
|
- *---------------------------------------------------------------------- |
|
- */ |
|
- |
|
-int |
|
-VNetProc_MakeEntry(char *name, |
|
- int mode, |
|
- VNetProcEntry **ret) |
|
-{ |
|
- return -ENXIO; |
|
-} |
|
- |
|
|
|
/* |
|
*---------------------------------------------------------------------- |
|
--- vmnet-only/userif.c |
|
+++ vmnet-only/userif.c |
|
@@ -389,7 +389,7 @@ VNetUserIfReceive(VNetJack *this, // IN |
|
/* |
|
*---------------------------------------------------------------------- |
|
* |
|
- * VNetUserIfProcRead -- |
|
+ * VNetUserIfProcShow -- |
|
* |
|
* Callback for read operation on this userif entry in vnets proc fs. |
|
* |
|
@@ -403,30 +403,23 @@ VNetUserIfReceive(VNetJack *this, // IN |
|
*/ |
|
|
|
static int |
|
-VNetUserIfProcRead(char *page, // IN/OUT: buffer to write into |
|
- char **start, // OUT: 0 if file < 4k, else offset into |
|
- // page |
|
- off_t off, // IN: offset of read into the file |
|
- int count, // IN: maximum number of bytes to read |
|
- int *eof, // OUT: TRUE if there is nothing more to |
|
- // read |
|
+VNetUserIfProcShow(struct seq_file *seqf, // IN/OUT: buffer to write into |
|
void *data) // IN: client data - not used |
|
{ |
|
VNetUserIF *userIf = (VNetUserIF*)data; |
|
- int len = 0; |
|
|
|
if (!userIf) { |
|
- return len; |
|
+ return 0; |
|
} |
|
|
|
- len += VNetPrintPort(&userIf->port, page+len); |
|
+ VNetPrintPort(&userIf->port, seqf); |
|
|
|
- len += sprintf(page+len, "read %u written %u queued %u ", |
|
+ seq_printf(seqf, "read %u written %u queued %u ", |
|
userIf->stats.read, |
|
userIf->stats.written, |
|
userIf->stats.queued); |
|
|
|
- len += sprintf(page+len, |
|
+ seq_printf(seqf, |
|
"dropped.down %u dropped.mismatch %u " |
|
"dropped.overflow %u dropped.largePacket %u", |
|
userIf->stats.droppedDown, |
|
@@ -434,13 +427,23 @@ VNetUserIfProcRead(char *page, // IN/OUT: buffer to write into |
|
userIf->stats.droppedOverflow, |
|
userIf->stats.droppedLargePacket); |
|
|
|
- len += sprintf(page+len, "\n"); |
|
+ seq_printf(seqf, "\n"); |
|
|
|
- *start = 0; |
|
- *eof = 1; |
|
- return len; |
|
+ return 0; |
|
+} |
|
+ |
|
+static int proc_userif_open(struct inode *inode, struct file *file) |
|
+{ |
|
+ return single_open(file, VNetUserIfProcShow, PDE_DATA(inode)); |
|
} |
|
|
|
+static const struct file_operations proc_userif_fops = { |
|
+ .open = proc_userif_open, |
|
+ .read = seq_read, |
|
+ .llseek = seq_lseek, |
|
+ .release = seq_release, |
|
+}; |
|
+ |
|
|
|
/* |
|
*---------------------------------------------------------------------- |
|
@@ -1036,8 +1039,8 @@ VNetUserIf_Create(VNetPort **ret) // OUT |
|
* Make proc entry for this jack. |
|
*/ |
|
|
|
- retval = VNetProc_MakeEntry(userIf->port.jack.name, S_IFREG, |
|
- &userIf->port.jack.procEntry); |
|
+ retval = VNetProc_MakeEntryOps(userIf->port.jack.name, S_IFREG, |
|
+ &userIf->port.jack.procEntry, &proc_userif_fops, userIf); |
|
if (retval) { |
|
if (retval == -ENXIO) { |
|
userIf->port.jack.procEntry = NULL; |
|
@@ -1045,9 +1048,6 @@ VNetUserIf_Create(VNetPort **ret) // OUT |
|
kfree(userIf); |
|
return retval; |
|
} |
|
- } else { |
|
- userIf->port.jack.procEntry->read_proc = VNetUserIfProcRead; |
|
- userIf->port.jack.procEntry->data = userIf; |
|
} |
|
|
|
/* |
|
--- vmnet-only/vnetInt.h |
|
+++ vmnet-only/vnetInt.h |
|
@@ -171,12 +171,14 @@ VNetJack *VNetDisconnect(VNetJack *jack); |
|
|
|
void VNetSend(const VNetJack *jack, struct sk_buff *skb); |
|
|
|
-int VNetProc_MakeEntry(char *name, int mode, |
|
- VNetProcEntry **ret); |
|
+int VNetProc_MakeEntryOps(char *name, int mode, |
|
+ VNetProcEntry **ret, |
|
+ const struct file_operations *fops, |
|
+ void *data); |
|
|
|
void VNetProc_RemoveEntry(VNetProcEntry *node); |
|
|
|
-int VNetPrintJack(const VNetJack *jack, char *buf); |
|
+void VNetPrintJack(const VNetJack *jack, struct seq_file *seqf); |
|
|
|
int VNet_MakeMACAddress(VNetPort *port); |
|
|
|
@@ -196,7 +198,7 @@ Bool VNetPacketMatch(const uint8 *destAddr, const uint8 *ifAddr, |
|
|
|
Bool VNetCycleDetectIf(const char *name, int generation); |
|
|
|
-int VNetPrintPort(const VNetPort *port, char *buf); |
|
+void VNetPrintPort(const VNetPort *port, struct seq_file *seqf); |
|
|
|
int VNetSnprintf(char *str, size_t size, const char *format, ...); |
|
|
|
-- |