Changeset 2b96463 in mainline for uspace/srv


Ignore:
Timestamp:
2011-01-28T15:15:11Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3ee48f2, 7a51d75
Parents:
ef8d655 (diff), ae0300b5 (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

Location:
uspace/srv
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/clip/clip.c

    ref8d655 r2b96463  
    183183        async_set_client_connection(clip_connection);
    184184       
    185         sysarg_t phonead;
    186         if (ipc_connect_to_me(PHONE_NS, SERVICE_CLIPBOARD, 0, 0, &phonead) != 0)
     185        if (ipc_connect_to_me(PHONE_NS, SERVICE_CLIPBOARD, 0, 0, NULL, NULL))
    187186                return -1;
    188187       
  • uspace/srv/devman/main.c

    ref8d655 r2b96463  
    587587
    588588        /* Register device manager at naming service. */
    589         sysarg_t phonead;
    590         if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAN, 0, 0, &phonead) != 0)
     589        if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAN, 0, 0, NULL, NULL) != 0)
    591590                return -1;
    592591
  • uspace/srv/devmap/devmap.c

    ref8d655 r2b96463  
    11501150       
    11511151        /* Register device mapper at naming service */
    1152         sysarg_t phonead;
    1153         if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, 0, &phonead) != 0)
     1152        if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, 0, NULL, NULL) != 0)
    11541153                return -1;
    11551154       
  • uspace/srv/hid/adb_mouse/adb_dev.c

    ref8d655 r2b96463  
    6868
    6969        /* NB: The callback connection is slotted for removal */
     70        sysarg_t taskhash;
    7071        sysarg_t phonehash;
    71         if (ipc_connect_to_me(dev_phone, 0, 0, 0, &phonehash) != 0) {
     72        if (ipc_connect_to_me(dev_phone, 0, 0, 0, &taskhash, &phonehash) != 0) {
    7273                printf(NAME ": Failed to create callback from device\n");
    7374                return false;
    7475        }
    7576
    76         async_new_connection(phonehash, 0, NULL, adb_dev_events);
     77        async_new_connection(taskhash, phonehash, 0, NULL, adb_dev_events);
    7778
    7879        return 0;
  • uspace/srv/hid/char_mouse/chardev.c

    ref8d655 r2b96463  
    7070
    7171        /* NB: The callback connection is slotted for removal */
     72        sysarg_t taskhash;
    7273        sysarg_t phonehash;
    73         if (ipc_connect_to_me(dev_phone, 0, 0, 0, &phonehash) != 0) {
     74        if (ipc_connect_to_me(dev_phone, 0, 0, 0, &taskhash, &phonehash) != 0) {
    7475                printf(NAME ": Failed to create callback from device\n");
    7576                return false;
    7677        }
    7778
    78         async_new_connection(phonehash, 0, NULL, chardev_events);
     79        async_new_connection(taskhash, phonehash, 0, NULL, chardev_events);
    7980
    8081        return 0;
  • uspace/srv/hid/console/console.c

    ref8d655 r2b96463  
    727727        /* NB: The callback connection is slotted for removal */
    728728        sysarg_t phonehash;
     729        sysarg_t taskhash;
    729730        int rc = async_req_3_5(phone, IPC_M_CONNECT_TO_ME, SERVICE_CONSOLE,
    730             0, 0, NULL, NULL, NULL, NULL, &phonehash);
     731            0, 0, NULL, NULL, NULL, &taskhash, &phonehash);
    731732        if (rc != EOK) {
    732733                printf(NAME ": Failed to create callback from input device\n");
     
    734735        }
    735736       
    736         async_new_connection(phonehash, 0, NULL, keyboard_events);
     737        async_new_connection(taskhash, phonehash, 0, NULL, keyboard_events);
    737738
    738739        printf(NAME ": we got a hit (new keyboard \"%s\").\n", path);
     
    784785        /* NB: The callback connection is slotted for removal */
    785786        sysarg_t phonehash;
     787        sysarg_t taskhash;
    786788        int rc = async_req_3_5(phone, IPC_M_CONNECT_TO_ME, SERVICE_CONSOLE,
    787             0, 0, NULL, NULL, NULL, NULL, &phonehash);
     789            0, 0, NULL, NULL, NULL, &taskhash, &phonehash);
    788790        if (rc != EOK) {
    789791                printf(NAME ": Failed to create callback from input device\n");
     
    791793        }
    792794
    793         async_new_connection(phonehash, 0, NULL, keyboard_events);
     795        async_new_connection(taskhash, phonehash, 0, NULL, keyboard_events);
    794796
    795797        printf(NAME ": we got a hit (new keyboard \"/dev/%s\").\n",
     
    862864        }
    863865       
     866        sysarg_t taskhash;
    864867        sysarg_t phonehash;
    865         if (ipc_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {
     868        if (ipc_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, &taskhash,
     869            &phonehash) != 0) {
    866870                printf(NAME ": Failed to create callback from mouse device\n");
    867871                mouse_phone = -1;
     
    869873        }
    870874       
    871         async_new_connection(phonehash, 0, NULL, mouse_events);
     875        async_new_connection(taskhash, phonehash, 0, NULL, mouse_events);
    872876skip_mouse:
    873877       
  • uspace/srv/hid/fb/main.c

    ref8d655 r2b96463  
    114114                return -1;
    115115       
    116         sysarg_t phonead;
    117         if (ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, 0, &phonead) != 0)
     116        if (ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, 0, NULL, NULL) != 0)
    118117                return -1;
    119118       
  • uspace/srv/hid/kbd/port/adb.c

    ref8d655 r2b96463  
    7171
    7272        /* NB: The callback connection is slotted for removal */
     73        sysarg_t taskhash;
    7374        sysarg_t phonehash;
    74         if (ipc_connect_to_me(dev_phone, 0, 0, 0, &phonehash) != 0) {
     75        if (ipc_connect_to_me(dev_phone, 0, 0, 0, &taskhash, &phonehash) != 0) {
    7576                printf(NAME ": Failed to create callback from device\n");
    7677                return false;
    7778        }
    7879
    79         async_new_connection(phonehash, 0, NULL, kbd_port_events);
     80        async_new_connection(taskhash, phonehash, 0, NULL, kbd_port_events);
    8081
    8182        return 0;
  • uspace/srv/hid/kbd/port/chardev.c

    ref8d655 r2b96463  
    9191
    9292        /* NB: The callback connection is slotted for removal */
     93        sysarg_t taskhash;
    9394        sysarg_t phonehash;
    94         if (ipc_connect_to_me(dev_phone, 0, 0, 0, &phonehash) != 0) {
     95        if (ipc_connect_to_me(dev_phone, 0, 0, 0, &taskhash, &phonehash) != 0) {
    9596                printf(NAME ": Failed to create callback from device\n");
    9697                return -1;
    9798        }
    9899
    99         async_new_connection(phonehash, 0, NULL, kbd_port_events);
     100        async_new_connection(taskhash, phonehash, 0, NULL, kbd_port_events);
    100101
    101102        return 0;
  • uspace/srv/hw/irc/apic/apic.c

    ref8d655 r2b96463  
    108108       
    109109        async_set_client_connection(apic_connection);
    110         sysarg_t phonead;
    111         ipc_connect_to_me(PHONE_NS, SERVICE_APIC, 0, 0, &phonead);
     110        ipc_connect_to_me(PHONE_NS, SERVICE_APIC, 0, 0, NULL, NULL);
    112111       
    113112        return true;
  • uspace/srv/hw/irc/fhc/fhc.c

    ref8d655 r2b96463  
    137137       
    138138        async_set_client_connection(fhc_connection);
    139         sysarg_t phonead;
    140         ipc_connect_to_me(PHONE_NS, SERVICE_FHC, 0, 0, &phonead);
     139        ipc_connect_to_me(PHONE_NS, SERVICE_FHC, 0, 0, NULL, NULL);
    141140       
    142141        return true;
  • uspace/srv/hw/irc/i8259/i8259.c

    ref8d655 r2b96463  
    150150       
    151151        async_set_client_connection(i8259_connection);
    152         sysarg_t phonead;
    153         ipc_connect_to_me(PHONE_NS, SERVICE_I8259, 0, 0, &phonead);
     152        ipc_connect_to_me(PHONE_NS, SERVICE_I8259, 0, 0, NULL, NULL);
    154153       
    155154        return true;
  • uspace/srv/hw/irc/obio/obio.c

    ref8d655 r2b96463  
    138138       
    139139        async_set_client_connection(obio_connection);
    140         sysarg_t phonead;
    141         ipc_connect_to_me(PHONE_NS, SERVICE_OBIO, 0, 0, &phonead);
     140        ipc_connect_to_me(PHONE_NS, SERVICE_OBIO, 0, 0, NULL, NULL);
    142141       
    143142        return true;
  • uspace/srv/hw/netif/ne2000/ne2000.c

    ref8d655 r2b96463  
    397397        async_set_interrupt_received(irq_handler);
    398398       
    399         sysarg_t phonehash;
    400         return ipc_connect_to_me(PHONE_NS, SERVICE_NE2000, 0, 0, &phonehash);
     399        return ipc_connect_to_me(PHONE_NS, SERVICE_NE2000, 0, 0, NULL, NULL);
    401400}
    402401
  • uspace/srv/loader/main.c

    ref8d655 r2b96463  
    423423int main(int argc, char *argv[])
    424424{
    425         sysarg_t phonead;
    426425        task_id_t id;
    427426        int rc;
     
    439438       
    440439        /* Register at naming service. */
    441         if (ipc_connect_to_me(PHONE_NS, SERVICE_LOAD, 0, 0, &phonead) != 0)
     440        if (ipc_connect_to_me(PHONE_NS, SERVICE_LOAD, 0, 0, NULL, NULL) != 0)
    442441                return -2;
    443442
  • uspace/srv/net/net/net.c

    ref8d655 r2b96463  
    326326static int net_module_start(async_client_conn_t client_connection)
    327327{
    328         sysarg_t phonehash;
    329328        int rc;
    330329       
     
    338337                goto out;
    339338       
    340         rc = ipc_connect_to_me(PHONE_NS, SERVICE_NETWORKING, 0, 0, &phonehash);
     339        rc = ipc_connect_to_me(PHONE_NS, SERVICE_NETWORKING, 0, 0, NULL, NULL);
    341340        if (rc != EOK)
    342341                goto out;
  • uspace/srv/net/netif/lo/lo.c

    ref8d655 r2b96463  
    167167int netif_initialize(void)
    168168{
    169         sysarg_t phonehash;
    170         return ipc_connect_to_me(PHONE_NS, SERVICE_LO, 0, 0, &phonehash);
     169        return ipc_connect_to_me(PHONE_NS, SERVICE_LO, 0, 0, NULL, NULL);
    171170}
    172171
  • uspace/srv/vfs/vfs.c

    ref8d655 r2b96463  
    5959        ipc_answer_0(iid, EOK);
    6060       
    61         /*
    62          * Here we enter the main connection fibril loop.
    63          * The logic behind this loop and the protocol is that we'd like to keep
    64          * each connection open until the client hangs up. When the client hangs
    65          * up, we will free its VFS state. The act of hanging up the connection
    66          * by the client is equivalent to client termination because we cannot
    67          * distinguish one from the other. On the other hand, the client can
    68          * hang up arbitrarily if it has no open files and reestablish the
    69          * connection later.
    70          */
    7161        while (keep_on_going) {
    7262                ipc_call_t call;
     
    133123                }
    134124        }
    135        
    136         vfs_files_done();
     125
     126        /*
     127         * Open files for this client will be cleaned up when its last
     128         * connection fibril terminates.
     129         */
    137130}
    138131
     
    166159       
    167160        /*
     161         * Set client data constructor and destructor.
     162         */
     163        async_set_client_data_constructor(vfs_client_data_create);
     164        async_set_client_data_destructor(vfs_client_data_destroy);
     165
     166        /*
    168167         * Set a connection handling function/fibril.
    169168         */
     
    173172         * Register at the naming service.
    174173         */
    175         sysarg_t phonead;
    176         ipc_connect_to_me(PHONE_NS, SERVICE_VFS, 0, 0, &phonead);
     174        ipc_connect_to_me(PHONE_NS, SERVICE_VFS, 0, 0, NULL, NULL);
    177175       
    178176        /*
  • uspace/srv/vfs/vfs.h

    ref8d655 r2b96463  
    188188#define MAX_OPEN_FILES  128
    189189
    190 extern bool vfs_files_init(void);
    191 extern void vfs_files_done(void);
     190extern void *vfs_client_data_create(void);
     191extern void vfs_client_data_destroy(void *);
     192
    192193extern vfs_file_t *vfs_file_get(int);
    193 extern int vfs_fd_assign(vfs_file_t *file, int fd);
     194extern void vfs_file_put(vfs_file_t *);
     195extern int vfs_fd_assign(vfs_file_t *, int);
    194196extern int vfs_fd_alloc(bool desc);
    195197extern int vfs_fd_free(int);
    196 
    197 extern void vfs_file_addref(vfs_file_t *);
    198 extern void vfs_file_delref(vfs_file_t *);
    199198
    200199extern void vfs_node_addref(vfs_node_t *);
  • uspace/srv/vfs/vfs_file.c

    ref8d655 r2b96463  
    4545#include "vfs.h"
    4646
    47 /**
    48  * This is a per-connection table of open files.
    49  * Our assumption is that each client opens only one connection and therefore
    50  * there is one table of open files per task. However, this may not be the case
    51  * and the client can open more connections to VFS. In that case, there will be
    52  * several tables and several file handle name spaces per task. Besides of this,
    53  * the functionality will stay unchanged. So unless the client knows what it is
    54  * doing, it should open one connection to VFS only.
    55  *
    56  * Allocation of the open files table is deferred until the client makes the
    57  * first VFS_OPEN operation.
    58  *
    59  * This resource being per-connection and, in the first place, per-fibril, we
    60  * don't need to protect it by a mutex.
    61  */
    62 fibril_local vfs_file_t **files = NULL;
     47#define VFS_DATA        ((vfs_client_data_t *) async_client_data_get())
     48#define FILES           (VFS_DATA->files)
     49
     50typedef struct {
     51        fibril_mutex_t lock;
     52        vfs_file_t **files;
     53} vfs_client_data_t;
    6354
    6455/** Initialize the table of open files. */
    65 bool vfs_files_init(void)
    66 {
    67         if (!files) {
    68                 files = malloc(MAX_OPEN_FILES * sizeof(vfs_file_t *));
    69                 if (!files)
     56static bool vfs_files_init(void)
     57{
     58        fibril_mutex_lock(&VFS_DATA->lock);
     59        if (!FILES) {
     60                FILES = malloc(MAX_OPEN_FILES * sizeof(vfs_file_t *));
     61                if (!FILES) {
     62                        fibril_mutex_unlock(&VFS_DATA->lock);
    7063                        return false;
    71                 memset(files, 0, MAX_OPEN_FILES * sizeof(vfs_file_t *));
    72         }
     64                }
     65                memset(FILES, 0, MAX_OPEN_FILES * sizeof(vfs_file_t *));
     66        }
     67        fibril_mutex_unlock(&VFS_DATA->lock);
    7368        return true;
    7469}
    7570
    7671/** Cleanup the table of open files. */
    77 void vfs_files_done(void)
     72static void vfs_files_done(void)
    7873{
    7974        int i;
    8075
    81         if (!files)
     76        if (!FILES)
    8277                return;
    8378
    8479        for (i = 0; i < MAX_OPEN_FILES; i++) {
    85                 if (files[i]) {
    86                         (void) vfs_close_internal(files[i]);
     80                if (FILES[i]) {
     81                        (void) vfs_close_internal(FILES[i]);
    8782                        (void) vfs_fd_free(i);
    8883                }
    8984        }
    9085       
    91         free(files);
    92 }
     86        free(FILES);
     87}
     88
     89void *vfs_client_data_create(void)
     90{
     91        vfs_client_data_t *vfs_data;
     92
     93        vfs_data = malloc(sizeof(vfs_client_data_t));
     94        if (vfs_data) {
     95                fibril_mutex_initialize(&vfs_data->lock);
     96                vfs_data->files = NULL;
     97        }
     98       
     99        return vfs_data;
     100}
     101
     102void vfs_client_data_destroy(void *data)
     103{
     104        vfs_client_data_t *vfs_data = (vfs_client_data_t *) data;
     105
     106        vfs_files_done();
     107        free(vfs_data);
     108}
     109
     110/** Increment reference count of VFS file structure.
     111 *
     112 * @param file          File structure that will have reference count
     113 *                      incremented.
     114 */
     115static void vfs_file_addref(vfs_file_t *file)
     116{
     117        assert(fibril_mutex_is_locked(&VFS_DATA->lock));
     118
     119        file->refcnt++;
     120}
     121
     122/** Decrement reference count of VFS file structure.
     123 *
     124 * @param file          File structure that will have reference count
     125 *                      decremented.
     126 */
     127static void vfs_file_delref(vfs_file_t *file)
     128{
     129        assert(fibril_mutex_is_locked(&VFS_DATA->lock));
     130
     131        if (file->refcnt-- == 1) {
     132                /*
     133                 * Lost the last reference to a file, need to drop our reference
     134                 * to the underlying VFS node.
     135                 */
     136                vfs_node_delref(file->node);
     137                free(file);
     138        }
     139}
     140
    93141
    94142/** Allocate a file descriptor.
     
    111159                i = 0;
    112160       
     161        fibril_mutex_lock(&VFS_DATA->lock);
    113162        while (true) {
    114                 if (!files[i]) {
    115                         files[i] = (vfs_file_t *) malloc(sizeof(vfs_file_t));
    116                         if (!files[i])
     163                if (!FILES[i]) {
     164                        FILES[i] = (vfs_file_t *) malloc(sizeof(vfs_file_t));
     165                        if (!FILES[i]) {
     166                                fibril_mutex_unlock(&VFS_DATA->lock);
    117167                                return ENOMEM;
     168                        }
    118169                       
    119                         memset(files[i], 0, sizeof(vfs_file_t));
    120                         fibril_mutex_initialize(&files[i]->lock);
    121                         vfs_file_addref(files[i]);
     170                        memset(FILES[i], 0, sizeof(vfs_file_t));
     171                        fibril_mutex_initialize(&FILES[i]->lock);
     172                        vfs_file_addref(FILES[i]);
     173                        fibril_mutex_unlock(&VFS_DATA->lock);
    122174                        return (int) i;
    123175                }
     
    135187                }
    136188        }
     189        fibril_mutex_unlock(&VFS_DATA->lock);
    137190       
    138191        return EMFILE;
     
    150203        if (!vfs_files_init())
    151204                return ENOMEM;
    152        
    153         if ((fd < 0) || (fd >= MAX_OPEN_FILES) || (files[fd] == NULL))
     205
     206        fibril_mutex_lock(&VFS_DATA->lock);     
     207        if ((fd < 0) || (fd >= MAX_OPEN_FILES) || (FILES[fd] == NULL)) {
     208                fibril_mutex_unlock(&VFS_DATA->lock);
    154209                return EBADF;
    155        
    156         vfs_file_delref(files[fd]);
    157         files[fd] = NULL;
     210        }
     211       
     212        vfs_file_delref(FILES[fd]);
     213        FILES[fd] = NULL;
     214        fibril_mutex_unlock(&VFS_DATA->lock);
    158215       
    159216        return EOK;
     
    173230        if (!vfs_files_init())
    174231                return ENOMEM;
    175        
    176         if ((fd < 0) || (fd >= MAX_OPEN_FILES) || (files[fd] != NULL))
     232
     233        fibril_mutex_lock(&VFS_DATA->lock);     
     234        if ((fd < 0) || (fd >= MAX_OPEN_FILES) || (FILES[fd] != NULL)) {
     235                fibril_mutex_unlock(&VFS_DATA->lock);
    177236                return EINVAL;
    178        
    179         files[fd] = file;
    180         vfs_file_addref(files[fd]);
     237        }
     238       
     239        FILES[fd] = file;
     240        vfs_file_addref(FILES[fd]);
     241        fibril_mutex_unlock(&VFS_DATA->lock);
    181242       
    182243        return EOK;
    183244}
    184245
    185 /** Increment reference count of VFS file structure.
    186  *
    187  * @param file          File structure that will have reference count
    188  *                      incremented.
    189  */
    190 void vfs_file_addref(vfs_file_t *file)
    191 {
    192         /*
    193          * File structures are per-connection, so no-one, except the current
    194          * fibril, should have a reference to them. This is the reason we don't
    195          * do any synchronization here.
    196          */
    197         file->refcnt++;
    198 }
    199 
    200 /** Decrement reference count of VFS file structure.
    201  *
    202  * @param file          File structure that will have reference count
    203  *                      decremented.
    204  */
    205 void vfs_file_delref(vfs_file_t *file)
    206 {
    207         if (file->refcnt-- == 1) {
    208                 /*
    209                  * Lost the last reference to a file, need to drop our reference
    210                  * to the underlying VFS node.
    211                  */
    212                 vfs_node_delref(file->node);
    213                 free(file);
    214         }
    215 }
    216 
    217246/** Find VFS file structure for a given file descriptor.
    218247 *
     
    226255                return NULL;
    227256       
    228         if ((fd >= 0) && (fd < MAX_OPEN_FILES))
    229                 return files[fd];
     257        fibril_mutex_lock(&VFS_DATA->lock);
     258        if ((fd >= 0) && (fd < MAX_OPEN_FILES)) {
     259                vfs_file_t *file = FILES[fd];
     260                vfs_file_addref(file);
     261                fibril_mutex_unlock(&VFS_DATA->lock);
     262                return file;
     263        }
     264        fibril_mutex_unlock(&VFS_DATA->lock);
    230265       
    231266        return NULL;
     267}
     268
     269/** Stop using a file structure.
     270 *
     271 * @param file          VFS file structure.
     272 */
     273void vfs_file_put(vfs_file_t *file)
     274{
     275        fibril_mutex_lock(&VFS_DATA->lock);
     276        vfs_file_delref(file);
     277        fibril_mutex_unlock(&VFS_DATA->lock);
    232278}
    233279
  • uspace/srv/vfs/vfs_ops.c

    ref8d655 r2b96463  
    491491void vfs_open(ipc_callid_t rid, ipc_call_t *request)
    492492{
    493         if (!vfs_files_init()) {
    494                 ipc_answer_0(rid, ENOMEM);
    495                 return;
    496         }
    497        
    498493        /*
    499494         * The POSIX interface is open(path, oflag, mode).
     
    609604        vfs_node_addref(node);
    610605        vfs_node_put(node);
     606        vfs_file_put(file);
    611607       
    612608        /* Success! Return the new file descriptor to the client. */
     
    617613{
    618614        // FIXME: check for sanity of the supplied fs, dev and index
    619        
    620         if (!vfs_files_init()) {
    621                 ipc_answer_0(rid, ENOMEM);
    622                 return;
    623         }
    624615       
    625616        /*
     
    686677        vfs_node_addref(node);
    687678        vfs_node_put(node);
     679        vfs_file_put(file);
    688680       
    689681        /* Success! Return the new file descriptor to the client. */
     
    721713        vfs_release_phone(file->node->fs_handle, fs_phone);
    722714        fibril_mutex_unlock(&file->lock);
    723        
     715
     716        vfs_file_put(file);
    724717        ipc_answer_0(rid, rc);
    725718}
     
    775768                ipc_answer_0(rid, ret);
    776769       
     770        vfs_file_put(file);
    777771        ret = vfs_fd_free(fd);
    778772        ipc_answer_0(rid, ret);
     
    875869                file->pos += bytes;
    876870        fibril_mutex_unlock(&file->lock);
    877        
     871        vfs_file_put(file);     
     872
    878873        /*
    879874         * FS server's reply is the final result of the whole operation we
     
    915910                        file->pos = (aoff64_t) off;
    916911                        fibril_mutex_unlock(&file->lock);
     912                        vfs_file_put(file);
    917913                        ipc_answer_1(rid, EOK, off);
    918914                        return;
     
    922918                if ((off >= 0) && (file->pos + off < file->pos)) {
    923919                        fibril_mutex_unlock(&file->lock);
     920                        vfs_file_put(file);
    924921                        ipc_answer_0(rid, EOVERFLOW);
    925922                        return;
     
    928925                if ((off < 0) && (file->pos < (aoff64_t) -off)) {
    929926                        fibril_mutex_unlock(&file->lock);
     927                        vfs_file_put(file);
    930928                        ipc_answer_0(rid, EOVERFLOW);
    931929                        return;
     
    936934               
    937935                fibril_mutex_unlock(&file->lock);
     936                vfs_file_put(file);
    938937                ipc_answer_2(rid, EOK, LOWER32(newoff),
    939938                    UPPER32(newoff));
     
    946945                        fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    947946                        fibril_mutex_unlock(&file->lock);
     947                        vfs_file_put(file);
    948948                        ipc_answer_0(rid, EOVERFLOW);
    949949                        return;
     
    953953                        fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    954954                        fibril_mutex_unlock(&file->lock);
     955                        vfs_file_put(file);
    955956                        ipc_answer_0(rid, EOVERFLOW);
    956957                        return;
     
    962963                fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    963964                fibril_mutex_unlock(&file->lock);
     965                vfs_file_put(file);
    964966                ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
    965967                return;
     
    967969       
    968970        fibril_mutex_unlock(&file->lock);
     971        vfs_file_put(file);
    969972        ipc_answer_0(rid, EINVAL);
    970973}
     
    10051008
    10061009        fibril_mutex_unlock(&file->lock);
     1010        vfs_file_put(file);
    10071011        ipc_answer_0(rid, (sysarg_t)rc);
    10081012}
     
    10211025        ipc_callid_t callid;
    10221026        if (!async_data_read_receive(&callid, NULL)) {
     1027                vfs_file_put(file);
    10231028                ipc_answer_0(callid, EINVAL);
    10241029                ipc_answer_0(rid, EINVAL);
     
    10381043
    10391044        fibril_mutex_unlock(&file->lock);
     1045        vfs_file_put(file);
    10401046        ipc_answer_0(rid, rc);
    10411047}
     
    13391345        int newfd = IPC_GET_ARG2(*request);
    13401346       
     1347        /* If the file descriptors are the same, do nothing. */
     1348        if (oldfd == newfd) {
     1349                ipc_answer_1(rid, EOK, newfd);
     1350                return;
     1351        }
     1352       
    13411353        /* Lookup the file structure corresponding to oldfd. */
    13421354        vfs_file_t *oldfile = vfs_file_get(oldfd);
    13431355        if (!oldfile) {
    13441356                ipc_answer_0(rid, EBADF);
    1345                 return;
    1346         }
    1347        
    1348         /* If the file descriptors are the same, do nothing. */
    1349         if (oldfd == newfd) {
    1350                 ipc_answer_1(rid, EOK, newfd);
    13511357                return;
    13521358        }
     
    13651371                if (ret != EOK) {
    13661372                        fibril_mutex_unlock(&oldfile->lock);
     1373                        vfs_file_put(oldfile);
     1374                        vfs_file_put(newfile);
    13671375                        ipc_answer_0(rid, ret);
    13681376                        return;
     
    13721380                if (ret != EOK) {
    13731381                        fibril_mutex_unlock(&oldfile->lock);
     1382                        vfs_file_put(oldfile);
     1383                        vfs_file_put(newfile);
    13741384                        ipc_answer_0(rid, ret);
    13751385                        return;
    13761386                }
     1387                vfs_file_put(newfile);
    13771388        }
    13781389       
     
    13801391        int ret = vfs_fd_assign(oldfile, newfd);
    13811392        fibril_mutex_unlock(&oldfile->lock);
     1393        vfs_file_put(oldfile);
    13821394       
    13831395        if (ret != EOK)
Note: See TracChangeset for help on using the changeset viewer.