.. on Linux

Posts made in January, 2012

LVM2 device names and device paths

Posted by on Jan 10, 2012 in Computers, Linux | 0 comments

If you use LVM (Linux volume manager) you’ll be no doubt aware that the ability to place your volumes in groups and name the volumes accordingly makes administration much easier. Having a volume group called oracle and then a binaries and data volume means a tiny glance at a system identifies what is doing what (or so I was under the impression). When it comes to doing any sort of low level administration or system metrics, you may notice that device paths change. Using fdisk or looking at /proc metrics and you’ll suddenly come across dm-0 etc..  devices, which clearly are the lvm devices under another name. Scanning quickly through a ton of web pages and the lvm2 documentation turned up nothing.

Then I realised that the first two columns in /proc/diskstats where the major/minor device numbers, which when compared with the entries in /dev/mapper allowed me to match up the devices. This can also be achieved by looking at the major/minor numbers from lvdisplay and dmsetup ls. However the latter two tools require root privileges so clearly were not going to work with my current project.

Turned out that the simplest method is to look through the sysfs file hierarchy as the block devices can identify other names that they have. The following command will iterate all of the block devices with alternative names and print them in a format that can be piped into anything else, or in my case be read easily into an NSArray.

grep -H "." /sys/devices/virtual/block/*/dm/name \
| sed 's/\/sys\/devices\/virtual\/block\///g' \
| sed 's/\/dm\/name:/ /g'

		Read More
	

Window handling from the dock icon (Objective-C / Xcode)

Posted by on Jan 10, 2012 in Xcode | 0 comments

I should probably post this stuff to stackoverflow, however I find that most of the people on there are rude and spend far too much time just berating anyone who asks for the slightest help. I apologise for anyone who had to waste time looking a little bit longer for this tip.

The default behaviour for a cocoa window when it’s closed with cmd+w or pressing the red X button is for the window to be closed ((but not destroyed) this applies to the main window, others may be created to release etc..). This means that the window simply needs being passed the makeKeyAndOrderFront: method to be made visible when its dock icon is clicked on:

 

-(BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
{
if (flag)
  {
 NSLog(@"Window already open");
  } else {
   [_window makeKeyAndOrderFront:self];
  }
 return YES;
}
Read More

Disposable

Posted by on Jan 2, 2012 in Photos | 0 comments

 

 

I finally crumbled and gave the gimmicky disposable app a go, sharing some film with a friend(@Grizly_Chops) form New Zealand. Initially I found the experience a bit annoying as i’ve become so used to immediately viewing my results, usually deleting just as quick and lining up a shot for attempt 2/3/4/… I hadn’t really paid it a huge amount of attention just taking a pic here and there although was pretty excited when my phone dinged this morning telling me the roll was finished.

I think the results are pretty nice, a couple of duplicate shots have appeared I assume this is due to not being able to see results. Might try a different roll of film and try to recruit some more snappers.

Read More