Changes in / [547c37a:7b712b60] in mainline


Ignore:
Files:
36 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    r547c37a r7b712b60  
    9797        $(USPACE_PATH)/srv/fs/tmpfs/tmpfs \
    9898        $(USPACE_PATH)/srv/fs/fat/fat \
    99         $(USPACE_PATH)/srv/fs/ext2fs/ext2fs \
    10099        $(USPACE_PATH)/srv/taskmon/taskmon \
    101100        $(USPACE_PATH)/srv/hw/netif/ne2000/ne2000 \
     
    115114        rootvirt \
    116115        test1 \
    117         test2 \
    118         test3
     116        test2
    119117
    120118RD_DRV_CFG =
     
    136134
    137135RD_APPS_NON_ESSENTIAL = \
    138         $(USPACE_PATH)/app/blkdump/blkdump \
    139         $(USPACE_PATH)/app/bnchmark/bnchmark \
    140136        $(USPACE_PATH)/app/dltest/dltest \
    141137        $(USPACE_PATH)/app/dltest2/dltest2 \
    142138        $(USPACE_PATH)/app/dload/dload \
    143139        $(USPACE_PATH)/app/edit/edit \
    144         $(USPACE_PATH)/app/ext2info/ext2info \
    145140        $(USPACE_PATH)/app/kill/kill \
    146141        $(USPACE_PATH)/app/killall/killall \
     
    150145        $(USPACE_PATH)/app/taskdump/taskdump \
    151146        $(USPACE_PATH)/app/tester/tester \
    152         $(USPACE_PATH)/app/testread/testread \
    153147        $(USPACE_PATH)/app/tetris/tetris \
    154148        $(USPACE_PATH)/app/trace/trace \
  • kernel/generic/src/interrupt/interrupt.c

    r547c37a r7b712b60  
    177177            (void *) istate_get_pc(istate));
    178178       
    179         istate_decode(istate);
    180179        stack_trace_istate(istate);
    181180       
  • uspace/Makefile

    r547c37a r7b712b60  
    3535DIRS = \
    3636        app/bdsh \
    37         app/blkdump \
    38         app/bnchmark \
    3937        app/edit \
    40         app/ext2info \
    4138        app/getterm \
    4239        app/init \
     
    5047        app/taskdump \
    5148        app/tester \
    52         app/testread \
    5349        app/tetris \
    5450        app/trace \
     
    7672        srv/fs/tmpfs \
    7773        srv/fs/devfs \
    78         srv/fs/ext2fs \
    7974        srv/hid/adb_mouse \
    8075        srv/hid/char_mouse \
     
    9590        drv/rootvirt \
    9691        drv/test1 \
    97         drv/test2 \
    98         drv/test3
     92        drv/test2
    9993
    10094## Networking
     
    154148        lib/drv \
    155149        lib/packet \
    156         lib/net \
    157         lib/ext2
     150        lib/net
    158151
    159152LIBC_BUILD = $(addsuffix .build,$(LIBC))
  • uspace/Makefile.common

    r547c37a r7b712b60  
    108108LIBCLUI_PREFIX = $(LIB_PREFIX)/clui
    109109
    110 LIBEXT2_PREFIX = $(LIB_PREFIX)/ext2
    111 
    112110LIBDRV_PREFIX = $(LIB_PREFIX)/drv
    113111LIBPACKET_PREFIX = $(LIB_PREFIX)/packet
  • uspace/app/bdsh/cmds/modules/mount/mount.c

    r547c37a r7b712b60  
    5151{
    5252        static char helpfmt[] =
    53             "Usage:  %s <fstype> <mp> [dev] [<moptions>]\n";
     53            "Usage:  %s <fstype> <mp> <dev> [<moptions>]\n";
    5454        if (level == HELP_SHORT) {
    5555                printf("'%s' mounts a file system.\n", cmdname);
     
    6666        unsigned int argc;
    6767        const char *mopts = "";
    68         const char *dev = "";
    6968        int rc, c, opt_ind;
    7069
     
    8079        }
    8180
    82         if ((argc < 3) || (argc > 5)) {
     81        if ((argc < 4) || (argc > 5)) {
    8382                printf("%s: invalid number of arguments. Try `mount --help'\n",
    8483                    cmdname);
    8584                return CMD_FAILURE;
    8685        }
    87         if (argc > 3)
    88                 dev = argv[3];
    8986        if (argc == 5)
    9087                mopts = argv[4];
    9188
    92         rc = mount(argv[1], argv[2], dev, mopts, 0);
     89        rc = mount(argv[1], argv[2], argv[3], mopts, 0);
    9390        if (rc != EOK) {
    9491                printf("Unable to mount %s filesystem to %s on %s (rc=%d)\n",
  • uspace/app/redir/redir.c

    r547c37a r7b712b60  
    4949static void usage(void)
    5050{
    51         fprintf(stderr, "Usage: %s [-i <stdin>] [-o <stdout>] [-e <stderr>] -- <cmd> [args ...]\n",
     51        printf("Usage: %s [-i <stdin>] [-o <stdout>] [-e <stderr>] -- <cmd> [args ...]\n",
    5252            NAME);
    5353}
     
    8383        args = (const char **) calloc(argc + 1, sizeof(char *));
    8484        if (!args) {
    85                 fprintf(stderr, "No memory available\n");
     85                printf("No memory available\n");
    8686                return 0;
    8787        }
     
    9898       
    9999        if (rc != EOK) {
    100                 fprintf(stderr, "%s: Error spawning %s (%s)\n", NAME, argv[0],
     100                printf("%s: Error spawning %s (%s)\n", NAME, argv[0],
    101101                    str_error(rc));
    102                 return 0;
    103102        }
    104103       
  • uspace/app/tester/Makefile

    r547c37a r7b712b60  
    2929
    3030USPACE_PREFIX = ../..
    31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBEXT2_PREFIX)/libext2.a
    32 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBEXT2_PREFIX)
    3331BINARY = tester
    3432
    3533SOURCES = \
    3634        tester.c \
    37         util.c \
    3835        thread/thread1.c \
    3936        print/print1.c \
     
    5653        mm/malloc3.c \
    5754        devs/devman1.c \
    58         devs/devman2.c \
    5955        hw/misc/virtchar1.c \
    60         hw/serial/serial1.c \
    61         libext2/libext2_1.c
     56        hw/serial/serial1.c
    6257
    6358include $(USPACE_PREFIX)/Makefile.common
  • uspace/app/tester/tester.c

    r547c37a r7b712b60  
    6666#include "hw/serial/serial1.def"
    6767#include "hw/misc/virtchar1.def"
    68 #include "libext2/libext2_1.def"
    6968#include "devs/devman1.def"
    70 #include "devs/devman2.def"
    7169        {NULL, NULL, NULL, false}
    7270};
  • uspace/app/tester/tester.h

    r547c37a r7b712b60  
    9999extern const char *test_serial1(void);
    100100extern const char *test_virtchar1(void);
    101 extern const char *test_libext2_1(void);
    102101extern const char *test_devman1(void);
    103 extern const char *test_devman2(void);
    104102
    105103extern test_t tests[];
  • uspace/drv/rootvirt/devices.def

    r547c37a r7b712b60  
    2121        .match_id = "virtual&test1"
    2222},
    23 {
    24         .name = "test3",
    25         .match_id = "virtual&test3"
    26 },
    2723#endif
  • uspace/lib/block/libblock.c

    r547c37a r7b712b60  
    22 * Copyright (c) 2008 Jakub Jermar
    33 * Copyright (c) 2008 Martin Decky
    4  * Copyright (c) 2011 Martin Sucha
    54 * All rights reserved.
    65 *
     
    828827}
    829828
    830 /** Read bytes directly from the device (bypass cache)
    831  *
    832  * @param devmap_handle Device handle of the block device.
    833  * @param abs_offset    Absolute offset in bytes where to start reading
    834  * @param bytes                 Number of bytes to read
    835  * @param data                  Buffer that receives the data
    836  *
    837  * @return              EOK on success or negative error code on failure.
    838  */
    839 int block_read_bytes_direct(devmap_handle_t devmap_handle, aoff64_t abs_offset,
    840     size_t bytes, void *data)
    841 {
    842         int rc;
    843         size_t phys_block_size;
    844         size_t buf_size;
    845         void *buffer;
    846         aoff64_t first_block;
    847         aoff64_t last_block;
    848         size_t blocks;
    849         size_t offset;
    850        
    851         rc = block_get_bsize(devmap_handle, &phys_block_size);
    852         if (rc != EOK) {
    853                 return rc;
    854         }
    855        
    856         /* calculate data position and required space */
    857         first_block = abs_offset / phys_block_size;
    858         offset = abs_offset % phys_block_size;
    859         last_block = (abs_offset + bytes - 1) / phys_block_size;
    860         blocks = last_block - first_block + 1;
    861         buf_size = blocks * phys_block_size;
    862        
    863         /* read the data into memory */
    864         buffer = malloc(buf_size);
    865         if (buffer == NULL) {
    866                 return ENOMEM;
    867         }
    868        
    869         rc = block_read_direct(devmap_handle, first_block, blocks, buffer);
    870         if (rc != EOK) {
    871                 free(buffer);
    872                 return rc;
    873         }
    874        
    875         /* copy the data from the buffer */
    876         memcpy(data, buffer + offset, bytes);
    877         free(buffer);
    878        
    879         return EOK;
    880 }
    881 
    882829/** Read blocks from block device.
    883830 *
  • uspace/lib/block/libblock.h

    r547c37a r7b712b60  
    22 * Copyright (c) 2008 Jakub Jermar
    33 * Copyright (c) 2008 Martin Decky
    4  * Copyright (c) 2011 Martin Sucha
    54 * All rights reserved.
    65 *
     
    114113extern int block_get_nblocks(devmap_handle_t, aoff64_t *);
    115114extern int block_read_direct(devmap_handle_t, aoff64_t, size_t, void *);
    116 extern int block_read_bytes_direct(devmap_handle_t, aoff64_t, size_t, void *);
    117115extern int block_write_direct(devmap_handle_t, aoff64_t, size_t, const void *);
    118116
  • uspace/srv/vfs/vfs.h

    r547c37a r7b712b60  
    176176    vfs_pair_t *, ...);
    177177extern int vfs_open_node_internal(vfs_lookup_res_t *);
     178extern int vfs_close_internal(vfs_file_t *);
    178179
    179180extern bool vfs_nodes_init(void);
  • uspace/srv/vfs/vfs_file.c

    r547c37a r7b712b60  
    7979        for (i = 0; i < MAX_OPEN_FILES; i++) {
    8080                if (FILES[i]) {
     81                        (void) vfs_close_internal(FILES[i]);
    8182                        (void) vfs_fd_free(i);
    8283                }
     
    107108}
    108109
    109 /** Close the file in the endpoint FS server. */
    110 static int vfs_file_close_remote(vfs_file_t *file)
    111 {
    112         ipc_call_t answer;
    113         aid_t msg;
    114         sysarg_t rc;
    115         int phone;
    116 
    117         assert(!file->refcnt);
    118 
    119         phone = vfs_grab_phone(file->node->fs_handle);
    120         msg = async_send_2(phone, VFS_OUT_CLOSE, file->node->devmap_handle,
    121             file->node->index, &answer);
    122         async_wait_for(msg, &rc);
    123         vfs_release_phone(file->node->fs_handle, phone);
    124 
    125         return IPC_GET_ARG1(answer);
    126 }
    127 
    128 
    129110/** Increment reference count of VFS file structure.
    130111 *
     
    144125 *                      decremented.
    145126 */
    146 static int vfs_file_delref(vfs_file_t *file)
    147 {
    148         int rc = EOK;
    149 
     127static void vfs_file_delref(vfs_file_t *file)
     128{
    150129        assert(fibril_mutex_is_locked(&VFS_DATA->lock));
    151130
    152131        if (file->refcnt-- == 1) {
    153132                /*
    154                  * Lost the last reference to a file, need to close it in the
    155                  * endpoint FS and drop our reference to the underlying VFS node.
     133                 * Lost the last reference to a file, need to drop our reference
     134                 * to the underlying VFS node.
    156135                 */
    157                 rc = vfs_file_close_remote(file);
    158136                vfs_node_delref(file->node);
    159137                free(file);
    160138        }
    161 
    162         return rc;
    163139}
    164140
     
    225201int vfs_fd_free(int fd)
    226202{
    227         int rc;
    228 
    229203        if (!vfs_files_init())
    230204                return ENOMEM;
     
    236210        }
    237211       
    238         rc = vfs_file_delref(FILES[fd]);
     212        vfs_file_delref(FILES[fd]);
    239213        FILES[fd] = NULL;
    240214        fibril_mutex_unlock(&VFS_DATA->lock);
    241215       
    242         return rc;
     216        return EOK;
    243217}
    244218
  • uspace/srv/vfs/vfs_ops.c

    r547c37a r7b712b60  
    717717}
    718718
     719int vfs_close_internal(vfs_file_t *file)
     720{
     721        /*
     722         * Lock the open file structure so that no other thread can manipulate
     723         * the same open file at a time.
     724         */
     725        fibril_mutex_lock(&file->lock);
     726       
     727        if (file->refcnt <= 1) {
     728                /* Only close the file on the destination FS server
     729                   if there are no more file descriptors (except the
     730                   present one) pointing to this file. */
     731               
     732                int fs_phone = vfs_grab_phone(file->node->fs_handle);
     733               
     734                /* Make a VFS_OUT_CLOSE request at the destination FS server. */
     735                aid_t msg;
     736                ipc_call_t answer;
     737                msg = async_send_2(fs_phone, VFS_OUT_CLOSE,
     738                    file->node->devmap_handle, file->node->index, &answer);
     739               
     740                /* Wait for reply from the FS server. */
     741                sysarg_t rc;
     742                async_wait_for(msg, &rc);
     743               
     744                vfs_release_phone(file->node->fs_handle, fs_phone);
     745                fibril_mutex_unlock(&file->lock);
     746               
     747                return IPC_GET_ARG1(answer);
     748        }
     749       
     750        fibril_mutex_unlock(&file->lock);
     751        return EOK;
     752}
     753
    719754void vfs_close(ipc_callid_t rid, ipc_call_t *request)
    720755{
    721756        int fd = IPC_GET_ARG1(*request);
    722         int ret;
    723        
     757       
     758        /* Lookup the file structure corresponding to the file descriptor. */
     759        vfs_file_t *file = vfs_file_get(fd);
     760        if (!file) {
     761                async_answer_0(rid, ENOENT);
     762                return;
     763        }
     764       
     765        int ret = vfs_close_internal(file);
     766        if (ret != EOK)
     767                async_answer_0(rid, ret);
     768       
     769        vfs_file_put(file);
    724770        ret = vfs_fd_free(fd);
    725771        async_answer_0(rid, ret);
     
    13231369        fibril_mutex_lock(&oldfile->lock);
    13241370       
    1325         /* Make sure newfd is closed. */
    1326         (void) vfs_fd_free(newfd);
     1371        /* Lookup an open file structure possibly corresponding to newfd. */
     1372        vfs_file_t *newfile = vfs_file_get(newfd);
     1373        if (newfile) {
     1374                /* Close the originally opened file. */
     1375                int ret = vfs_close_internal(newfile);
     1376                if (ret != EOK) {
     1377                        fibril_mutex_unlock(&oldfile->lock);
     1378                        vfs_file_put(oldfile);
     1379                        vfs_file_put(newfile);
     1380                        async_answer_0(rid, ret);
     1381                        return;
     1382                }
     1383               
     1384                ret = vfs_fd_free(newfd);
     1385                if (ret != EOK) {
     1386                        fibril_mutex_unlock(&oldfile->lock);
     1387                        vfs_file_put(oldfile);
     1388                        vfs_file_put(newfile);
     1389                        async_answer_0(rid, ret);
     1390                        return;
     1391                }
     1392                vfs_file_put(newfile);
     1393        }
    13271394       
    13281395        /* Assign the old file to newfd. */
Note: See TracChangeset for help on using the changeset viewer.