Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/modules/vfs_scannedonly.c

    r596 r745  
    22 * scannedonly VFS module for Samba 3.5
    33 *
    4  * Copyright 2007,2008,2009 (C) Olivier Sessink
     4 * Copyright 2007,2008,2009,2010 (C) Olivier Sessink
    55 *
    66 * This program is free software; you can redistribute it and/or modify
     
    4949
    5050#include "includes.h"
     51#include "smbd/smbd.h"
     52#include "system/filesys.h"
    5153
    5254#include "config.h"
     
    378380        TALLOC_CTX *ctx=talloc_tos();
    379381        char *cachefile;
    380         int retval;
     382        int retval = -1;
    381383        int didloop;
    382384        DEBUG(SCANNEDONLY_DEBUG,
     
    477479                while (retval != 0      /*&& errno == ENOENT */
    478480                       && i < recheck_tries) {
    479                         struct timespec req = { 0, recheck_time * 10000 };
    480481                        DEBUG(SCANNEDONLY_DEBUG,
    481482                              ("scannedonly_allow_access, wait (try=%d "
     
    483484                               i, recheck_tries,
    484485                               recheck_time, cache_smb_fname->base_name));
    485                         nanosleep(&req, NULL);
     486                        smb_msleep(recheck_time);
    486487                        retval = SMB_VFS_NEXT_STAT(handle, cache_smb_fname);
    487488                        i++;
     
    527528        return (SMB_STRUCT_DIR *) sDIR;
    528529}
     530
     531static SMB_STRUCT_DIR *scannedonly_fdopendir(vfs_handle_struct * handle,
     532                                           files_struct *fsp,
     533                                           const char *mask, uint32 attr)
     534{
     535        SMB_STRUCT_DIR *DIRp;
     536        struct scannedonly_DIR *sDIR;
     537        const char *fname;
     538
     539        DIRp = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
     540        if (!DIRp) {
     541                return NULL;
     542        }
     543
     544        fname = (const char *)fsp->fsp_name->base_name;
     545
     546        sDIR = TALLOC_P(NULL, struct scannedonly_DIR);
     547        if (fname[0] != '/') {
     548                sDIR->base = construct_full_path(sDIR,handle, fname, true);
     549        } else {
     550                sDIR->base = name_w_ending_slash(sDIR, fname);
     551        }
     552        DEBUG(SCANNEDONLY_DEBUG,
     553                        ("scannedonly_fdopendir, fname=%s, base=%s\n",fname,sDIR->base));
     554        sDIR->DIR = DIRp;
     555        sDIR->notify_loop_done = 0;
     556        return (SMB_STRUCT_DIR *) sDIR;
     557}
     558
    529559
    530560static SMB_STRUCT_DIRENT *scannedonly_readdir(vfs_handle_struct *handle,
     
    767797        struct smb_filename *smb_fname_dst_tmp = NULL;
    768798        char *cachefile_src, *cachefile_dst;
     799        bool needscandst=false;
     800        int ret;
    769801        TALLOC_CTX *ctx = talloc_tos();
    770802
     
    778810                smb_fname_dst->base_name,
    779811                STRUCTSCANO(handle->data)->p_scanned);
    780 
    781812        create_synthetic_smb_fname(ctx, cachefile_src,NULL,NULL,
    782813                                   &smb_fname_src_tmp);
     
    784815                                   &smb_fname_dst_tmp);
    785816
    786         if (SMB_VFS_NEXT_RENAME(handle, smb_fname_src_tmp, smb_fname_dst_tmp)
    787             != 0) {
     817        ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src_tmp, smb_fname_dst_tmp);
     818        if (ret == ENOENT) {
     819                needscandst=true;
     820        } else if (ret != 0) {
    788821                DEBUG(SCANNEDONLY_DEBUG,
    789                       ("failed to rename %s into %s\n", cachefile_src,
    790                        cachefile_dst));
    791         }
    792         return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
     822                      ("failed to rename %s into %s error %d: %s\n", cachefile_src,
     823                       cachefile_dst, ret, strerror(ret)));
     824                needscandst=true;
     825        }
     826        ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
     827        if (ret == 0 && needscandst) {
     828                notify_scanner(handle, smb_fname_dst->base_name);
     829                flush_sendbuffer(handle);
     830        }
     831        return ret;
    793832}
    794833
     
    9791018static struct vfs_fn_pointers vfs_scannedonly_fns = {
    9801019        .opendir = scannedonly_opendir,
     1020        .fdopendir = scannedonly_fdopendir,
    9811021        .readdir = scannedonly_readdir,
    9821022        .seekdir = scannedonly_seekdir,
     
    9871027        .stat = scannedonly_stat,
    9881028        .lstat = scannedonly_lstat,
    989         .open = scannedonly_open,
     1029        .open_fn = scannedonly_open,
    9901030        .close_fn = scannedonly_close,
    9911031        .rename = scannedonly_rename,
Note: See TracChangeset for help on using the changeset viewer.