Adapted mount.c to use the Haiku mounting API instead of the on found in BeOS.
New unmount.c that now also use the new API, and accepts the new -f flag to force unmounts in case of open files. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9572 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
2c4f728f7e
commit
232b61f7be
@ -30,7 +30,7 @@ StdBinCommands
|
||||
unmount.c
|
||||
waitfor.c
|
||||
whoami.c
|
||||
;
|
||||
: libroot.so ;
|
||||
|
||||
StdBinCommands
|
||||
top.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 <fs_volume.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
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;
|
||||
|
@ -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 <stdio.h>
|
||||
#include <fs_volume.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
static void
|
||||
usage(const char *programName)
|
||||
{
|
||||
if(argc != 2)
|
||||
{
|
||||
fprintf(stderr, "usage: unmount path\n");
|
||||
return 1;
|
||||
|
||||
printf("usage: %s [-f] <path to volume>\n"
|
||||
"\t-f\tforces unmounting in case of open files left\n", programName);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(unmount(argv[1]) < 0)
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
fprintf(stderr, "unmount: %s\n", strerror(errno));
|
||||
return 1;
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user