applied style patch by Vasilis Kaoutsis

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19601 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2006-12-22 08:17:16 +00:00
parent 6e194a72e7
commit 422f8ec3ee
1 changed files with 53 additions and 52 deletions

View File

@ -1,78 +1,80 @@
// isvolume - for OpenBeOS /*
// * Copyright 2002-2006, Haiku Inc. All rights reserved.
// authors, in order of contribution: * Distributed under the terms of the MIT License.
// jonas.sundstrom@kirilla.com *
// * Authors:
* Jonas Sundstrom, jonas.sundstrom@kirilla.com
*/
#include <fs_info.h>
// std C includes
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
// BeOS C includes void Usage();
#include <fs_info.h>
void print_help (void); int
main(int32 argc, char** argv)
int main (int32 argc, char **argv)
{ {
dev_t vol_device = dev_for_path("."); dev_t volumeDevice = dev_for_path(".");
uint32 is_volume_flags = 0; uint32 isVolumeFlags = 0;
fs_info volume_info; fs_info volumeInfo;
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++) {
{ if (!strcmp(argv[i], "--help")) {
if (! strcmp(argv[i], "--help")) Usage();
{ return 0;
print_help();
return (0);
} }
if (argv[i][0] == '-') if (argv[i][0] == '-') {
{ if (! strcmp(argv[i], "-readonly"))
if (! strcmp(argv[i], "-readonly")) is_volume_flags |= B_FS_IS_READONLY; isVolumeFlags |= B_FS_IS_READONLY;
else if (! strcmp(argv[i], "-query")) is_volume_flags |= B_FS_HAS_QUERY; else if (! strcmp(argv[i], "-query"))
else if (! strcmp(argv[i], "-attribute")) is_volume_flags |= B_FS_HAS_ATTR; isVolumeFlags |= B_FS_HAS_QUERY;
else if (! strcmp(argv[i], "-mime")) is_volume_flags |= B_FS_HAS_MIME; else if (! strcmp(argv[i], "-attribute"))
else if (! strcmp(argv[i], "-shared")) is_volume_flags |= B_FS_IS_SHARED; isVolumeFlags |= B_FS_HAS_ATTR;
else if (! strcmp(argv[i], "-persistent")) is_volume_flags |= B_FS_IS_PERSISTENT; else if (! strcmp(argv[i], "-mime"))
else if (! strcmp(argv[i], "-removable")) is_volume_flags |= B_FS_IS_REMOVABLE; isVolumeFlags |= B_FS_HAS_MIME;
else else if (! strcmp(argv[i], "-shared"))
{ isVolumeFlags |= B_FS_IS_SHARED;
fprintf(stderr, "%s: option %s is not understood (use --help for help)\n", argv[0], argv[i]); else if (! strcmp(argv[i], "-persistent"))
return (-1); isVolumeFlags |= B_FS_IS_PERSISTENT;
else if (! strcmp(argv[i], "-removable"))
isVolumeFlags |= B_FS_IS_REMOVABLE;
else {
fprintf(stderr,
"%s: option %s is not understood (use --help for help)\n", argv[0], argv[i]);
return -1;
} }
} } else {
else volumeDevice = dev_for_path(argv[i]);
{
vol_device = dev_for_path(argv[i]);
if (vol_device < 0) if (volumeDevice < 0) {
{
fprintf(stderr, "%s: can't get information about volume: %s\n", argv[0], argv[i]); fprintf(stderr, "%s: can't get information about volume: %s\n", argv[0], argv[i]);
return (-1); return -1;
} }
} }
} }
if(fs_stat_dev(vol_device, & volume_info) == B_OK) if (fs_stat_dev(volumeDevice, &volumeInfo) == B_OK) {
{ if (volumeInfo.flags & isVolumeFlags)
if (volume_info.flags & is_volume_flags)
printf("yes\n"); printf("yes\n");
else else
printf("no\n"); printf("no\n");
return (0); return 0;
} } else {
else fprintf(stderr, "%s: can't get information about dev_t: %ld\n", argv[0], volumeDevice);
{ return -1;
fprintf(stderr, "%s: can't get information about dev_t: %ld\n", argv[0], vol_device);
return (-1);
} }
} }
void print_help (void)
void
Usage()
{ {
fprintf (stderr, fprintf(stderr,
"Usage: isvolume {-OPTION} [volumename]\n" "Usage: isvolume {-OPTION} [volumename]\n"
" Where OPTION is one of:\n" " Where OPTION is one of:\n"
" -readonly - volume is read-only\n" " -readonly - volume is read-only\n"
@ -87,4 +89,3 @@ void print_help (void)
" can be specified in which case all of them must be true.\n\n" " can be specified in which case all of them must be true.\n\n"
" If no volume is specified, the volume of the current directory is assumed.\n"); " If no volume is specified, the volume of the current directory is assumed.\n");
} }