VirtualBox

Changeset 77515 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Feb 28, 2019 10:35:07 PM (6 years ago)
Author:
vboxsync
Message:

linux/vboxsf: Fleshed out sf_update_inode() and refreshed sf_init_inode(). Provide birth time to kernels with the statx() syscall as well as respecting AT_STATX_FORCE_SYNC and AT_STATX_DONT_SYNC flags. bugref:9172

Location:
trunk/src/VBox/Additions/linux/sharedfolders
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/sharedfolders/regops.c

    r77492 r77515  
    5050# define SEEK_END 2
    5151#endif
    52 
    53 
    54 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
    55 
    56 /*
    57  * inode compatibility glue.
    58  */
    59 #include <iprt/asm.h>
    60 
    61 DECLINLINE(loff_t) i_size_read(struct inode *inode)
    62 {
    63         AssertCompile(sizeof(loff_t) == sizeof(uint64_t));
    64         return ASMAtomicReadU64((uint64_t volatile *)&inode->i_size);
    65 }
    66 
    67 DECLINLINE(void) i_size_write(struct inode *inode, loff_t i_size)
    68 {
    69         AssertCompile(sizeof(inode->i_size) == sizeof(uint64_t));
    70         ASMAtomicWriteU64((uint64_t volatile *)&inode->i_size, i_size);
    71 }
    72 
    73 #endif /* < 2.6.0 */
    7452
    7553
     
    11811159                case SEEK_END: {
    11821160                        struct sf_reg_info *sf_r = file->private_data;
    1183                         int rc = sf_inode_revalidate_with_handle(GET_F_DENTRY(file), sf_r->Handle.hHost, true /*fForce*/);
     1161                        int rc = sf_inode_revalidate_with_handle(GET_F_DENTRY(file), sf_r->Handle.hHost, true /*fForce*/,
     1162                                                                 false /*fInodeLocked*/);
    11841163                        if (rc == 0)
    11851164                                break;
  • trunk/src/VBox/Additions/linux/sharedfolders/utils.c

    r77505 r77515  
    3737#include <linux/vfs.h>
    3838
    39 /*
    40  * sf_reg_aops and sf_backing_dev_info are just quick implementations to make
    41  * sendfile work. For more information have a look at
     39
     40/**
     41 * Convert from VBox to linux time.
     42 */
     43#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     44DECLINLINE(void) sf_ftime_from_timespec(time_t *pLinuxDst, PCRTTIMESPEC pVBoxSrc)
     45{
     46        int64_t t = RTTimeSpecGetNano(pVBoxSrc);
     47        do_div(t, RT_NS_1SEC);
     48        *pLinuxDst = t;
     49}
     50#else   /* >= 2.6.0 */
     51# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0)
     52DECLINLINE(void) sf_ftime_from_timespec(struct timespec *pLinuxDst, PCRTTIMESPEC pVBoxSrc)
     53# else
     54DECLINLINE(void) sf_ftime_from_timespec(struct timespec64 *pLinuxDst, PCRTTIMESPEC pVBoxSrc)
     55# endif
     56{
     57        int64_t t = RTTimeSpecGetNano(pVBoxSrc);
     58        pLinuxDst->tv_nsec = do_div(t, RT_NS_1SEC);
     59        pLinuxDst->tv_sec  = t;
     60}
     61#endif  /* >= 2.6.0 */
     62
     63
     64/**
     65 * Convert from linux to VBox time.
     66 */
     67#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     68DECLINLINE(void) sf_timespec_from_ftime(PRTTIMESPEC pVBoxDst, time_t *pLinuxSrc)
     69{
     70        RTTimeSpecSetNano(pVBoxDst, RT_NS_1SEC_64 * *pLinuxSrc);
     71}
     72#else   /* >= 2.6.0 */
     73# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0)
     74DECLINLINE(void) sf_timespec_from_ftime(PRTTIMESPEC pVBoxDst, struct timespec const *pLinuxSrc)
     75# else
     76DECLINLINE(void) sf_timespec_from_ftime(PRTTIMESPEC pVBoxDst, struct timespec64 const *pLinuxSrc)
     77# endif
     78{
     79        RTTimeSpecSetNano(pVBoxDst, pLinuxSrc->tv_nsec + pLinuxSrc->tv_sec * (int64_t)RT_NS_1SEC);
     80}
     81#endif  /* >= 2.6.0 */
     82
     83
     84/**
     85 * Converts VBox access permissions  to Linux ones (mode & 0777).
    4286 *
    43  *   http://us1.samba.org/samba/ftp/cifs-cvs/ols2006-fs-tutorial-smf.odp
    44  *
    45  * and the sample implementation
    46  *
    47  *   http://pserver.samba.org/samba/ftp/cifs-cvs/samplefs.tar.gz
    48  */
    49 
    50 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
    51 
    52 DECLINLINE(void) sf_ftime_from_timespec(time_t * time, RTTIMESPEC *ts)
    53 {
    54         int64_t t = RTTimeSpecGetNano(ts);
    55         do_div(t, RT_NS_1SEC);
    56         *time = t;
    57 }
    58 
    59 DECLINLINE(void) sf_timespec_from_ftime(RTTIMESPEC * ts, time_t *time)
    60 {
    61         RTTimeSpecSetNano(ts, RT_NS_1SEC_64 * *time);
    62 }
    63 
    64 #else   /* >= 2.6.0 */
    65 
    66 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0)
    67 DECLINLINE(void) sf_ftime_from_timespec(struct timespec *tv, RTTIMESPEC *ts)
    68 # else
    69 DECLINLINE(void) sf_ftime_from_timespec(struct timespec64 *tv, RTTIMESPEC *ts)
    70 # endif
    71 {
    72         int64_t t = RTTimeSpecGetNano(ts);
    73         tv->tv_nsec = do_div(t, RT_NS_1SEC);
    74         tv->tv_sec  = t;
    75 }
    76 
    77 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0)
    78 DECLINLINE(void) sf_timespec_from_ftime(RTTIMESPEC *ts, struct timespec *tv)
    79 # else
    80 DECLINLINE(void) sf_timespec_from_ftime(RTTIMESPEC *ts, struct timespec64 *tv)
    81 # endif
    82 {
    83         RTTimeSpecSetNano(ts, tv->tv_nsec + tv->tv_sec * (int64_t)RT_NS_1SEC);
    84 }
    85 
    86 #endif  /* >= 2.6.0 */
    87 
    88 /* set [inode] attributes based on [info], uid/gid based on [sf_g] */
    89 void sf_init_inode(struct inode *inode, struct sf_inode_info *sf_i, PSHFLFSOBJINFO info, struct sf_glob_info *sf_g)
    90 {
    91         PCSHFLFSOBJATTR attr = &info->Attr;
    92         int mode;
     87 * @note Currently identical.
     88 */
     89DECLINLINE(int) sf_convert_access_perms(uint32_t fAttr)
     90{
     91        /* Access bits should be the same: */
     92        AssertCompile(RTFS_UNIX_IRUSR == S_IRUSR);
     93        AssertCompile(RTFS_UNIX_IWUSR == S_IWUSR);
     94        AssertCompile(RTFS_UNIX_IXUSR == S_IXUSR);
     95        AssertCompile(RTFS_UNIX_IRGRP == S_IRGRP);
     96        AssertCompile(RTFS_UNIX_IWGRP == S_IWGRP);
     97        AssertCompile(RTFS_UNIX_IXGRP == S_IXGRP);
     98        AssertCompile(RTFS_UNIX_IROTH == S_IROTH);
     99        AssertCompile(RTFS_UNIX_IWOTH == S_IWOTH);
     100        AssertCompile(RTFS_UNIX_IXOTH == S_IXOTH);
     101
     102        return fAttr & RTFS_UNIX_ALL_ACCESS_PERMS;
     103}
     104
     105
     106/**
     107 * Produce the Linux mode mask, given VBox, mount options and file type.
     108 */
     109DECLINLINE(int) sf_convert_file_mode(uint32_t fVBoxMode, int fFixedMode, int fClearMask, int fType)
     110{
     111        int fLnxMode = sf_convert_access_perms(fVBoxMode);
     112        if (fFixedMode != ~0)
     113                fLnxMode = fFixedMode & 0777;
     114        fLnxMode &= ~fClearMask;
     115        fLnxMode |= fType;
     116        return fLnxMode;
     117}
     118
     119
     120/**
     121 * Initializes the @a inode attributes based on @a pObjInfo and @a sf_g options.
     122 */
     123void sf_init_inode(struct inode *inode, struct sf_inode_info *sf_i, PSHFLFSOBJINFO pObjInfo, struct sf_glob_info *sf_g)
     124{
     125        PCSHFLFSOBJATTR pAttr = &pObjInfo->Attr;
    93126
    94127        TRACE();
     
    96129        sf_i->ts_up_to_date = jiffies;
    97130        sf_i->force_restat  = 0;
    98 
    99 #define mode_set(r) attr->fMode & (RTFS_UNIX_##r) ? (S_##r) : 0;
    100         mode = mode_set(IRUSR);
    101         mode |= mode_set(IWUSR);
    102         mode |= mode_set(IXUSR);
    103 
    104         mode |= mode_set(IRGRP);
    105         mode |= mode_set(IWGRP);
    106         mode |= mode_set(IXGRP);
    107 
    108         mode |= mode_set(IROTH);
    109         mode |= mode_set(IWOTH);
    110         mode |= mode_set(IXOTH);
    111 
    112 #undef mode_set
    113131
    114132#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     
    118136# endif
    119137#endif
    120 
    121         if (RTFS_IS_DIRECTORY(attr->fMode)) {
    122                 inode->i_mode = sf_g->dmode != ~0 ? (sf_g->dmode & 0777) : mode;
    123                 inode->i_mode &= ~sf_g->dmask;
    124                 inode->i_mode |= S_IFDIR;
     138        if (RTFS_IS_DIRECTORY(pAttr->fMode)) {
     139                inode->i_mode = sf_convert_file_mode(pAttr->fMode, sf_g->dmode, sf_g->dmask, S_IFDIR);
    125140                inode->i_op = &sf_dir_iops;
    126141                inode->i_fop = &sf_dir_fops;
     142
    127143                /* XXX: this probably should be set to the number of entries
    128144                   in the directory plus two (. ..) */
    129 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
    130145                set_nlink(inode, 1);
    131 #else
    132                 inode->i_nlink = 1;
    133 #endif
    134146        }
    135147#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 8)
    136         else if (RTFS_IS_SYMLINK(attr->fMode)) {
    137                 inode->i_mode = sf_g->fmode != ~0 ? (sf_g->fmode & 0777) : mode;
    138                 inode->i_mode &= ~sf_g->fmask;
    139                 inode->i_mode |= S_IFLNK;
     148        else if (RTFS_IS_SYMLINK(pAttr->fMode)) {
     149                /** @todo r=bird: Aren't System V symlinks w/o any mode mask? IIRC there is
     150                 *        no lchmod on Linux. */
     151                inode->i_mode = sf_convert_file_mode(pAttr->fMode, sf_g->fmode, sf_g->fmask, S_IFLNK);
    140152                inode->i_op = &sf_lnk_iops;
    141 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
    142153                set_nlink(inode, 1);
    143 # else
    144                 inode->i_nlink = 1;
    145 # endif
    146154        }
    147155#endif
    148156        else {
    149                 inode->i_mode = sf_g->fmode != ~0 ? (sf_g->fmode & 0777) : mode;
    150                 inode->i_mode &= ~sf_g->fmask;
    151                 inode->i_mode |= S_IFREG;
     157                inode->i_mode = sf_convert_file_mode(pAttr->fMode, sf_g->fmode, sf_g->fmask, S_IFREG);
    152158                inode->i_op = &sf_reg_iops;
    153159                inode->i_fop = &sf_reg_fops;
    154 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
    155160                set_nlink(inode, 1);
    156 #else
    157                 inode->i_nlink = 1;
    158 #endif
    159161        }
    160162
     
    167169#endif
    168170
    169         inode->i_size = info->cbObject;
     171        inode->i_size = pObjInfo->cbObject;
    170172#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) && !defined(KERNEL_FC6)
    171173        inode->i_blksize = 4096;
     
    175177#endif
    176178        /* i_blocks always in units of 512 bytes! */
    177         inode->i_blocks = (info->cbAllocated + 511) / 512;
    178 
    179         sf_ftime_from_timespec(&inode->i_atime, &info->AccessTime);
    180         sf_ftime_from_timespec(&inode->i_ctime, &info->ChangeTime);
    181         sf_ftime_from_timespec(&inode->i_mtime, &info->ModificationTime);
     179        inode->i_blocks = (pObjInfo->cbAllocated + 511) / 512;
     180
     181        sf_ftime_from_timespec(&inode->i_atime, &pObjInfo->AccessTime);
     182        sf_ftime_from_timespec(&inode->i_ctime, &pObjInfo->ChangeTime);
     183        sf_ftime_from_timespec(&inode->i_mtime, &pObjInfo->ModificationTime);
     184        sf_i->BirthTime = pObjInfo->BirthTime;
    182185}
    183186
    184187/**
    185188 * Update the inode with new object info from the host.
    186  */
    187 void sf_update_inode(struct inode *pInode, struct sf_inode_info *pInfoInfo, PSHFLFSOBJINFO pObjInfo, struct sf_glob_info *sf_g)
    188 {
    189         /** @todo  make lock/rcu safe.  */
    190         sf_init_inode(pInode, pInfoInfo, pObjInfo, sf_g);
     189 *
     190 * Called by sf_inode_revalidate() and sf_inode_revalidate_with_handle(), the
     191 * inode is probably locked...
     192 *
     193 * @todo sort out the inode locking situation.
     194 */
     195static void sf_update_inode(struct inode *pInode, struct sf_inode_info *pInodeInfo, PSHFLFSOBJINFO pObjInfo,
     196                            struct sf_glob_info *sf_g, bool fInodeLocked)
     197{
     198        PCSHFLFSOBJATTR pAttr = &pObjInfo->Attr;
     199        int fMode;
     200
     201        TRACE();
     202
     203#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
     204        if (!fInodeLocked)
     205                inode_lock(pInode);
     206#endif
     207
     208        /*
     209         * Calc new mode mask and update it if it changed.
     210         */
     211        if (RTFS_IS_DIRECTORY(pAttr->fMode))
     212                fMode = sf_convert_file_mode(pAttr->fMode, sf_g->dmode, sf_g->dmask, S_IFDIR);
     213#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 8)
     214        else if (RTFS_IS_SYMLINK(pAttr->fMode))
     215                /** @todo r=bird: Aren't System V symlinks w/o any mode mask? IIRC there is
     216                 *        no lchmod on Linux. */
     217                fMode = sf_convert_file_mode(pAttr->fMode, sf_g->fmode, sf_g->fmask, S_IFLNK);
     218#endif
     219        else
     220                fMode = sf_convert_file_mode(pAttr->fMode, sf_g->fmode, sf_g->fmask, S_IFREG);
     221
     222        if (fMode == pInode->i_mode) {
     223                /* likely */
     224        } else {
     225                if ((fMode & S_IFMT) == (pInode->i_mode & S_IFMT))
     226                        pInode->i_mode = fMode;
     227                else {
     228                        SFLOGFLOW(("sf_update_inode: Changed from %o to %o (%s)\n",
     229                                   pInode->i_mode & S_IFMT, fMode & S_IFMT, pInodeInfo->path->String.ach));
     230                        /** @todo we probably need to be more drastic... */
     231                        sf_init_inode(pInode, pInodeInfo, pObjInfo, sf_g);
     232
     233#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
     234                        if (!fInodeLocked)
     235                                inode_unlock(pInode);
     236#endif
     237                        return;
     238                }
     239        }
     240
     241        /*
     242         * Update the sizes.
     243         * Note! i_blocks is always in units of 512 bytes!
     244         */
     245        pInode->i_blocks = (pObjInfo->cbAllocated + 511) / 512;
     246        i_size_write(pInode, pObjInfo->cbObject);
     247
     248        /*
     249         * Update the timestamps.
     250         */
     251        sf_ftime_from_timespec(&pInode->i_atime, &pObjInfo->AccessTime);
     252        sf_ftime_from_timespec(&pInode->i_ctime, &pObjInfo->ChangeTime);
     253        sf_ftime_from_timespec(&pInode->i_mtime, &pObjInfo->ModificationTime);
     254        pInodeInfo->BirthTime = pObjInfo->BirthTime;
     255
     256        /*
     257         * Mark it as up to date.
     258         */
     259        pInodeInfo->ts_up_to_date = jiffies;
     260        pInodeInfo->force_restat  = 0;
     261
     262#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
     263        if (!fInodeLocked)
     264                inode_unlock(pInode);
     265#endif
    191266}
    192267
     
    235310
    236311/**
    237  * Revalidate an inode.
     312 * Revalidate an inode, inner worker.
    238313 *
    239  * This is called directly as inode-op on 2.4, indirectly as dir-op
    240  * sf_dentry_revalidate() on 2.4/2.6, indirectly as inode-op through
    241  * sf_getattr() on 2.6.  The job is to find out whether dentry/inode is still
    242  * valid.  The test fails if @a dentry does not have an inode or sf_stat() is
    243  * unsuccessful, otherwise we return success and update inode attributes.
    244  */
    245 int sf_inode_revalidate(struct dentry *dentry)
     314 * @sa sf_inode_revalidate()
     315 */
     316int sf_inode_revalidate_worker(struct dentry *dentry, bool fForced)
    246317{
    247318        int rc;
     
    256327                 * Can we get away without any action here?
    257328                 */
    258                 if (   !sf_i->force_restat
     329                if (   !fForced
     330                    && !sf_i->force_restat
    259331                    && jiffies - sf_i->ts_up_to_date < sf_g->ttl)
    260332                        rc = 0;
     
    275347                                                 * Reset the TTL and copy the info over into the inode structure.
    276348                                                 */
    277                                                 sf_update_inode(pInode, sf_i, &pReq->ObjInfo, sf_g);
     349                                                sf_update_inode(pInode, sf_i, &pReq->ObjInfo, sf_g, true /*fInodeLocked??*/);
    278350                                        } else if (rc == VERR_INVALID_HANDLE) {
    279351                                                rc = -ENOENT; /* Restore.*/
     
    285357                                } else
    286358                                        rc = -ENOMEM;
    287                                 sf_handle_release(pHandle, sf_g, "sf_inode_revalidate");
     359                                sf_handle_release(pHandle, sf_g, "sf_inode_revalidate_worker");
    288360
    289361                        } else {
     
    303375                                                         * Reset the TTL and copy the info over into the inode structure.
    304376                                                         */
    305                                                         sf_update_inode(pInode, sf_i, &pReq->CreateParms.Info, sf_g);
     377                                                        sf_update_inode(pInode, sf_i, &pReq->CreateParms.Info,
     378                                                                        sf_g, true /*fInodeLocked??*/);
    306379                                                        rc = 0;
    307380                                                } else {
     
    327400}
    328401
     402
     403/**
     404 * Revalidate an inode.
     405 *
     406 * This is called directly as inode-op on 2.4, indirectly as dir-op
     407 * sf_dentry_revalidate() on 2.4/2.6.  The job is to find out whether
     408 * dentry/inode is still valid.  The test fails if @a dentry does not have an
     409 * inode or sf_stat() is unsuccessful, otherwise we return success and update
     410 * inode attributes.
     411 */
     412int sf_inode_revalidate(struct dentry *dentry)
     413{
     414    return sf_inode_revalidate_worker(dentry, false /*fForced*/);
     415}
     416
     417
    329418/**
    330419 * Similar to sf_inode_revalidate, but uses associated host file handle as that
    331420 * is quite a bit faster.
    332421 */
    333 int sf_inode_revalidate_with_handle(struct dentry *dentry, SHFLHANDLE hHostFile, bool fForced)
     422int sf_inode_revalidate_with_handle(struct dentry *dentry, SHFLHANDLE hHostFile, bool fForced, bool fInodeLocked)
    334423{
    335424        int err;
     
    363452                                         * Reset the TTL and copy the info over into the inode structure.
    364453                                         */
    365                                         sf_update_inode(pInode, sf_i, &pReq->ObjInfo, sf_g);
     454                                        sf_update_inode(pInode, sf_i, &pReq->ObjInfo, sf_g, fInodeLocked);
    366455                                } else {
    367456                                        LogFunc(("VbglR0SfHostReqQueryObjInfo failed on %#RX64: %Rrc\n", hHostFile, err));
     
    400489# endif
    401490
    402         rc = sf_inode_revalidate(dentry);
     491# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     492        /*
     493         * With the introduction of statx() userland can control whether we
     494         * update the inode information or not.
     495         */
     496        switch (flags & AT_STATX_SYNC_TYPE) {
     497                default:
     498                        rc = sf_inode_revalidate_worker(dentry, false /*fForced*/);
     499                        break;
     500
     501                case AT_STATX_FORCE_SYNC:
     502                        rc = sf_inode_revalidate_worker(dentry, true /*fForced*/);
     503                        break;
     504
     505                case AT_STATX_DONT_SYNC:
     506                        rc = 0;
     507                        break;
     508        }
     509# else
     510        rc = sf_inode_revalidate_worker(dentry, false /*fForced*/);
     511# endif
    403512        if (rc == 0) {
     513                /* Do generic filling in of info. */
    404514                generic_fillattr(dentry->d_inode, kstat);
     515
     516                /* Add birth time. */
     517#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     518                if (dentry->d_inode) {
     519                        struct sf_inode_info *pInodeInfo = GET_INODE_INFO(dentry->d_inode);
     520                        if (pInodeInfo) {
     521                                sf_ftime_from_timespec(&kstat->btime, &pInodeInfo->BirthTime);
     522                                kstat->result_mask |= STATX_BTIME;
     523                        }
     524                }
     525#endif
    405526
    406527                /*
     
    554675         * dentry and all its parent entries are valid and could touch their timestamps
    555676         * extending their TTL (CIFS does that). */
    556         sf_i->force_restat = 1; /* temp fix */
    557         return sf_inode_revalidate(dentry);
     677        return sf_inode_revalidate_worker(dentry, true /*fForced*/);
    558678
    559679 fail1:
     
    9751095 * This is called during name resolution/lookup to check if the @a dentry in the
    9761096 * cache is still valid.  The actual validation is job is handled by
    977  * sf_inode_revalidate().
     1097 * sf_inode_revalidate_worker().
    9781098 */
    9791099static int
     
    10291149                                SFLOGFLOW(("sf_dentry_revalidate: age: %lu vs. TTL %lu -> 1\n", cJiffiesAge, sf_g->ttl));
    10301150                                rc = 1;
    1031                         } else if (!sf_inode_revalidate(dentry /** @todo force */)) {
     1151                        } else if (!sf_inode_revalidate_worker(dentry, true /*fForced*/)) {
    10321152                                sf_dentry_set_update_jiffies(dentry, jiffies); /** @todo get jiffies from inode. */
    10331153                                SFLOGFLOW(("sf_dentry_revalidate: age: %lu vs. TTL %lu -> reval -> 1\n", cJiffiesAge, sf_g->ttl));
     
    10791199
    10801200/** For logging purposes only. */
     1201# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
    10811202static int sf_dentry_delete(const struct dentry *pDirEntry)
     1203# else
     1204static int sf_dentry_delete(struct dentry *pDirEntry)
     1205# endif
    10821206{
    10831207        SFLOGFLOW(("sf_dentry_delete: %p\n", pDirEntry));
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c

    r77502 r77515  
    3131/**
    3232 * @note Anyone wishing to make changes here might wish to take a look at
    33  *  https://github.com/torvalds/linux/blob/master/Documentation/filesystems/vfs.txt
     33 * https://github.com/torvalds/linux/blob/master/Documentation/filesystems/vfs.txt
    3434 * which seems to be the closest there is to official documentation on
    3535 * writing filesystem drivers for Linux.
     36 *
     37 * See also: http://us1.samba.org/samba/ftp/cifs-cvs/ols2006-fs-tutorial-smf.odp
    3638 */
    3739
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h

    r77492 r77515  
    5252#include <VBox/VBoxGuestLibSharedFolders.h>
    5353#include <VBox/VBoxGuestLibSharedFoldersInline.h>
     54#include <iprt/asm.h>
    5455#include "vbsfmount.h"
     56
     57
     58/*
     59 * inode compatibility glue.
     60 */
     61#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     62
     63DECLINLINE(loff_t) i_size_read(struct inode *pInode)
     64{
     65        AssertCompile(sizeof(loff_t) == sizeof(uint64_t));
     66        return ASMAtomicReadU64((uint64_t volatile *)&pInode->i_size);
     67}
     68
     69DECLINLINE(void) i_size_write(struct inode *pInode, loff_t cbNew)
     70{
     71        AssertCompile(sizeof(pInode->i_size) == sizeof(uint64_t));
     72        ASMAtomicWriteU64((uint64_t volatile *)&pInode->i_size, cbNew);
     73}
     74
     75#endif /* < 2.6.0 */
     76
     77#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0)
     78DECLINLINE(void) set_nlink(struct inode *pInode, unsigned int cLinks)
     79{
     80        pInode->i_nlink = cLinks;
     81}
     82#endif
     83
    5584
    5685#define DIR_BUFFER_SIZE (16*_1K)
     
    121150        SHFLSTRING *path;
    122151        /** Some information was changed, update data on next revalidate */
    123         int force_restat;
     152        bool force_restat;
    124153        /** directory content changed, update the whole directory on next sf_getdent */
    125         int force_reread;
     154        bool force_reread;
    126155        /** The timestamp (jiffies) where the inode info was last updated. */
    127         unsigned long ts_up_to_date;
     156        unsigned long           ts_up_to_date;
     157        /** The birth time. */
     158        RTTIMESPEC              BirthTime;
    128159
    129160        /** handle valid if a file was created with sf_create_aux until it will
     
    265296                   SHFLSTRING * path, PSHFLFSOBJINFO result, int ok_to_fail);
    266297extern int sf_inode_revalidate(struct dentry *dentry);
    267 int sf_inode_revalidate_with_handle(struct dentry *dentry, SHFLHANDLE hHostFile, bool fForced);
     298extern int sf_inode_revalidate_worker(struct dentry *dentry, bool fForced);
     299extern int sf_inode_revalidate_with_handle(struct dentry *dentry, SHFLHANDLE hHostFile, bool fForced, bool fInodeLocked);
    268300#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
    269301# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette