Changeset 745 for trunk/server/source3/libsmb/libsmb_stat.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/libsmb/libsmb_stat.c
r414 r745 8 8 Copyright (C) Derrell Lipman 2003-2008 9 9 Copyright (C) Jeremy Allison 2007, 2008 10 10 11 11 This program is free software; you can redistribute it and/or modify 12 12 it under the terms of the GNU General Public License as published by 13 13 the Free Software Foundation; either version 3 of the License, or 14 14 (at your option) any later version. 15 15 16 16 This program is distributed in the hope that it will be useful, 17 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 19 GNU General Public License for more details. 20 20 21 21 You should have received a copy of the GNU General Public License 22 22 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 24 24 25 25 #include "includes.h" 26 #include "libsmb/libsmb.h" 26 27 #include "libsmbclient.h" 27 28 #include "libsmb_internal.h" … … 37 38 { 38 39 if (!context || !context->internal->initialized) { 39 40 40 errno = EINVAL; 41 41 return -1; 42 43 } 44 42 } 43 45 44 if (!*name) return 2; /* FIXME, why 2 ??? */ 46 45 return (ino_t)str_checksum(name); 47 48 46 } 49 47 … … 61 59 { 62 60 TALLOC_CTX *frame = talloc_stackframe(); 63 61 64 62 st->st_mode = 0; 65 63 66 64 if (IS_DOS_DIR(mode)) { 67 65 st->st_mode = SMBC_DIR_MODE; … … 69 67 st->st_mode = SMBC_FILE_MODE; 70 68 } 71 69 72 70 if (IS_DOS_ARCHIVE(mode)) st->st_mode |= S_IXUSR; 73 71 if (IS_DOS_SYSTEM(mode)) st->st_mode |= S_IXGRP; 74 72 if (IS_DOS_HIDDEN(mode)) st->st_mode |= S_IXOTH; 75 73 if (!IS_DOS_READONLY(mode)) st->st_mode |= S_IWUSR; 76 74 77 75 st->st_size = size; 78 76 #ifdef HAVE_STAT_ST_BLKSIZE … … 87 85 st->st_uid = getuid(); 88 86 st->st_gid = getgid(); 89 87 90 88 if (IS_DOS_DIR(mode)) { 91 89 st->st_nlink = 2; … … 93 91 st->st_nlink = 1; 94 92 } 95 93 96 94 if (st->st_ino == 0) { 97 95 st->st_ino = generate_inode(context, fname); 98 96 } 99 97 100 98 TALLOC_FREE(frame); 101 99 return True; /* FIXME: Is this needed ? */ 102 103 100 } 104 101 … … 126 123 SMB_INO_T ino = 0; 127 124 TALLOC_CTX *frame = talloc_stackframe(); 128 125 129 126 if (!context || !context->internal->initialized) { 130 131 127 errno = EINVAL; /* Best I can think of ... */ 132 128 TALLOC_FREE(frame); 133 129 return -1; 134 130 } 135 131 136 132 if (!fname) { 137 133 errno = EINVAL; … … 139 135 return -1; 140 136 } 141 137 142 138 DEBUG(4, ("smbc_stat(%s)\n", fname)); 143 139 144 140 if (SMBC_parse_path(frame, 145 141 context, … … 165 161 } 166 162 } 167 163 168 164 srv = SMBC_server(frame, context, True, 169 165 server, share, &workgroup, &user, &password); 170 171 166 if (!srv) { 172 167 TALLOC_FREE(frame); 173 168 return -1; /* errno set by SMBC_server */ 174 169 } 175 170 176 171 if (!SMBC_getatr(context, srv, path, &mode, &size, 177 172 NULL, … … 184 179 return -1; 185 180 } 186 181 187 182 st->st_ino = ino; 188 183 189 184 setup_stat(context, st, (char *) fname, size, mode); 190 185 191 186 st->st_atime = convert_timespec_to_time_t(access_time_ts); 192 187 st->st_ctime = convert_timespec_to_time_t(change_time_ts); 193 188 st->st_mtime = convert_timespec_to_time_t(write_time_ts); 194 189 st->st_dev = srv->dev; 195 190 196 191 TALLOC_FREE(frame); 197 192 return 0; 198 199 193 } 200 194 … … 222 216 SMB_INO_T ino = 0; 223 217 TALLOC_CTX *frame = talloc_stackframe(); 224 218 225 219 if (!context || !context->internal->initialized) { 226 227 220 errno = EINVAL; 228 221 TALLOC_FREE(frame); 229 222 return -1; 230 223 } 231 224 232 225 if (!file || !SMBC_dlist_contains(context->internal->files, file)) { 233 226 errno = EBADF; … … 235 228 return -1; 236 229 } 237 230 238 231 if (!file->file) { 239 232 TALLOC_FREE(frame); 240 233 return smbc_getFunctionFstatdir(context)(context, file, st); 241 234 } 242 235 243 236 /*d_printf(">>>fstat: parsing %s\n", file->fname);*/ 244 237 if (SMBC_parse_path(frame, … … 256 249 return -1; 257 250 } 258 251 259 252 /*d_printf(">>>fstat: resolving %s\n", path);*/ 260 253 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)) { 263 256 d_printf("Could not resolve %s\n", path); 264 257 errno = ENOENT; … … 267 260 } 268 261 /*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))) { 277 270 time_t change_time, access_time, write_time; 278 271 279 272 if (!NT_STATUS_IS_OK(cli_getattrE(targetcli, file->cli_fd, &mode, &size, 280 273 &change_time, &access_time, &write_time))) { 281 282 274 errno = EINVAL; 283 275 TALLOC_FREE(frame); 284 276 return -1; 285 277 } 286 287 278 change_time_ts = convert_time_t_to_timespec(change_time); 288 279 access_time_ts = convert_time_t_to_timespec(access_time); 289 280 write_time_ts = convert_time_t_to_timespec(write_time); 290 281 } 291 282 292 283 st->st_ino = ino; 293 284 294 285 setup_stat(context, st, file->fname, size, mode); 295 286 296 287 st->st_atime = convert_timespec_to_time_t(access_time_ts); 297 288 st->st_ctime = convert_timespec_to_time_t(change_time_ts); 298 289 st->st_mtime = convert_timespec_to_time_t(write_time_ts); 299 290 st->st_dev = file->srv->dev; 300 291 301 292 TALLOC_FREE(frame); 302 293 return 0; 303 304 294 } 305 295 … … 369 359 uint32 fs_attrs = 0; 370 360 struct cli_state *cli = file->srv->cli; 371 372 361 373 362 /* Initialize all fields (at least until we actually use them) */ … … 390 379 uint64_t sectors_per_allocation_unit; 391 380 uint64_t bytes_per_sector; 392 381 NTSTATUS status; 382 393 383 /* 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 §ors_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 §ors_per_allocation_unit, 389 &bytes_per_sector); 390 if (NT_STATUS_IS_OK(status)) { 400 391 401 392 /* ... then provide it */ … … 422 413 uint64_t free_file_nodes; 423 414 uint64_t fs_identifier; 415 NTSTATUS status; 424 416 425 417 /* 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)) { 435 428 436 429 /* ... then what's provided here takes precedence. */ … … 455 448 456 449 /* 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))) { 458 451 /* 459 452 * We can't determine the case sensitivity of
Note:
See TracChangeset
for help on using the changeset viewer.