diff --git a/src/apps/bin/Jamfile b/src/apps/bin/Jamfile index 22d6fcb08f..2eeb132cb3 100644 --- a/src/apps/bin/Jamfile +++ b/src/apps/bin/Jamfile @@ -30,7 +30,7 @@ StdBinCommands unmount.c waitfor.c whoami.c - ; + : libroot.so ; StdBinCommands top.c diff --git a/src/apps/bin/mount.c b/src/apps/bin/mount.c index 661f8b2a58..db399e8f62 100644 --- a/src/apps/bin/mount.c +++ b/src/apps/bin/mount.c @@ -1,20 +1,17 @@ /* -** Copyright (c) 2001-2002, OpenBeOS -** -** This software is part of the OpenBeOS distribution and is covered -** by the OpenBeOS license. -** -** File: mount.c -** Author: Axel Dörfler (axeld@users.sf.net) -** Description: mounts a volume with the specified file system +** Copyright 2001-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the Haiku License. */ +/** Mounts a volume with the specified file system */ + + +#include -#include -#include -#include #include -#include +#include +#include +#include static void @@ -36,7 +33,8 @@ main(int argc, char **argv) const char *parameter = NULL; const char *fs = NULL; struct stat mountStat; - int flags = 0; + status_t status; + uint32 flags = 0; /* prettify the program name */ @@ -82,8 +80,9 @@ main(int argc, char **argv) /* do the work */ - if (mount(fs, mountPoint, device, flags, (void *)parameter, parameter ? strlen(parameter) : 0) < 0) { - fprintf(stderr, "%s: %s\n", programName, strerror(errno)); + status = fs_mount_volume(fs, mountPoint, device, flags, parameter); + if (status != B_OK) { + fprintf(stderr, "%s: %s\n", programName, strerror(status)); return -1; } return 0; diff --git a/src/apps/bin/unmount.c b/src/apps/bin/unmount.c index 973b747449..f35784c466 100644 --- a/src/apps/bin/unmount.c +++ b/src/apps/bin/unmount.c @@ -1,26 +1,76 @@ -// Author: Ryan Fleet -// Created: October 11th 2002 -// Modified: October 12th 2002 +/* +** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the Haiku License. +*/ + +/** Unmounts a volume */ -#include +#include + +#include #include -#include +#include #include -int main(int argc, char *argv[]) + +static void +usage(const char *programName) { - if(argc != 2) - { - fprintf(stderr, "usage: unmount path\n"); - return 1; - } - if(unmount(argv[1]) < 0) - { - fprintf(stderr, "unmount: %s\n", strerror(errno)); - return 1; + printf("usage: %s [-f] \n" + "\t-f\tforces unmounting in case of open files left\n", programName); + exit(0); +} + + +int +main(int argc, char **argv) +{ + const char *programName = argv[0]; + struct stat pathStat; + const char *path; + status_t status; + uint32 flags = 0; + + /* prettify the program name */ + + if (strrchr(programName, '/')) + programName = strrchr(programName, '/') + 1; + + /* get all options */ + + while (*++argv) { + char *arg = *argv; + if (*arg != '-') + break; + + if (!strcmp(arg, "f")) + flags |= B_FORCE_UNMOUNT; + else + usage(programName); } - + + path = argv[0]; + + /* check the arguments */ + + if (path == NULL) + usage(programName); + + if (stat(path, &pathStat) < 0) { + fprintf(stderr, "%s: The path \"%s\" is not accessible\n", programName, path); + return -1; + } + + /* do the work */ + + status = fs_unmount_volume(path, flags); + if (status != B_OK) { + fprintf(stderr, "%s: unmounting failed: %s\n", programName, strerror(status)); + return -1; + } + return 0; } +