mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 22:37:37 +03:00
da3b124374
Summary: The shell scripts and awk fu did not always work correctly, so use Python to parse the Linux mount table. Reviewed By: mshroyer Differential Revision: D45238375 fbshipit-source-id: 6d8918b8ecbdfe37e8ceba2b0962e5f821794140
43 lines
1.2 KiB
Python
Executable File
43 lines
1.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
import argparse
|
|
import shlex
|
|
import subprocess
|
|
import tempfile
|
|
|
|
|
|
def read_eden_mounts():
|
|
with open("/proc/mounts") as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
mount_type, rest = line.split(maxsplit=1)
|
|
mount_path, proto, flags, x, y = rest.rsplit(maxsplit=4)
|
|
if mount_type.startswith("edenfs:"):
|
|
yield mount_type, mount_path
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
group = parser.add_mutually_exclusive_group(required=True)
|
|
group.add_argument("--all", action="store_true")
|
|
group.add_argument("--tmp", action="store_true")
|
|
args = parser.parse_args()
|
|
|
|
tmp = tempfile.gettempdir()
|
|
|
|
for _mount_type, mount_path in read_eden_mounts():
|
|
if args.tmp and not mount_path.startswith(tmp):
|
|
continue
|
|
cmd = ["sudo", "umount", "-lf", mount_path]
|
|
print(" ".join(map(shlex.quote, cmd)))
|
|
if subprocess.call(cmd):
|
|
print("umount failed")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|