Changes in / [ab4bace:b73c26d] in mainline


Ignore:
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/ipc.c

    rab4bace rb73c26d  
    212212 *
    213213 * @param call          Call structure to be answered.
    214  * @param selflocked    If true, then TASK->answebox is locked.
    215  */
    216 static void _ipc_answer_free_call(call_t *call, bool selflocked)
     214 */
     215static void _ipc_answer_free_call(call_t *call)
    217216{
    218217        answerbox_t *callerbox = call->callerbox;
    219         bool do_lock = ((!selflocked) || callerbox != (&TASK->answerbox));
    220218
    221219        call->flags |= IPC_CALL_ANSWERED;
     
    228226        }
    229227
    230         if (do_lock)
    231                 spinlock_lock(&callerbox->lock);
     228        spinlock_lock(&callerbox->lock);
    232229        list_append(&call->link, &callerbox->answers);
    233         if (do_lock)
    234                 spinlock_unlock(&callerbox->lock);
     230        spinlock_unlock(&callerbox->lock);
    235231        waitq_wakeup(&callerbox->wq, WAKEUP_FIRST);
    236232}
     
    248244        spinlock_unlock(&box->lock);
    249245        /* Send back answer */
    250         _ipc_answer_free_call(call, false);
     246        _ipc_answer_free_call(call);
    251247}
    252248
     
    265261        atomic_inc(&phone->active_calls);
    266262        IPC_SET_RETVAL(call->data, err);
    267         _ipc_answer_free_call(call, false);
     263        _ipc_answer_free_call(call);
    268264}
    269265
     
    304300                if (call->flags & IPC_CALL_FORWARDED) {
    305301                        IPC_SET_RETVAL(call->data, EFORWARD);
    306                         _ipc_answer_free_call(call, false);
     302                        _ipc_answer_free_call(call);
    307303                } else {
    308304                        if (phone->state == IPC_PHONE_HUNGUP)
     
    459455
    460456                IPC_SET_RETVAL(call->data, EHANGUP);
    461                 _ipc_answer_free_call(call, true);
     457                _ipc_answer_free_call(call);
    462458        }
    463459}
  • uspace/srv/fs/fat/fat_fat.c

    rab4bace rb73c26d  
    608608}
    609609
    610 /** Perform basic sanity checks on the file system.
    611  *
    612  * Verify if values of boot sector fields are sane. Also verify media
    613  * descriptor. This is used to rule out cases when a device obviously
    614  * does not contain a fat file system.
    615  */
    616 int fat_sanity_check(fat_bs_t *bs, dev_handle_t dev_handle)
    617 {
    618         fat_cluster_t e0, e1;
    619         unsigned fat_no;
    620         int rc;
    621 
    622         /* Check number of FATs. */
    623         if (bs->fatcnt == 0)
    624                 return ENOTSUP;
    625 
    626         /* Check total number of sectors. */
    627 
    628         if (bs->totsec16 == 0 && bs->totsec32 == 0)
    629                 return ENOTSUP;
    630 
    631         if (bs->totsec16 != 0 && bs->totsec32 != 0 &&
    632             bs->totsec16 != bs->totsec32)
    633                 return ENOTSUP;
    634 
    635         /* Check media descriptor. Must be between 0xf0 and 0xff. */
    636         if ((bs->mdesc & 0xf0) != 0xf0)
    637                 return ENOTSUP;
    638 
    639         /* Check number of sectors per FAT. */
    640         if (bs->sec_per_fat == 0)
    641                 return ENOTSUP;
    642 
    643         /*
    644          * Check that the root directory entries take up whole blocks.
    645          * This check is rather strict, but it allows us to treat the root
    646          * directory and non-root directories uniformly in some places.
    647          * It can be removed provided that functions such as fat_read() are
    648          * sanitized to support file systems with this property.
    649          */
    650         if ((uint16_t_le2host(bs->root_ent_max) * sizeof(fat_dentry_t)) %
    651             uint16_t_le2host(bs->bps) != 0)
    652                 return ENOTSUP;
    653 
    654         /* Check signature of each FAT. */
    655 
    656         for (fat_no = 0; fat_no < bs->fatcnt; fat_no++) {
    657                 rc = fat_get_cluster(bs, dev_handle, fat_no, 0, &e0);
    658                 if (rc != EOK)
    659                         return EIO;
    660 
    661                 rc = fat_get_cluster(bs, dev_handle, fat_no, 1, &e1);
    662                 if (rc != EOK)
    663                         return EIO;
    664 
    665                 /* Check that first byte of FAT contains the media descriptor. */
    666                 if ((e0 & 0xff) != bs->mdesc)
    667                         return ENOTSUP;
    668 
    669                 /*
    670                  * Check that remaining bits of the first two entries are
    671                  * set to one.
    672                  */
    673                 if ((e0 >> 8) != 0xff || e1 != 0xffff)
    674                         return ENOTSUP;
    675         }
    676 
    677         return EOK;
    678 }
    679 
    680610/**
    681611 * @}
  • uspace/srv/fs/fat/fat_fat.h

    rab4bace rb73c26d  
    8787    off_t);
    8888extern int fat_zero_cluster(struct fat_bs *, dev_handle_t, fat_cluster_t);
    89 extern int fat_sanity_check(struct fat_bs *, dev_handle_t);
    9089
    9190#endif
  • uspace/srv/fs/fat/fat_idx.c

    rab4bace rb73c26d  
    531531        unused_initialize(u, dev_handle);
    532532        fibril_mutex_lock(&unused_lock);
    533         if (!unused_find(dev_handle, false)) {
     533        if (!unused_find(dev_handle, false))
    534534                list_append(&u->link, &unused_head);
    535         } else {
    536                 free(u);
     535        else
    537536                rc = EEXIST;
    538         }
    539537        fibril_mutex_unlock(&unused_lock);
    540538        return rc;
  • uspace/srv/fs/fat/fat_ops.c

    rab4bace rb73c26d  
    290290
    291291        *nodepp = nodep;
     292        return EOK;
     293}
     294
     295/** Perform basic sanity checks on the file system.
     296 *
     297 * Verify if values of boot sector fields are sane. Also verify media
     298 * descriptor. This is used to rule out cases when a device obviously
     299 * does not contain a fat file system.
     300 */
     301static int fat_sanity_check(fat_bs_t *bs, dev_handle_t dev_handle)
     302{
     303        fat_cluster_t e0, e1;
     304        unsigned fat_no;
     305        int rc;
     306
     307        /* Check number of FATs. */
     308        if (bs->fatcnt == 0)
     309                return ENOTSUP;
     310
     311        /* Check total number of sectors. */
     312
     313        if (bs->totsec16 == 0 && bs->totsec32 == 0)
     314                return ENOTSUP;
     315
     316        if (bs->totsec16 != 0 && bs->totsec32 != 0 &&
     317            bs->totsec16 != bs->totsec32)
     318                return ENOTSUP;
     319
     320        /* Check media descriptor. Must be between 0xf0 and 0xff. */
     321        if ((bs->mdesc & 0xf0) != 0xf0)
     322                return ENOTSUP;
     323
     324        /* Check number of sectors per FAT. */
     325        if (bs->sec_per_fat == 0)
     326                return ENOTSUP;
     327
     328        /*
     329         * Check that the root directory entries take up whole blocks.
     330         * This check is rather strict, but it allows us to treat the root
     331         * directory and non-root directories uniformly in some places.
     332         * It can be removed provided that functions such as fat_read() are
     333         * sanitized to support file systems with this property.
     334         */
     335        if ((uint16_t_le2host(bs->root_ent_max) * sizeof(fat_dentry_t)) %
     336            uint16_t_le2host(bs->bps) != 0)
     337                return ENOTSUP;
     338
     339        /* Check signature of each FAT. */
     340
     341        for (fat_no = 0; fat_no < bs->fatcnt; fat_no++) {
     342                rc = fat_get_cluster(bs, dev_handle, fat_no, 0, &e0);
     343                if (rc != EOK)
     344                        return EIO;
     345
     346                rc = fat_get_cluster(bs, dev_handle, fat_no, 1, &e1);
     347                if (rc != EOK)
     348                        return EIO;
     349
     350                /* Check that first byte of FAT contains the media descriptor. */
     351                if ((e0 & 0xff) != bs->mdesc)
     352                        return ENOTSUP;
     353
     354                /*
     355                 * Check that remaining bits of the first two entries are
     356                 * set to one.
     357                 */
     358                if ((e0 >> 8) != 0xff || e1 != 0xffff)
     359                        return ENOTSUP;
     360        }
     361
    292362        return EOK;
    293363}
     
    9451015                cmode = CACHE_MODE_WB;
    9461016
    947         free(opts);
    948 
    9491017        /* initialize libblock */
    9501018        rc = block_init(dev_handle, BS_SIZE);
  • uspace/srv/vfs/vfs.c

    rab4bace rb73c26d  
    137137        }
    138138       
    139         vfs_files_done();
     139        /* TODO: cleanup after the client */
    140140}
    141141
  • uspace/srv/vfs/vfs.h

    rab4bace rb73c26d  
    177177    vfs_pair_t *, ...);
    178178extern int vfs_open_node_internal(vfs_lookup_res_t *);
    179 extern int vfs_close_internal(vfs_file_t *);
    180179
    181180extern bool vfs_nodes_init(void);
     
    189188
    190189extern bool vfs_files_init(void);
    191 extern void vfs_files_done(void);
    192190extern vfs_file_t *vfs_file_get(int);
    193191extern int vfs_fd_assign(vfs_file_t *file, int fd);
  • uspace/srv/vfs/vfs_file.c

    rab4bace rb73c26d  
    7272        }
    7373        return true;
    74 }
    75 
    76 /** Cleanup the table of open files. */
    77 void vfs_files_done(void)
    78 {
    79         int i;
    80 
    81         if (!files)
    82                 return;
    83 
    84         for (i = 0; i < MAX_OPEN_FILES; i++) {
    85                 if (files[i]) {
    86                         (void) vfs_close_internal(files[i]);
    87                         (void) vfs_fd_free(i);
    88                 }
    89         }
    90        
    91         free(files);
    9274}
    9375
  • uspace/srv/vfs/vfs_ops.c

    rab4bace rb73c26d  
    817817}
    818818
    819 int vfs_close_internal(vfs_file_t *file)
     819static int vfs_close_internal(vfs_file_t *file)
    820820{
    821821        /*
Note: See TracChangeset for help on using the changeset viewer.