Changeset b0f00a9 in mainline for uspace/srv/fs/exfat/exfat.c


Ignore:
Timestamp:
2011-11-06T22:21:05Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
898e847
Parents:
2bdf8313 (diff), 7b5f4c9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/exfat/exfat.c

    r2bdf8313 rb0f00a9  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2006 Martin Decky
     3 * Copyright (c) 2008 Jakub Jermar
     4 * Copyright (c) 2011 Oleg Romanenko
    35 * All rights reserved.
    46 *
     
    2729 */
    2830
    29 /** @addtogroup mouse
     31/** @addtogroup fs
    3032 * @{
    3133 */
    32 /** @file
    33  * @brief
     34
     35/**
     36 * @file        exfat.c
     37 * @brief       FAT file system driver for HelenOS.
    3438 */
    3539
    36 #include <ipc/adb.h>
     40#include "exfat.h"
     41#include <ipc/services.h>
     42#include <ns.h>
    3743#include <async.h>
    38 #include <vfs/vfs.h>
    39 #include <fcntl.h>
    4044#include <errno.h>
     45#include <unistd.h>
     46#include <task.h>
     47#include <stdio.h>
     48#include <libfs.h>
     49#include "../../vfs/vfs.h"
    4150
    42 #include "adb_mouse.h"
    43 #include "adb_dev.h"
     51#define NAME    "exfat"
    4452
    45 static void adb_dev_events(ipc_callid_t iid, ipc_call_t *icall);
     53vfs_info_t exfat_vfs_info = {
     54        .name = NAME,
     55        .concurrent_read_write = false,
     56        .write_retains_size = false,
     57        .instance = 0,
     58};
    4659
    47 static int dev_phone;
     60int main(int argc, char **argv)
     61{
     62        printf(NAME ": HelenOS exFAT file system server\n");
    4863
    49 int adb_dev_init(void)
    50 {
    51         const char *input = "/dev/adb/mouse";
    52         int input_fd;
    53 
    54         printf(NAME ": open %s\n", input);
    55 
    56         input_fd = open(input, O_RDONLY);
    57         if (input_fd < 0) {
    58                 printf(NAME ": Failed opening %s (%d)\n", input, input_fd);
    59                 return false;
     64        if (argc == 3) {
     65                if (!str_cmp(argv[1], "--instance"))
     66                        exfat_vfs_info.instance = strtol(argv[2], NULL, 10);
     67                else {
     68                        printf(NAME " Unrecognized parameters");
     69                        return -1;
     70                }
    6071        }
    6172
    62         dev_phone = fd_phone(input_fd);
    63         if (dev_phone < 0) {
    64                 printf(NAME ": Failed to connect to device\n");
    65                 return false;
    66         }
     73        int rc = exfat_idx_init();
     74        if (rc != EOK)
     75                goto err;
    6776
    68         /* NB: The callback connection is slotted for removal */
    69         if (async_connect_to_me(dev_phone, 0, 0, 0, adb_dev_events) != 0) {
    70                 printf(NAME ": Failed to create callback from device\n");
    71                 return false;
     77        async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
     78            SERVICE_VFS, 0, 0);
     79        if (!vfs_sess) {
     80                printf(NAME ": failed to connect to VFS\n");
     81                return -1;
    7282        }
    7383       
     84        rc = fs_register(vfs_sess, &exfat_vfs_info, &exfat_ops, &exfat_libfs_ops);
     85        if (rc != EOK) {
     86                exfat_idx_fini();
     87                goto err;
     88        }
     89       
     90        printf(NAME ": Accepting connections\n");
     91        task_retval(0);
     92        async_manager();
     93
     94        /* not reached */
    7495        return 0;
     96
     97err:
     98        printf(NAME ": Failed to register file system (%d)\n", rc);
     99        return rc;
    75100}
    76101
    77 static void adb_dev_events(ipc_callid_t iid, ipc_call_t *icall)
    78 {
    79         /* Ignore parameters, the connection is already opened */
    80         while (true) {
    81 
    82                 ipc_call_t call;
    83                 ipc_callid_t callid = async_get_call(&call);
    84 
    85                 int retval;
    86 
    87                 switch (IPC_GET_IMETHOD(call)) {
    88                 case IPC_M_PHONE_HUNGUP:
    89                         /* TODO: Handle hangup */
    90                         return;
    91                 case IPC_FIRST_USER_METHOD:
    92                         mouse_handle_data(IPC_GET_ARG1(call));
    93                         break;
    94                 default:
    95                         retval = ENOENT;
    96                 }
    97                 async_answer_0(callid, retval);
    98         }
    99 }
    100102
    101103/**
Note: See TracChangeset for help on using the changeset viewer.