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/libsmb/libsmb_stat.c

    r414 r745  
    88   Copyright (C) Derrell Lipman 2003-2008
    99   Copyright (C) Jeremy Allison 2007, 2008
    10    
     10
    1111   This program is free software; you can redistribute it and/or modify
    1212   it under the terms of the GNU General Public License as published by
    1313   the Free Software Foundation; either version 3 of the License, or
    1414   (at your option) any later version.
    15    
     15
    1616   This program is distributed in the hope that it will be useful,
    1717   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1919   GNU General Public License for more details.
    20    
     20
    2121   You should have received a copy of the GNU General Public License
    2222   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2424
    2525#include "includes.h"
     26#include "libsmb/libsmb.h"
    2627#include "libsmbclient.h"
    2728#include "libsmb_internal.h"
     
    3738{
    3839        if (!context || !context->internal->initialized) {
    39                
    4040                errno = EINVAL;
    4141                return -1;
    42                
    43         }
    44        
     42        }
     43
    4544        if (!*name) return 2; /* FIXME, why 2 ??? */
    4645        return (ino_t)str_checksum(name);
    47        
    4846}
    4947
     
    6159{
    6260        TALLOC_CTX *frame = talloc_stackframe();
    63        
     61
    6462        st->st_mode = 0;
    65        
     63
    6664        if (IS_DOS_DIR(mode)) {
    6765                st->st_mode = SMBC_DIR_MODE;
     
    6967                st->st_mode = SMBC_FILE_MODE;
    7068        }
    71        
     69
    7270        if (IS_DOS_ARCHIVE(mode)) st->st_mode |= S_IXUSR;
    7371        if (IS_DOS_SYSTEM(mode)) st->st_mode |= S_IXGRP;
    7472        if (IS_DOS_HIDDEN(mode)) st->st_mode |= S_IXOTH;
    7573        if (!IS_DOS_READONLY(mode)) st->st_mode |= S_IWUSR;
    76        
     74
    7775        st->st_size = size;
    7876#ifdef HAVE_STAT_ST_BLKSIZE
     
    8785        st->st_uid = getuid();
    8886        st->st_gid = getgid();
    89        
     87
    9088        if (IS_DOS_DIR(mode)) {
    9189                st->st_nlink = 2;
     
    9391                st->st_nlink = 1;
    9492        }
    95        
     93
    9694        if (st->st_ino == 0) {
    9795                st->st_ino = generate_inode(context, fname);
    9896        }
    99        
     97
    10098        TALLOC_FREE(frame);
    10199        return True;  /* FIXME: Is this needed ? */
    102        
    103100}
    104101
     
    126123        SMB_INO_T ino = 0;
    127124        TALLOC_CTX *frame = talloc_stackframe();
    128        
     125
    129126        if (!context || !context->internal->initialized) {
    130                
    131127                errno = EINVAL;  /* Best I can think of ... */
    132128                TALLOC_FREE(frame);
    133129                return -1;
    134130        }
    135        
     131
    136132        if (!fname) {
    137133                errno = EINVAL;
     
    139135                return -1;
    140136        }
    141        
     137
    142138        DEBUG(4, ("smbc_stat(%s)\n", fname));
    143        
     139
    144140        if (SMBC_parse_path(frame,
    145141                            context,
     
    165161                }
    166162        }
    167        
     163
    168164        srv = SMBC_server(frame, context, True,
    169165                          server, share, &workgroup, &user, &password);
    170        
    171166        if (!srv) {
    172167                TALLOC_FREE(frame);
    173168                return -1;  /* errno set by SMBC_server */
    174169        }
    175        
     170
    176171        if (!SMBC_getatr(context, srv, path, &mode, &size,
    177172                         NULL,
     
    184179                return -1;
    185180        }
    186        
     181
    187182        st->st_ino = ino;
    188        
     183
    189184        setup_stat(context, st, (char *) fname, size, mode);
    190        
     185
    191186        st->st_atime = convert_timespec_to_time_t(access_time_ts);
    192187        st->st_ctime = convert_timespec_to_time_t(change_time_ts);
    193188        st->st_mtime = convert_timespec_to_time_t(write_time_ts);
    194189        st->st_dev   = srv->dev;
    195        
     190
    196191        TALLOC_FREE(frame);
    197192        return 0;
    198        
    199193}
    200194
     
    222216        SMB_INO_T ino = 0;
    223217        TALLOC_CTX *frame = talloc_stackframe();
    224        
     218
    225219        if (!context || !context->internal->initialized) {
    226                
    227220                errno = EINVAL;
    228221                TALLOC_FREE(frame);
    229222                return -1;
    230223        }
    231        
     224
    232225        if (!file || !SMBC_dlist_contains(context->internal->files, file)) {
    233226                errno = EBADF;
     
    235228                return -1;
    236229        }
    237        
     230
    238231        if (!file->file) {
    239232                TALLOC_FREE(frame);
    240233                return smbc_getFunctionFstatdir(context)(context, file, st);
    241234        }
    242        
     235
    243236        /*d_printf(">>>fstat: parsing %s\n", file->fname);*/
    244237        if (SMBC_parse_path(frame,
     
    256249                return -1;
    257250        }
    258        
     251
    259252        /*d_printf(">>>fstat: resolving %s\n", path);*/
    260253        if (!cli_resolve_path(frame, "", context->internal->auth_info,
    261                         file->srv->cli, path,
    262                         &targetcli, &targetpath)) {
     254                              file->srv->cli, path,
     255                              &targetcli, &targetpath)) {
    263256                d_printf("Could not resolve %s\n", path);
    264257                errno = ENOENT;
     
    267260        }
    268261        /*d_printf(">>>fstat: resolved path as %s\n", targetpath);*/
    269        
    270         if (!cli_qfileinfo(targetcli, file->cli_fd, &mode, &size,
    271                            NULL,
    272                            &access_time_ts,
    273                            &write_time_ts,
    274                            &change_time_ts,
    275                            &ino)) {
    276                
     262
     263        if (!NT_STATUS_IS_OK(cli_qfileinfo_basic(
     264                                     targetcli, file->cli_fd, &mode, &size,
     265                                     NULL,
     266                                     &access_time_ts,
     267                                     &write_time_ts,
     268                                     &change_time_ts,
     269                                     &ino))) {
    277270                time_t change_time, access_time, write_time;
    278                
     271
    279272                if (!NT_STATUS_IS_OK(cli_getattrE(targetcli, file->cli_fd, &mode, &size,
    280273                                  &change_time, &access_time, &write_time))) {
    281                        
    282274                        errno = EINVAL;
    283275                        TALLOC_FREE(frame);
    284276                        return -1;
    285277                }
    286                
    287278                change_time_ts = convert_time_t_to_timespec(change_time);
    288279                access_time_ts = convert_time_t_to_timespec(access_time);
    289280                write_time_ts = convert_time_t_to_timespec(write_time);
    290281        }
    291        
     282
    292283        st->st_ino = ino;
    293        
     284
    294285        setup_stat(context, st, file->fname, size, mode);
    295        
     286
    296287        st->st_atime = convert_timespec_to_time_t(access_time_ts);
    297288        st->st_ctime = convert_timespec_to_time_t(change_time_ts);
    298289        st->st_mtime = convert_timespec_to_time_t(write_time_ts);
    299290        st->st_dev = file->srv->dev;
    300        
     291
    301292        TALLOC_FREE(frame);
    302293        return 0;
    303        
    304294}
    305295
     
    369359        uint32 fs_attrs = 0;
    370360        struct cli_state *cli = file->srv->cli;
    371                
    372361
    373362        /* Initialize all fields (at least until we actually use them) */
     
    390379                uint64_t sectors_per_allocation_unit;
    391380                uint64_t bytes_per_sector;
    392                
     381                NTSTATUS status;
     382
    393383                /* Nope. If size data is available... */
    394                 if (cli_get_fs_full_size_info(cli,
    395                                               &total_allocation_units,
    396                                               &caller_allocation_units,
    397                                               &actual_allocation_units,
    398                                               &sectors_per_allocation_unit,
    399                                               &bytes_per_sector)) {
     384                status = cli_get_fs_full_size_info(cli,
     385                                                   &total_allocation_units,
     386                                                   &caller_allocation_units,
     387                                                   &actual_allocation_units,
     388                                                   &sectors_per_allocation_unit,
     389                                                   &bytes_per_sector);
     390                if (NT_STATUS_IS_OK(status)) {
    400391
    401392                        /* ... then provide it */
     
    422413                uint64_t free_file_nodes;
    423414                uint64_t fs_identifier;
     415                NTSTATUS status;
    424416
    425417                /* Has UNIXCIFS. If POSIX filesystem info is available... */
    426                 if (cli_get_posix_fs_info(cli,
    427                                           &optimal_transfer_size,
    428                                           &block_size,
    429                                           &total_blocks,
    430                                           &blocks_available,
    431                                           &user_blocks_available,
    432                                           &total_file_nodes,
    433                                           &free_file_nodes,
    434                                           &fs_identifier)) {
     418                status = cli_get_posix_fs_info(cli,
     419                                               &optimal_transfer_size,
     420                                               &block_size,
     421                                               &total_blocks,
     422                                               &blocks_available,
     423                                               &user_blocks_available,
     424                                               &total_file_nodes,
     425                                               &free_file_nodes,
     426                                               &fs_identifier);
     427                if (NT_STATUS_IS_OK(status)) {
    435428
    436429                        /* ... then what's provided here takes precedence. */
     
    455448
    456449        /* See if the share is case sensitive */
    457         if (!cli_get_fs_attr_info(cli, &fs_attrs)) {
     450        if (!NT_STATUS_IS_OK(cli_get_fs_attr_info(cli, &fs_attrs))) {
    458451                /*
    459452                 * We can't determine the case sensitivity of
Note: See TracChangeset for help on using the changeset viewer.