Welcome

Pacific Simplicity is the home to my tech blog of sorts, aiming to assist and provide information easily to other Linux users and Open Source hackers out there.  It contains articles on Linux, system admin hints, scripting, programming embedded systems, OpenWRT and of course Drupal . Check it out and don't forget to comment!

Posted: Thu, 12/03/2015 - 13:15

I recently ran across some code for some students that was terribly written regarding sockets and upon helping them - I realized, that most examples just abhorrently throw all of the required code into the program with no function calls to help segment/make sense of it.

Here is my example programs - note that the actual socket code is wrapped up in socket.c & shared.h:

Posted: Sun, 06/07/2015 - 03:36

Here is a quick ring buffer example, I wrote up for a hackathon.

/**
 * @file data_struct.c
 * @author Ron Brash (ron.brash @ gmail.com)
 * @brief Simple array ring buffer, its not super careful, but illustrates the connect
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define ELEMENT_SIZE 32

Posted: Thu, 04/02/2015 - 13:38

Creating custom menu items is simple - all you need to do is this inside of your package (OpenWRT) Makefiles

define Package/wiringPi
        SECTION:=libs
        CATEGORY:=<YOUR NEW SECTION WHICH IS IN THE ROOT OF THE MENU>
        TITLE:=wiringPi
        SUBMENU:=<YOUR NEW SUBSECTION INSIDE OF YOUR NEW CATEGORY ITEM>
        DEPENDS:=+libpthread
endef
Posted: Mon, 03/30/2015 - 11:49

Knowing after a large Kernel version jump, compiling VMware will result in failed module compilation. Instead of subscribing to VMware's horrible product model - "buy new versions because we won't support our products with patches", I decided to make VMware VMnet modules work by patching the source. This works on Ubuntu x64, 15.04 Beta2.

In vmnet.tar:vmnet-only/userif.c, near line 470: modify the source to look like the following:

#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
        return skb_copy_datagram_iovec(skb, 0, &iov, len);
#else
        struct iov_iter to;
        iov_iter_init(&to, READ, &iov, 1, len);
        return skb_copy_datagram_iter(skb, 0, &to, len);
#endif

In vmnet.tar:vmnet-only/driver.c, near line 274: modify the source to look like the following:

#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
        if (filp && filp->f_op && filp->f_op->ioctl == VNetFileOpIoctl) {
                ret = VNetFileOpIoctl(filp->f_dentry->d_inode, filp, iocmd, ioarg);
        }
        return ret;
#else
        if (filp && filp->f_op && filp->f_op->ioctl == VNetFileOpIoctl) {
                ret = VNetFileOpIoctl(filp->f_path.dentry->d_inode, filp, iocmd, ioarg);
        }
        return ret;
#endif

Then at line 1245:

#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
 if (filp && filp->f_dentry) {
 inode = filp->f_dentry->d_inode;
 }
 err = VNetFileOpIoctl(inode, filp, iocmd, ioarg);
 return err;
#else
 if (filp && filp->f_path.dentry) {
 inode = filp->f_path.dentry->d_inode;
 }
 err = VNetFileOpIoctl(inode, filp, iocmd, ioarg);
 return err;
#endif

In vmnet.tar:vmnet-only/filter.c, near line 205: modify the source to look like the following:

#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
VNetFilterHookFn(unsigned int hooknum,                 // IN:
#else
VNetFilterHookFn(const struct nf_hook_ops *ops,        // IN:
#endif

And near line 259:

#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
       transmit = (hooknum == VMW_NF_INET_POST_ROUTING);
    #else
       transmit = (ops->hooknum == VMW_NF_INET_POST_ROUTING);
    #endif);

In vmnet.tar:vmnet-only/netif.c at near line 152;

netif.c in /usr/lib/vmware/modules/source/vmnet.tar:

#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
dev = alloc_netdev(sizeof *netIf, deviceName, VNetNetIfSetup);
#else
dev = alloc_netdev(sizeof *netIf, deviceName, NET_NAME_UNKNOWN, VNetNetIfSetup);
#endif
Posted: Thu, 03/12/2015 - 10:47
#!/bin/sh
grep -r -l --include *.c --include *.h . > filelist
while read file; do
        OUTPUT=`pmccabe -F $file 2>/dev/null | sed -r -e "s/[\t\ ]+/,/g"|cut -d, -f1-5`
        FILENAME=`echo  $p | sed 's/.*\///'`
        echo $OUTPUT","$FILENAME","$file

done < filelist