← Back to team overview

marionnet-dev team mailing list archive

Patch pour l'utilisation des tmpfs et variable dans TMPDIR

 

Bonjour,

Ce patch corrige une erreur dans le script de vérification des types de systèmes de fichiers qui empêche de définir la variable TMPDIR avec un tmpfs. En effet, le premier "df" retourne "none" pour $DEV et le premier "none" dans mount correspond à /sys/fs/fuse/connections sur nos machine.

Maintenant TMPDIR est correctement vérifier et on peut également le spécifier dans le fichier de configuration marionnet.conf.

( Merci de vérifier la syntaxe du ocaml au cas ou ;) )

A dans quelques minutes pour un deuxième mails ;)

A+

--
----------------------------------------------
Pierre BLONDEAU
Administrateur Systèmes & réseaux
Université de Caen
Laboratoire GREYC, Département d'informatique

tel	: 02 31 56 75 42
bureau	: Campus 2, Science 3, 406
----------------------------------------------
--- marionnet-trunk-orig-366/configuration.ml   2012-09-13 08:16:23.918973000 +0200
+++ marionnet-trunk/configuration.ml    2012-09-12 13:16:54.252346461 +0200
@@ -47,5 +47,6 @@
                 "MARIONNET_MACHINE_KERNEL";
                 "MARIONNET_ROUTER_PORT0_DEFAULT_IPV4_CONFIG";
                 "MARIONNET_DISABLE_WARNING_TEMPORARY_WORKING_DIRECTORY_AUTOMATICALLY_SET";
+                "MARIONNET_TMPDIR_PATH";
               ]
     ();;
--- marionnet-trunk-orig-366/etc/marionnet.conf 2012-09-13 08:16:23.918973000 +0200
+++ marionnet-trunk/etc/marionnet.conf  2012-09-12 13:50:31.976583389 +0200
@@ -78,5 +78,8 @@
 # Default for the factory-set configuration address for routers
 MARIONNET_ROUTER_PORT0_DEFAULT_IPV4_CONFIG=192.168.1.254/24

+# Default temprorary working directory ( enable fs : reiserfs reiser4 ext4 ext4dev ext3 ext2 udf ntfs jfs ufs tmpfs vxfs xiafs )
+MARIONNET_TMPDIR_PATH=/tmp
+
 # Disable warnings:
 #MARIONNET_DISABLE_WARNING_TEMPORARY_WORKING_DIRECTORY_AUTOMATICALLY_SET=true
--- marionnet-trunk-orig-366/initialization.ml  2012-09-13 08:16:23.918973000 +0200
+++ marionnet-trunk/initialization.ml   2012-09-12 14:01:34.902474539 +0200
@@ -197,6 +197,8 @@
  let user_filesystems = user_home^"/.marionnet/filesystems"
  let user_kernels = user_home^"/.marionnet/kernels"

+ let tmp_dir = configuration_variable_or "MARIONNET_TMPDIR_PATH"
+
 end (* Path *)
 ;;
--- marionnet-trunk-orig-366/marionnet.ml       2012-09-13 08:16:23.918973000 +0200
+++ marionnet-trunk/marionnet.ml        2012-09-12 14:04:39.146335240 +0200
@@ -182,9 +182,9 @@
    st#temporary_directory#set dir;
    warning_tmp_automatically_set_for_you dir
  in
- let tmpdir = try Sys.getenv "TMPDIR" with _ -> "/tmp" in
+ let tmpdir = try Sys.getenv "TMPDIR" with _ -> "" in
  let home   = try Some (Sys.getenv "HOME") with _ -> None in
- let d1 = if tmpdir="" then "/tmp" else tmpdir in                (* ${TMPDIR:-/tmp} *)
+ let d1 = if tmpdir="" then Initialization.Path.tmp_dir else tmpdir in (* ${TMPDIR:-/tmp} *)
  let d2 = "/tmp"                               in                (*  /tmp  *)
  let d3 = Initialization.cwd_at_startup_time   in                (*  $PWD  *)
  let d4 = Option.map (fun h -> Filename.concat h "tmp") home in  (*  ~/tmp *)
--- marionnet-trunk-orig-366/scripts/can-directory-host-sparse-files.sh 2012-09-13 08:16:23.918973000 +0200
+++ marionnet-trunk/scripts/can-directory-host-sparse-files.sh  2012-09-13 08:27:01.518898925 +0200
@@ -16,20 +16,43 @@

 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+function get_mount_point() {
+    MOUNT=""
+    DIR=$1
+    [ -d "${DIR}" ] || DIR=`dirname "${DIR}"`
+    while [ -z "${MOUNT}" ]
+    do
+        RES=`mount -l | awk '{print $3}' | grep "^${DIR}$"`
+        if [ -n "${RES}" ]
+        then
+            MOUNT="${DIR}"
+        fi
+        DIRN=`dirname "${DIR}"`
+        if [ "${DIR}" = "${DIRN}" ]
+        then
+             break
+        else
+            DIR="${DIRN}"
+        fi
+    done
+    echo "${MOUNT}"
+}
+
 DIR=${1:-$PWD}

-[[ -d "$DIR" ]] || {
+[[ -d "${DIR}" ]] || {
  echo "Directory doesn't exist. Exiting."
  exit 3
 } >&2

 # The device containing the directory
-DEV=$(df -P "$DIR" | tail -n -1 | grep "^[a-zA-Z/0-9]" | awk '{print $1}')
+DEV=$(get_mount_point "${DIR}")

 # The filesystem type of the device
-FSTYPE=$(mount -l | grep "^${DEV} " | awk '{print $5}' | head -n 1)
+FSTYPE=$(mount -l | awk '{print $3,$5}' | grep "^${DEV}"| awk '{print $2}' | head -n 1)

-[[ -n "$FSTYPE" ]] || {
+[[ -n "${FSTYPE}" ]] || {
  echo "Cannot determine the filesystem type. Exiting."
  exit 2
 } >&2
@@ -37,6 +60,6 @@
 # Check if the filesystem type belongs the white list.
 # Note that apparently xfs no longer supports sparse files in Ubuntu 12.04 (kernel 3.2).
 WHITE_LIST="reiserfs reiser4 ext4 ext4dev ext3 ext2 udf ntfs jfs ufs tmpfs vxfs xiafs"
-echo "$WHITE_LIST" | grep -qw "$FSTYPE"
+echo "${WHITE_LIST}" | grep -qw "${FSTYPE}"

 exit $?


Follow ups