Changeset 11884

Show
Ignore:
Timestamp:
03/17/05 16:04:25 (4 years ago)
Author:
bonefish
Message:

Added missing select()/deselect() Hooks to the file system interface
and made sure they are called by the VFS, if existent.

Location:
haiku/trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • haiku/trunk/headers/os/drivers/fs_interface.h

    r11718 r11884  
    1818struct stat; 
    1919struct fs_info; 
     20struct select_sync; 
    2021 
    2122typedef dev_t mount_id; 
     
    8485        status_t (*ioctl)(fs_volume fs, fs_vnode v, fs_cookie cookie, ulong op, void *buffer, size_t length); 
    8586        status_t (*set_flags)(fs_volume fs, fs_vnode v, fs_cookie cookie, int flags); 
     87        status_t (*select)(fs_volume fs, fs_vnode v, fs_cookie cookie, uint8 event, 
     88                                uint32 ref, selectsync *sync); 
     89        status_t (*deselect)(fs_volume fs, fs_vnode v, fs_cookie cookie, 
     90                                uint8 event, selectsync *sync); 
    8691        status_t (*fsync)(fs_volume fs, fs_vnode v); 
    8792 
  • haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp

    r11722 r11884  
    20282028        &bfs_ioctl, 
    20292029        &bfs_set_flags, 
     2030        NULL,   // &bfs_select 
     2031        NULL,   // &bfs_deselect 
    20302032        &bfs_fsync, 
    20312033 
  • haiku/trunk/src/kernel/core/fs/bootfs.c

    r11753 r11884  
    980980        &bootfs_ioctl, 
    981981        NULL,   // set_flags 
     982        NULL,   // select 
     983        NULL,   // deselect 
    982984        &bootfs_fsync, 
    983985 
  • haiku/trunk/src/kernel/core/fs/devfs.cpp

    r11015 r11884  
    13651365 
    13661366 
     1367static status_t 
     1368devfs_select(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, uint8 event, 
     1369        uint32 ref, selectsync *sync) 
     1370{ 
     1371        struct devfs_vnode *vnode = (struct devfs_vnode *)_vnode; 
     1372        struct devfs_cookie *cookie = (struct devfs_cookie *)_cookie; 
     1373 
     1374        if (!S_ISCHR(vnode->stream.type)) 
     1375                return B_NOT_ALLOWED; 
     1376 
     1377        // If the device has no select() hook, notify select() now. 
     1378        if (!vnode->stream.u.dev.info->select) 
     1379                return notify_select_event((selectsync*)sync, ref, event); 
     1380 
     1381        return vnode->stream.u.dev.info->select(cookie->u.dev.dcookie, event, ref, 
     1382                (selectsync*)sync); 
     1383} 
     1384 
     1385 
     1386static status_t 
     1387devfs_deselect(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, uint8 event, 
     1388        selectsync *sync) 
     1389{ 
     1390        struct devfs_vnode *vnode = (struct devfs_vnode *)_vnode; 
     1391        struct devfs_cookie *cookie = (struct devfs_cookie *)_cookie; 
     1392 
     1393        if (!S_ISCHR(vnode->stream.type)) 
     1394                return B_NOT_ALLOWED; 
     1395 
     1396        // If the device has no select() hook, notify select() now. 
     1397        if (!vnode->stream.u.dev.info->deselect) 
     1398                return B_OK; 
     1399 
     1400        return vnode->stream.u.dev.info->deselect(cookie->u.dev.dcookie, event, 
     1401                (selectsync*)sync); 
     1402} 
     1403 
     1404 
    13671405static bool 
    13681406devfs_can_page(fs_volume _fs, fs_vnode _vnode, fs_cookie cookie) 
     
    15461584        &devfs_ioctl, 
    15471585        &devfs_set_flags, 
     1586        &devfs_select, 
     1587        &devfs_deselect, 
    15481588        &devfs_fsync, 
    15491589 
  • haiku/trunk/src/kernel/core/fs/pipefs.cpp

    r11719 r11884  
    14401440 
    14411441 
     1442static status_t 
     1443pipefs_select(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, uint8 event, 
     1444        uint32 ref, selectsync *sync) 
     1445{ 
     1446        // ToDo: Implement! 
     1447        return notify_select_event(sync, ref, event); 
     1448} 
     1449 
     1450 
     1451static status_t 
     1452pipefs_deselect(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, uint8 event, 
     1453        selectsync *sync) 
     1454{ 
     1455        // ToDo: Implement! 
     1456        return B_OK; 
     1457} 
     1458 
     1459 
    14421460static bool 
    14431461pipefs_can_page(fs_volume _volume, fs_vnode _v, fs_cookie cookie) 
     
    15881606        &pipefs_ioctl, 
    15891607        &pipefs_set_flags, 
     1608        &pipefs_select, 
     1609        &pipefs_deselect, 
    15901610        &pipefs_fsync, 
    15911611 
  • haiku/trunk/src/kernel/core/fs/rootfs.c

    r11753 r11884  
    10571057        &rootfs_ioctl, 
    10581058        NULL,   // fs_set_flags() 
     1059        NULL,   // select 
     1060        NULL,   // deselect 
    10591061        &rootfs_fsync, 
    10601062 
  • haiku/trunk/src/kernel/core/fs/vfs.cpp

    r11868 r11884  
    188188static void file_free_fd(struct file_descriptor *); 
    189189static status_t file_close(struct file_descriptor *); 
     190static status_t file_select(struct file_descriptor *, uint8 event, uint32 ref, 
     191        struct select_sync *sync); 
     192static status_t file_deselect(struct file_descriptor *, uint8 event, 
     193        struct select_sync *sync); 
    190194static status_t dir_read(struct file_descriptor *, struct dirent *buffer, size_t bufferSize, uint32 *_count); 
    191195static status_t dir_read(struct vnode *vnode, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_count); 
     
    231235        file_seek, 
    232236        common_ioctl, 
    233         NULL,           // select() 
    234         NULL,           // deselect() 
     237        file_select, 
     238        file_deselect, 
    235239        NULL,           // read_dir() 
    236240        NULL,           // rewind_dir() 
     
    31503154 
    31513155static status_t 
     3156file_select(struct file_descriptor *descriptor, uint8 event, uint32 ref, 
     3157        struct select_sync *sync) 
     3158{ 
     3159        FUNCTION(("file_select(%p, %u, %lu, %p)\n", descriptor, event, ref, sync)); 
     3160 
     3161        struct vnode *vnode = descriptor->u.vnode; 
     3162 
     3163        // If the FS has no select() hook, notify select() now. 
     3164        if (FS_CALL(vnode, select) == NULL) 
     3165                return notify_select_event((selectsync*)sync, ref, event); 
     3166 
     3167        return FS_CALL(vnode, select)(vnode->mount->cookie, vnode->private_node, 
     3168                descriptor->cookie, event, ref, (selectsync*)sync); 
     3169} 
     3170 
     3171 
     3172static status_t 
     3173file_deselect(struct file_descriptor *descriptor, uint8 event, 
     3174        struct select_sync *sync) 
     3175{ 
     3176        struct vnode *vnode = descriptor->u.vnode; 
     3177 
     3178        if (FS_CALL(vnode, deselect) == NULL) 
     3179                return B_OK; 
     3180 
     3181        return FS_CALL(vnode, deselect)(vnode->mount->cookie, vnode->private_node, 
     3182                descriptor->cookie, event, (selectsync*)sync); 
     3183} 
     3184 
     3185 
     3186static status_t 
    31523187dir_create_entry_ref(mount_id mountID, vnode_id parentID, const char *name, int perms, bool kernel) 
    31533188{