[48e3190] | 1 | /*
|
---|
| 2 | * Copyright (c) 2006 Martin Decky
|
---|
| 3 | * Copyright (c) 2008 Jakub Jermar
|
---|
| 4 | * Copyright (c) 2012 Julia Medvedeva
|
---|
| 5 | * All rights reserved.
|
---|
| 6 | *
|
---|
| 7 | * Redistribution and use in source and binary forms, with or without
|
---|
| 8 | * modification, are permitted provided that the following conditions
|
---|
| 9 | * are met:
|
---|
| 10 | *
|
---|
| 11 | * - Redistributions of source code must retain the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer.
|
---|
| 13 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 14 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 15 | * documentation and/or other materials provided with the distribution.
|
---|
| 16 | * - The name of the author may not be used to endorse or promote products
|
---|
| 17 | * derived from this software without specific prior written permission.
|
---|
| 18 | *
|
---|
| 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 29 | */
|
---|
| 30 |
|
---|
| 31 | /** @addtogroup fs
|
---|
| 32 | * @{
|
---|
| 33 | */
|
---|
| 34 | /**
|
---|
| 35 | * @file udf.c
|
---|
| 36 | * @brief UDF 1.02 file system driver for HelenOS.
|
---|
| 37 | */
|
---|
| 38 |
|
---|
| 39 | #include <ipc/services.h>
|
---|
| 40 | #include <ns.h>
|
---|
| 41 | #include <async.h>
|
---|
| 42 | #include <errno.h>
|
---|
[c1694b6b] | 43 | #include <str_error.h>
|
---|
[48e3190] | 44 | #include <task.h>
|
---|
| 45 | #include <libfs.h>
|
---|
| 46 | #include <str.h>
|
---|
| 47 | #include <io/log.h>
|
---|
| 48 | #include "../../vfs/vfs.h"
|
---|
| 49 | #include "udf.h"
|
---|
| 50 | #include "udf_idx.h"
|
---|
| 51 |
|
---|
| 52 | #define NAME "udf"
|
---|
| 53 |
|
---|
| 54 | vfs_info_t udf_vfs_info = {
|
---|
| 55 | .name = NAME,
|
---|
| 56 | .concurrent_read_write = false,
|
---|
| 57 | .write_retains_size = false,
|
---|
| 58 | .instance = 0,
|
---|
| 59 | };
|
---|
| 60 |
|
---|
| 61 | int main(int argc, char *argv[])
|
---|
| 62 | {
|
---|
[70253688] | 63 | log_init(NAME);
|
---|
| 64 | log_msg(LOG_DEFAULT, LVL_NOTE, "HelenOS UDF 1.02 file system server");
|
---|
[a35b458] | 65 |
|
---|
[48e3190] | 66 | if (argc == 3) {
|
---|
| 67 | if (!str_cmp(argv[1], "--instance"))
|
---|
| 68 | udf_vfs_info.instance = strtol(argv[2], NULL, 10);
|
---|
| 69 | else {
|
---|
[70253688] | 70 | log_msg(LOG_DEFAULT, LVL_FATAL, "Unrecognized parameters");
|
---|
[48e3190] | 71 | return 1;
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
[a35b458] | 74 |
|
---|
[48e3190] | 75 | async_sess_t *vfs_sess =
|
---|
[f9b2cb4c] | 76 | service_connect_blocking(SERVICE_VFS, INTERFACE_VFS_DRIVER, 0);
|
---|
[48e3190] | 77 | if (!vfs_sess) {
|
---|
[70253688] | 78 | log_msg(LOG_DEFAULT, LVL_FATAL, "Failed to connect to VFS");
|
---|
[48e3190] | 79 | return 2;
|
---|
| 80 | }
|
---|
[a35b458] | 81 |
|
---|
[b7fd2a0] | 82 | errno_t rc = fs_register(vfs_sess, &udf_vfs_info, &udf_ops,
|
---|
[48e3190] | 83 | &udf_libfs_ops);
|
---|
| 84 | if (rc != EOK)
|
---|
| 85 | goto err;
|
---|
[a35b458] | 86 |
|
---|
[48e3190] | 87 | rc = udf_idx_init();
|
---|
| 88 | if (rc != EOK)
|
---|
| 89 | goto err;
|
---|
[a35b458] | 90 |
|
---|
[70253688] | 91 | log_msg(LOG_DEFAULT, LVL_NOTE, "Accepting connections");
|
---|
[48e3190] | 92 | task_retval(0);
|
---|
| 93 | async_manager();
|
---|
[a35b458] | 94 |
|
---|
[48e3190] | 95 | /* Not reached */
|
---|
| 96 | return 0;
|
---|
[a35b458] | 97 |
|
---|
[48e3190] | 98 | err:
|
---|
[c1694b6b] | 99 | log_msg(LOG_DEFAULT, LVL_FATAL, "Failed to register file system: %s", str_error(rc));
|
---|
[48e3190] | 100 | return rc;
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | /**
|
---|
| 104 | * @}
|
---|
| 105 | */
|
---|