summaryrefslogtreecommitdiff
path: root/contrib/osx-ramdisk.patch
blob: b1738b0dcf432a1814c762510f92a7981a71a0ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
From 9f640573906bf7f98133006d09cb2bddca5ec5ae Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Wed, 12 Sep 2012 21:08:56 +0200
Subject: [PATCH] Use ramdisk for volatile storage in OSX.

---
 src/password-store.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/password-store.sh b/src/password-store.sh
index c736d7b..33a0e97 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -239,6 +239,19 @@ case "$command" in
 
 		if [[ -d /dev/shm && -w /dev/shm && -x /dev/shm ]]; then
 			tmp_dir="$(TMPDIR=/dev/shm mktemp -t $template -d)"
+		elif [[ $(uname) = "Darwin" ]]; then
+			cleanup_tmp() {
+				[[ -d $tmp_dir ]] || return
+				rm -rf "$tmp_file" "$tmp_dir" 2>/dev/null
+				umount "$tmp_dir"
+				diskutil quiet eject "$ramdisk_dev"
+				rmdir "$tmp_dir"
+			}
+			trap cleanup_tmp INT TERM EXIT
+			tmp_dir="$(mktemp -t $template -d)"
+			ramdisk_dev="$(hdid -drivekey system-image=yes -nomount 'ram://32768' | cut -d ' ' -f 1)" # 32768 sectors = 16 mb
+			newfs_hfs -M 700 "$ramdisk_dev" &>/dev/null || exit 1
+			mount -t hfs -o noatime -o nobrowse "$ramdisk_dev" "$tmp_dir" || exit 1
 		else
 			prompt=$(echo    "Your system does not have /dev/shm, which means that it may"
 			         echo    "be difficult to entirely erase the temporary non-encrypted"
-- 
1.7.12
'/others/cgit.git/commit/ui-view.c?h=v0.6&id=9a8f88658d51aeb86a79ac1121de13562ad2601f&follow=1'>Add ui-commit.c + misc ui cleanupsLars Hjemli9-19/+140 2006-12-15Add a common commit parserLars Hjemli3-63/+75 2006-12-14Add simple pager to log pageLars Hjemli4-6/+37 2006-12-13Add separate makefile-rule to clear current cacheLars Hjemli1-2/+4 2006-12-13Remove implementation details from READMELars Hjemli1-53/+34 2006-12-13Small layout adjustments to summary and blob viewLars Hjemli3-5/+13 2006-12-13Add display of tree content w/ui-tree.cLars Hjemli9-8/+113 2006-12-12cache_lock: do xstrdup/free on lockfileLars Hjemli1-1/+2 2006-12-11Don't truncate valid cachefilesLars Hjemli3-4/+16 2006-12-11Move global variables + callback functions into shared.cLars Hjemli4-82/+86 2006-12-11Move functions for generic object output into ui-view.cLars Hjemli4-34/+43 2006-12-11Move log-functions into ui-log.cLars Hjemli5-111/+121 2006-12-11Move repo summary functions into ui-summary.cLars Hjemli4-47/+59 2006-12-11Move functions for repolist output into ui-repolist.cLars Hjemli5-70/+90 2006-12-11Move common output-functions into ui-shared.cLars Hjemli4-82/+99 2006-12-11Rename config.c to parsing.c + move cgit_parse_query from cgit.c to parsing.cLars Hjemli4-28/+29 2006-12-11Avoid infinite loops in caching layerLars Hjemli3-14/+31 2006-12-11Let 'make install' clear all cachefilesLars Hjemli1-0/+2 2006-12-11Fix cache algorithm loopholeLars Hjemli3-11/+16 2006-12-10Add version identifier in generated filesLars Hjemli2-9/+14 2006-12-10Add license file and copyright noticesLars Hjemli5-0/+372 2006-12-10Add caching infrastructureLars Hjemli9-28/+353