source: common/kernfs.xsl@ bea551c

trunk
Last change on this file since bea551c was aceacf2, checked in by Pierre Labastie <pierre.labastie@…>, 16 months ago

Modify kernfs scripts to be able to run them twice

Those scripts could only be run once, because mount errors out
if it tries to mount an already mounted fs (or unmount a non
mounted fs). This changes generation of the scripts so that

any mount is preceded with "mountpoint -q
", and any umount

is preceded with "mountpoint -q && ".

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[13c475b]1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<xsl:stylesheet
4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 version="1.0">
6
7 <xsl:output method="text"/>
8
9 <xsl:template match="/">
[87eb9e9]10 <xsl:text>#!/bin/bash
11</xsl:text>
[13c475b]12 <xsl:apply-templates select="//userinput[contains(string(),'--bind') or
13 contains(string(),'/proc') or
[47dfc81]14 contains(string(),'readlink') or
15 contains(string(),'-Rv')]"/>
[13c475b]16 </xsl:template>
17
18 <xsl:template match="userinput">
[aceacf2]19 <xsl:call-template name="check-mount">
20 <xsl:with-param name="mytext" select="string()"/>
21 </xsl:call-template>
[13c475b]22 <xsl:text>
23</xsl:text>
24 </xsl:template>
25
[aceacf2]26 <xsl:template name="check-mount">
27 <xsl:param name="mytext" select="''"/>
28 <xsl:choose>
29 <xsl:when test="contains($mytext,'&#xA;')">
30 <xsl:call-template name="check-mount">
31 <xsl:with-param name="mytext"
32 select="substring-before($mytext,'&#xA;')"/>
33 </xsl:call-template>
34 <xsl:text>&#xA;</xsl:text>
35 <xsl:call-template name="check-mount">
36 <xsl:with-param name="mytext"
37 select="substring-after($mytext,'&#xA;')"/>
38 </xsl:call-template>
39 </xsl:when>
40 <xsl:when test="starts-with(normalize-space($mytext),'mountpoint')">
41 <xsl:copy-of select="$mytext"/>
42 </xsl:when>
43 <xsl:when test="starts-with(normalize-space($mytext),'mount')">
44 <xsl:variable name="mountpoint">
45 <xsl:call-template name="last-arg">
46 <xsl:with-param name="myline" select="$mytext"/>
47 </xsl:call-template>
48 </xsl:variable>
49 <xsl:text>mountpoint -q </xsl:text>
50 <xsl:copy-of select="$mountpoint"/>
51 <xsl:text> || </xsl:text>
52 <xsl:copy-of select="$mytext"/>
53 </xsl:when>
54 <xsl:when test="starts-with(normalize-space($mytext),'umount')">
55 <xsl:variable name="mountpoint">
56 <xsl:call-template name="last-arg">
57 <xsl:with-param name="myline" select="$mytext"/>
58 </xsl:call-template>
59 </xsl:variable>
60 <xsl:text>mountpoint -q </xsl:text>
61 <xsl:copy-of select="$mountpoint"/>
62 <xsl:text> &amp;&amp; </xsl:text>
63 <xsl:copy-of select="$mytext"/>
64 </xsl:when>
65 <xsl:otherwise>
66 <xsl:copy-of select="$mytext"/>
67 </xsl:otherwise>
68 </xsl:choose>
69 </xsl:template>
70
71 <xsl:template name="last-arg">
72 <xsl:param name="myline" select="''"/>
73 <xsl:choose>
74 <xsl:when test="contains($myline,' ')">
75 <xsl:call-template name="last-arg">
76 <xsl:with-param name="myline" select="substring-after($myline,' ')"/>
77 </xsl:call-template>
78 </xsl:when>
79 <xsl:otherwise>
80 <xsl:copy-of select="$myline"/>
81 </xsl:otherwise>
82 </xsl:choose>
83 </xsl:template>
[13c475b]84</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.