[kernel-tests] 30/73: Add some utility functions to create and mount loopback filesystems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is an automated email from the git hooks/post-receive script.

jforbes pushed a commit to branch master
in repository kernel-tests.

commit 0ca76cd70357cfca0aece9594f3168d9f945f154
Author: Josh Boyer <jwboyer@xxxxxxxxxx>
Date:   Wed May 29 13:08:15 2013 -0400

    Add some utility functions to create and mount loopback filesystems
---
 utils/loopback.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/utils/loopback.sh b/utils/loopback.sh
new file mode 100644
index 0000000..3179c43
--- /dev/null
+++ b/utils/loopback.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+create_sparse_file() {
+	dd if=/dev/zero of=$1 bs=1 count=0 seek=$2M ;
+	return $?
+}
+
+create_fs() {
+	loopdev=`losetup --find --show $2`;
+	echo $loopdev
+	mkfs -t $1 $loopdev ;
+	losetup --detach $loopdev
+	return $?
+}
+
+mount_image() {
+	mount -t $1 -o loop $2 $3 ;
+	return $?
+}
+
+loopback_fs() {
+	file=$1;
+	size=$2;
+	fs=$3;
+	mountpoint=$4;
+
+	create_sparse_file $file $size;
+	rc=$?
+	if [ $rc -ne 0 ]
+	then
+		echo "Could not create spare file $file"
+		return 3
+	fi
+
+	create_fs $fs $file
+	if [ $rc -ne 0 ]
+	then
+		echo "Could not create $fs on $file"
+		return 3
+	fi
+	
+	mount_image $fs $file $mountpoint
+	if [ $rc -ne 0 ]
+	then
+		echo "Could not mount $fs filesystem on $file at $mountpoint"
+		return 3
+	fi
+
+	return 0
+}	

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
kernel mailing list
kernel@xxxxxxxxxxxxxxxxxxxxxxx
https://lists.fedoraproject.org/admin/lists/kernel@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Tux]     [Yosemite News]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [USB]     [Asterisk PBX]

  Powered by Linux