utilities/utilities/namespace-utils/namespace-utils/umount-in-namespace

26 lines
545 B
Bash

#!/bin/bash
#
# Copyright (c) 2015 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
MNT=$1
SELF_NS=$(ls -l /proc/self/ns/mnt 2>/dev/null| sed -r 's/.*\[(.*)\]/\1/')
ls -l /proc/*/ns/mnt 2>/dev/null| sed -r 's/.*\[(.*)\]/\1/' | sort -u | while read ns
do
if [ "$ns" = "$SELF_NS" ]
then
continue
fi
ls -l /proc/*/ns/mnt 2>/dev/null | grep $ns |grep '/proc/[0-9]*/' | sed -r 's#.*/proc/([0-9]*)/ns.*#\1#' | while read pid
do
echo "umount -n -l $MNT" | /usr/sbin/bashns $pid
done
done