Archive for the 'Linux' Category

Copy sparsebundle to disk on Linux

I’ve figured out an pretty easy way to copy the contents of a OS X sparsebundle onto a whole disk on linux.
First go into the Image.sparsebundle directory and have a look at the Info.plist. You need the values for size and band-size.
Now in a shell enter:
for i in $(seq 0 $(({size}/{band-size}-1))) ; dd if=`printf "%x" $i` of={/dev/sdx} bs={band-size}c seek=$i ; done
All in one line and replace everything in curly braces with the desired value, e.g. “{band-size}” => “8388608”.

FireWire hard disk emulation

I’ve discovered a way to use a file on a computer as a FireWire Harddisk for another computer. This is a handy way to work with older Apple computers because it’s way easier than burning CD’s or using a read FW HDD.

The setup is not that complicated but still there is some to do.

Continue reading ‘FireWire hard disk emulation’

Apples Integers

I was wondering whether I should use int, long or NSInteger. It took me a bit but I figured it out!

On OS X and iOS the following table shows you the the size of the types:

char       8 bit
short     16 bit
int       32 bit
long      system size
long long 64 bit

So, on 32bit OS X long is 32 bit, on 64bit OS X it’s 64 bit (unsure for iOS).

NSInteger has always the size of an pointer.

Often asked: “Use int or NSInteger?”. Answer: use NSInteger for pointers, ok usually you should use the pointer type itself, and for everything else use the size you require.

If you want exactly 8 bits, use int8_t for sigend or uint8_t for unsigned, for an integer which has at least those bits, use (u)int_least8_t (analogue for 16/32/64 bits).

Performance: you can use (u)int_fast8_t for the fastest type, which can hold (u)int_8_t. But since (u)int_leastY_t and (u)int_fastY_t are defined as (u)intY_t on OS X and iOS it should make no difference. I use the direct types for when all the bits are used, and the fast types when I don’t use exactly but less bits.

At last: don’t forget the LL or ULL suffix for 64bit constants (you can use (U)INT64_C(num) for always the correct suffix, also for 8/16/32), and the “%lld” in a formatted string for 64bit variables.
(example: NSLog(@"number: %lld", 1LL << 48);)

If you have more information or maybe corrections, please post a comment.

Zero-Mailer

This Zero-Mailer is even less than a nullmailer. It is a sendmail replacement which (basic configuration) send all mails to a single email address (ignoring the destination address).

It’s desigend for servers, which are no mail servers, and only sends logs, notices and such things. So all other software (may be scripts, used from the web-server) have to use a SMTP server for outgoing mail (e.g. forum).

It can be configred that when sendmail is invoked by a user, that all those mails are going to another address. (the users which calls sendmail is important, not the destination).

Continue reading ‘Zero-Mailer’