! UPDATE: Wicked Cool GUI here !
!! Much kudos to Erica for the lovely TUAW post !!
You can find out more about Erica's
substantial work on the iPhone here
We also seem to have made it to the top of the 10 of the digg.com tech section,
and to the front page of the "Top 10 in All Topics"
(We are very 'psyched' about this)

new - to enable bonjour
# ./dns-sd -R iPhoneFileServer _afpovertcp._tcp local. 548 &
[3] 54
Registering Service iPhoneFileServer._afpovertcp._tcp.local. port 548
Got a reply for iPhoneFileServer._afpovertcp._tcp.local.: Name now registered an
d active
Then it is published:
# ps aux | grep mDNS
root 20 0.0 0.0 273696 792 ?? Ss 1:47PM 0:00.34 /usr/sbin/mDNS
Responder -launchd
root 57 0.0 0.0 274156 0 p0 R 1:54PM 0:00.00 grep mDNS
This command will log to syslog:
# kill -info 20
# Nov 11 13:54:33 localhost mDNSResponder-118 (Jul 12 2007 23: 24:35)[20]:
---- BEGIN STATE LOG ----
Nov 11 13:54:33 localhost : Timenow 0x9279574D (-1837541555)
Nov 11 13:54:33 localhost : ------------ Cache -------------
Nov 11 13:54:33 localhost : Slt Q TTL if U Type rdlen
Nov 11 13:54:33 localhost : 223 * 1878666 -U- - PTR 13 130.1.168.192.in-addr.arpa. PTR iphone.
Nov 11 13:54:33 localhost : 240 * 1878721 -U- - Addr 4 somehost.attwireless.net. Addr 172.16.9.100
Nov 11 13:54:33 localhost : Cache currently contains 4 records; 2 referenced by active questions
Nov 11 13:54:33 localhost : ---------- Questions -----------
Nov 11 13:54:33 localhost : Int Next if Type
Nov 11 13:54:33 localhost : 3600 3511 O PTR 130.1.168.192.in-addr.arpa.
Nov 11 13:54:33 localhost : 1 question; 1 active
Nov 11 13:54:33 localhost : ---- Active Client Requests ----
Nov 11 13:54:33 localhost : 11: DNSServiceRegister iPhoneFileServer._afpovertcp._tcp.local. 548
Nov 11 13:54:33 localhost : 10: DNSServiceRegister iPhone._sftp-ssh._tcp.local. 22
Nov 11 13:54:33 localhost : 9: DNSServiceRegister iPhone._ssh._tcp.local. 22
Nov 11 13:54:33 localhost : ------ Network Interfaces ------
Nov 11 13:54:33 localhost : Interface: v4 en0(2) 00:00:00:00:00:00 Active v4 8 -1 InterfaceID 0080DC00 Adv TxRx 192.168.1.130
Nov 11 13:54:33 localhost : Interface: v4 ip2(4) 00:00:00:00:00:00 DORMANT 90
Nov 11 13:54:33 localhost : DNS Server 192.168.1.113 .
Nov 11 13:54:33 localhost : Timenow 0x927957BA (-1837541446)
Nov 11 13:54:33 localhost mDNSResponder-118 (Jul 12 2007 23: 24:35)[20]:
---- END STATE LOG ----
so just grab dns-sd from above!
Notes
Extract the tar.gz file to /opt/iphone/afp/
Then just:
/opt/iphone/afp/startserver.sh
Should start the daemon
Seems fast enough to stream video
Here is a quick demo with a test mpeg tivo'd recording on the iphone:
imac /F12/ du -h FSWA.mp4
415M FSWA.mp4
The file system looks small as it is based off the root FS, but this is in the
media partition, so afp also follows the symlinks correctly (woot!)
AFP Registered Users on the iphone
Added DHX encryption:
Nov 10 13:48:17 localhost afpd[105]: uam: "DHCAST128" available
Nov 10 13:48:33 localhost afpd[106]: ASIP session:548(4) from 192.168.1.127:5018 5(7)
Nov 10 13:48:33 localhost afpd[105]: server_child[1] 106 done
We can now log in as root, same starting instructions as per guest example below.
Also edited uid 0 code in netatalk for this to work:
Two file systems are exported currently, they can be changed in AppleVolume.default in this distro:
Will log this to /var/log/syslog (you need this enabled if you want or need to see this):
Nov 10 13:55:46 localhost afpd[130]: ASIP session:548(4) from 192.168.1.127:50198(7)
Nov 10 13:55:46 localhost afpd[130]: dhx login: root
Nov 10 13:55:46 localhost afpd[130]: login: root login this is bad! but this is an iPhone!
Nov 10 13:55:46 localhost afpd[130]: login root (uid 0, gid 0) AFP2.2
AFP guest on the iphone
Need to connect as guest at the moment - I need to work on the auth.
it also only uses the mtab backend, but for now it will be ok - we can read and
write ok
Thanks to drudge of http://conceitedsoftware.com/iphone/site/
for asking about this, he has packaged most of the stuff on this site from start to end!
19:19 < drudge> how about something using the afp
[ ] afpd.tgz 05-Nov-2007 21:08 131K
21:28 < core> not bad from question to a working web page in two hours :)
So to the code
Extract the tar.gz file to /opt/iphone/afp/
Then just:
/opt/iphone/afp/startserver.sh
Should start the daemon
Then back over on the mac:
imac /afpd/ df -H /Volumes/test\ folder/
Filesystem Size Used Avail Capacity Mounted o
n
afp_2nBRVm2nBRVm2nBRVm2nBRVm-1.2d000007 7.8G 7.2G 609M 92% /Volumes/
test folder
imac /afpd/ touch /Volumes/test\ folder/test
imac /afpd/ time dd if=/dev/zero of=/Volumes/test\ folder/test.dat bs=1024 count=100
100+0 records in
100+0 records out
102400 bytes transferred in 0.000856 secs (119636972 bytes/sec)
0.000u 0.003s 0:00.23 0.0% 0+0k 0+1io 0pf+0w
imac /afpd/ ls -ltra /Volumes/test\ folder/
total 256
drwxrwxrwx 2 core core 264 Nov 5 20:36 Temporary Items
drwxrwxrwx 2 core core 264 Nov 5 20:36 Network Trash Folder
drwxrwxrwt 7 root admin 238 Nov 5 20:47 ..
-rwxrwxrwx 1 core core 0 Nov 5 20:48 test
-rwxrwxrwx 1 core core 102400 Nov 5 20:48 test.dat
drwxrwxrwx 7 core core 264 Nov 5 20:48 .
-rwxrwxrwx 1 core core 6148 Nov 5 20:48 .DS_Store
imac /afpd/ md5 /Volumes/test\ folder/test.dat
MD5 (/Volumes/test folder/test.dat) = 4c6426ac7ef186464ecbb0d81cbfcb1e
Back on the iphone:
# md5 /tmp/test/test.dat
4c6426ac7ef186464ecbb0d81cbfcb1e /tmp/test/test.dat
Result!
You can change the export by editing this file:
# cat /opt/iphone/afp/etc/netatalk/AppleVolumes.system
/tmp/test "test folder" cnidscheme:mtab
Remember that the daemon runs as nobody, so currently can only see chmod 777 are as :)
Real world speed tests, 2+ seconds for a 3.1MB file:
imac /Flood/ time cp 02\ Birdhouse\ in\ Your\ Soul.m4p /Volumes/iPhone\ Root/
0.000u 0.036s 0:02.85 1.0% 0+0k 0+0io 0pf+0w
imac /Flood/ du -h 02\ Birdhouse\ in\ Your\ Soul.m4p
3.1M 02 Birdhouse in Your Soul.m4p