-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
230 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os | ||
import os.path | ||
import subprocess | ||
import sys | ||
|
||
|
||
def main(path): | ||
# If the path does not exist, we will create but need to verify it lives on the same volume | ||
if not os.path.exists(path): | ||
if path.endswith('/'): | ||
path = path.rstrip('/') | ||
path = os.path.dirname(path) | ||
|
||
# bail out if the parent path is not found | ||
if not os.path.exists(path): | ||
sys.exit(2) | ||
|
||
try: | ||
sys.stdout.write(subprocess.check_output(["findmnt", "--output", "UUID,fstype", "--json", "--target", path]).decode().strip()) | ||
except subprocess.SubprocessError as exc: | ||
print(exc, file=sys.stderr) | ||
sys.exit(3) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 2: | ||
sys.stderr.write("Path not provided\n") | ||
sys.exit(1) | ||
|
||
main(sys.argv[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os | ||
import os.path | ||
import subprocess | ||
import sys | ||
|
||
|
||
def main(path): | ||
# If the path does not exist, we will create but need to verify it lives on the same volume | ||
if not os.path.exists(path): | ||
if path.endswith('/'): | ||
path = path.rstrip('/') | ||
path = os.path.dirname(path) | ||
|
||
# bail out if the parent path is not found | ||
if not os.path.exists(path): | ||
sys.exit(2) | ||
|
||
try: | ||
print(subprocess.check_output(["findmnt", "--output", "UUID", "--no-heading", "--target", path])) | ||
except subprocess.SubprocessError as exc: | ||
print(exc, file=sys.stderr) | ||
sys.exit(3) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 2: | ||
sys.stdout.write("Path not provided\n") | ||
sys.exit(1) | ||
|
||
main(sys.argv[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters