static unsigned long get_gen_count | ( | void | ) | [static] |
参照元 file_new().
00050 { 00051 static unsigned long file_gen_counter; 00052 00053 if ((++file_gen_counter) == 0) 00054 return ++file_gen_counter; 00055 return file_gen_counter; 00056 }
NTSTATUS file_new | ( | connection_struct * | conn, | |
files_struct ** | result | |||
) |
参照先 bitmap_find()・bitmap_set()・chain_fsp・files_struct::conn・fd_handle::fd・files_struct::fh・file_bmap・fd_handle::file_id・Files・files_used・files_struct::fnum・fsp_singleton_cache::fsp・fsp_fi_cache・files_struct::fsp_name・get_gen_count()・GetTimeOfDay()・files_struct::open_time・real_max_open_files・fd_handle::ref_count・result・string_set()・sys_getpid().
参照元 dup_file_fsp()・open_directory()・open_fake_file()・open_file_fchmod()・open_file_ntcreate()・open_file_stat()・print_fsp_open().
00063 { 00064 int i; 00065 static int first_file; 00066 files_struct *fsp; 00067 00068 /* we want to give out file handles differently on each new 00069 connection because of a common bug in MS clients where they try to 00070 reuse a file descriptor from an earlier smb connection. This code 00071 increases the chance that the errant client will get an error rather 00072 than causing corruption */ 00073 if (first_file == 0) { 00074 first_file = (sys_getpid() ^ (int)time(NULL)) % real_max_open_files; 00075 } 00076 00077 /* TODO: Port the id-tree implementation from Samba4 */ 00078 00079 i = bitmap_find(file_bmap, first_file); 00080 if (i == -1) { 00081 DEBUG(0,("ERROR! Out of file structures\n")); 00082 /* TODO: We have to unconditionally return a DOS error here, 00083 * W2k3 even returns ERRDOS/ERRnofids for ntcreate&x with 00084 * NTSTATUS negotiated */ 00085 return NT_STATUS_TOO_MANY_OPENED_FILES; 00086 } 00087 00088 fsp = SMB_MALLOC_P(files_struct); 00089 if (!fsp) { 00090 return NT_STATUS_NO_MEMORY; 00091 } 00092 00093 ZERO_STRUCTP(fsp); 00094 00095 fsp->fh = SMB_MALLOC_P(struct fd_handle); 00096 if (!fsp->fh) { 00097 SAFE_FREE(fsp); 00098 return NT_STATUS_NO_MEMORY; 00099 } 00100 00101 ZERO_STRUCTP(fsp->fh); 00102 00103 fsp->fh->ref_count = 1; 00104 fsp->fh->fd = -1; 00105 00106 fsp->conn = conn; 00107 fsp->fh->file_id = get_gen_count(); 00108 GetTimeOfDay(&fsp->open_time); 00109 00110 first_file = (i+1) % real_max_open_files; 00111 00112 bitmap_set(file_bmap, i); 00113 files_used++; 00114 00115 fsp->fnum = i + FILE_HANDLE_OFFSET; 00116 SMB_ASSERT(fsp->fnum < 65536); 00117 00118 string_set(&fsp->fsp_name,""); 00119 00120 DLIST_ADD(Files, fsp); 00121 00122 DEBUG(5,("allocated file structure %d, fnum = %d (%d used)\n", 00123 i, fsp->fnum, files_used)); 00124 00125 chain_fsp = fsp; 00126 00127 /* A new fsp invalidates a negative fsp_fi_cache. */ 00128 if (fsp_fi_cache.fsp == NULL) { 00129 ZERO_STRUCT(fsp_fi_cache); 00130 } 00131 00132 *result = fsp; 00133 return NT_STATUS_OK; 00134 }
void file_close_conn | ( | connection_struct * | conn | ) |
参照先 close_file()・files_struct::conn・Files・files_struct::next・SHUTDOWN_CLOSE.
参照元 close_cnum().
00141 { 00142 files_struct *fsp, *next; 00143 00144 for (fsp=Files;fsp;fsp=next) { 00145 next = fsp->next; 00146 if (fsp->conn == conn) { 00147 close_file(fsp,SHUTDOWN_CLOSE); 00148 } 00149 } 00150 }
void file_close_pid | ( | uint16 | smbpid, | |
int | vuid | |||
) |
参照先 close_file()・files_struct::file_pid・Files・files_struct::next・SHUTDOWN_CLOSE・files_struct::vuid.
参照元 reply_exit().
00157 { 00158 files_struct *fsp, *next; 00159 00160 for (fsp=Files;fsp;fsp=next) { 00161 next = fsp->next; 00162 if ((fsp->file_pid == smbpid) && (fsp->vuid == vuid)) { 00163 close_file(fsp,SHUTDOWN_CLOSE); 00164 } 00165 } 00166 }
void file_init | ( | void | ) |
参照先 bitmap_allocate()・exit_server()・file_bmap・real_max_open_files・set_maxfiles()・set_pipe_handle_offset().
参照元 init_structs().
00175 { 00176 int request_max_open_files = lp_max_open_files(); 00177 int real_lim; 00178 00179 /* 00180 * Set the max_open files to be the requested 00181 * max plus a fudgefactor to allow for the extra 00182 * fd's we need such as log files etc... 00183 */ 00184 real_lim = set_maxfiles(request_max_open_files + MAX_OPEN_FUDGEFACTOR); 00185 00186 real_max_open_files = real_lim - MAX_OPEN_FUDGEFACTOR; 00187 00188 if (real_max_open_files + FILE_HANDLE_OFFSET + MAX_OPEN_PIPES > 65536) 00189 real_max_open_files = 65536 - FILE_HANDLE_OFFSET - MAX_OPEN_PIPES; 00190 00191 if(real_max_open_files != request_max_open_files) { 00192 DEBUG(1,("file_init: Information only: requested %d \ 00193 open files, %d are available.\n", request_max_open_files, real_max_open_files)); 00194 } 00195 00196 SMB_ASSERT(real_max_open_files > 100); 00197 00198 file_bmap = bitmap_allocate(real_max_open_files); 00199 00200 if (!file_bmap) { 00201 exit_server("out of memory in file_init"); 00202 } 00203 00204 /* 00205 * Ensure that pipe_handle_oppset is set correctly. 00206 */ 00207 set_pipe_handle_offset(real_max_open_files); 00208 }
void file_close_user | ( | int | vuid | ) |
参照先 close_file()・Files・files_struct::next・SHUTDOWN_CLOSE・files_struct::vuid.
参照元 reply_ulogoffX().
00215 { 00216 files_struct *fsp, *next; 00217 00218 for (fsp=Files;fsp;fsp=next) { 00219 next=fsp->next; 00220 if (fsp->vuid == vuid) { 00221 close_file(fsp,SHUTDOWN_CLOSE); 00222 } 00223 } 00224 }
void file_dump_open_table | ( | void | ) |
参照先 files_struct::dev・fd_handle::fd・files_struct::fh・fd_handle::file_id・Files・files_struct::fnum・files_struct::fsp_name・files_struct::inode・files_struct::next.
00231 { 00232 int count=0; 00233 files_struct *fsp; 00234 00235 for (fsp=Files;fsp;fsp=fsp->next,count++) { 00236 DEBUG(10,("Files[%d], fnum = %d, name %s, fd = %d, fileid = %lu, dev = %x, inode = %.0f\n", 00237 count, fsp->fnum, fsp->fsp_name, fsp->fh->fd, (unsigned long)fsp->fh->file_id, 00238 (unsigned int)fsp->dev, (double)fsp->inode )); 00239 } 00240 }
files_struct* file_find_fd | ( | int | fd | ) |
参照先 fd_handle::fd・files_struct::fh・Files・files_struct::next.
参照元 hpuxacl_sys_acl_get_fd()・hpuxacl_sys_acl_set_fd()・linux_oplock_receive_message().
00247 { 00248 int count=0; 00249 files_struct *fsp; 00250 00251 for (fsp=Files;fsp;fsp=fsp->next,count++) { 00252 if (fsp->fh->fd == fd) { 00253 if (count > 10) { 00254 DLIST_PROMOTE(Files, fsp); 00255 } 00256 return fsp; 00257 } 00258 } 00259 00260 return NULL; 00261 }
files_struct* file_find_dif | ( | SMB_DEV_T | dev, | |
SMB_INO_T | inode, | |||
unsigned long | file_id | |||
) |
参照先 files_struct::dev・fd_handle::fd・files_struct::fh・fd_handle::file_id・Files・files_struct::fsp_name・files_struct::inode・files_struct::next・files_struct::oplock_type・smb_panic().
参照元 initial_break_processing()・validate_my_share_entries().
00268 { 00269 int count=0; 00270 files_struct *fsp; 00271 00272 for (fsp=Files;fsp;fsp=fsp->next,count++) { 00273 /* We can have a fsp->fh->fd == -1 here as it could be a stat open. */ 00274 if (fsp->dev == dev && 00275 fsp->inode == inode && 00276 fsp->fh->file_id == file_id ) { 00277 if (count > 10) { 00278 DLIST_PROMOTE(Files, fsp); 00279 } 00280 /* Paranoia check. */ 00281 if ((fsp->fh->fd == -1) && 00282 (fsp->oplock_type != NO_OPLOCK) && 00283 (fsp->oplock_type != FAKE_LEVEL_II_OPLOCK)) { 00284 DEBUG(0,("file_find_dif: file %s dev = %x, inode = %.0f, file_id = %u \ 00285 oplock_type = %u is a stat open with oplock type !\n", fsp->fsp_name, (unsigned int)fsp->dev, 00286 (double)fsp->inode, (unsigned int)fsp->fh->file_id, 00287 (unsigned int)fsp->oplock_type )); 00288 smb_panic("file_find_dif\n"); 00289 } 00290 return fsp; 00291 } 00292 } 00293 00294 return NULL; 00295 }
files_struct* file_find_fsp | ( | files_struct * | orig_fsp | ) |
参照先 Files・files_struct::next.
00302 { 00303 files_struct *fsp; 00304 00305 for (fsp=Files;fsp;fsp=fsp->next) { 00306 if (fsp == orig_fsp) 00307 return fsp; 00308 } 00309 00310 return NULL; 00311 }
files_struct* file_find_di_first | ( | SMB_DEV_T | dev, | |
SMB_INO_T | inode | |||
) |
参照先 files_struct::dev・fsp_singleton_cache::dev・fd_handle::fd・files_struct::fh・Files・fsp_singleton_cache::fsp・fsp_fi_cache・files_struct::inode・fsp_singleton_cache::inode・files_struct::next.
参照元 call_trans2qfilepathinfo()・fcb_or_dos_open()・irix_oplock_receive_message()・msg_file_was_renamed()・rename_open_files().
00320 { 00321 files_struct *fsp; 00322 00323 if (fsp_fi_cache.dev == dev && fsp_fi_cache.inode == inode) { 00324 /* Positive or negative cache hit. */ 00325 return fsp_fi_cache.fsp; 00326 } 00327 00328 fsp_fi_cache.dev = dev; 00329 fsp_fi_cache.inode = inode; 00330 00331 for (fsp=Files;fsp;fsp=fsp->next) { 00332 if ( fsp->fh->fd != -1 && 00333 fsp->dev == dev && 00334 fsp->inode == inode ) { 00335 /* Setup positive cache. */ 00336 fsp_fi_cache.fsp = fsp; 00337 return fsp; 00338 } 00339 } 00340 00341 /* Setup negative cache. */ 00342 fsp_fi_cache.fsp = NULL; 00343 return NULL; 00344 }
files_struct* file_find_di_next | ( | files_struct * | start_fsp | ) |
参照先 files_struct::dev・fd_handle::fd・files_struct::fh・files_struct::inode・files_struct::next.
参照元 fcb_or_dos_open()・msg_file_was_renamed()・rename_open_files().
00351 { 00352 files_struct *fsp; 00353 00354 for (fsp = start_fsp->next;fsp;fsp=fsp->next) { 00355 if ( fsp->fh->fd != -1 && 00356 fsp->dev == start_fsp->dev && 00357 fsp->inode == start_fsp->inode ) 00358 return fsp; 00359 } 00360 00361 return NULL; 00362 }
files_struct* file_find_print | ( | void | ) |
参照先 Files・files_struct::next・files_struct::print_file.
00369 { 00370 files_struct *fsp; 00371 00372 for (fsp=Files;fsp;fsp=fsp->next) { 00373 if (fsp->print_file) { 00374 return fsp; 00375 } 00376 } 00377 00378 return NULL; 00379 }
void fsp_set_pending_modtime | ( | files_struct * | tfsp, | |
const struct timespec | mod | |||
) |
参照先 files_struct::dev・fd_handle::fd・files_struct::fh・Files・files_struct::inode・files_struct::next・null_timespec()・files_struct::pending_modtime・files_struct::pending_modtime_owner.
参照元 copy_file()・copy_internals()・reply_close()・smb_set_file_allocation_info()・smb_set_file_time().
00387 { 00388 files_struct *fsp; 00389 00390 if (null_timespec(mod)) { 00391 return; 00392 } 00393 00394 for (fsp = Files;fsp;fsp=fsp->next) { 00395 if ( fsp->fh->fd != -1 && 00396 fsp->dev == tfsp->dev && 00397 fsp->inode == tfsp->inode ) { 00398 fsp->pending_modtime = mod; 00399 fsp->pending_modtime_owner = False; 00400 } 00401 } 00402 00403 tfsp->pending_modtime_owner = True; 00404 }
void file_sync_all | ( | connection_struct * | conn | ) |
参照先 files_struct::conn・fd_handle::fd・files_struct::fh・Files・files_struct::next・sync_file().
参照元 reply_flush().
00411 { 00412 files_struct *fsp, *next; 00413 00414 for (fsp=Files;fsp;fsp=next) { 00415 next=fsp->next; 00416 if ((conn == fsp->conn) && (fsp->fh->fd != -1)) { 00417 sync_file(conn, fsp, True /* write through */); 00418 } 00419 } 00420 }
void file_free | ( | files_struct * | fsp | ) |
参照先 bitmap_clear()・chain_fsp・files_struct::conn・destroy_fake_file_handle()・files_struct::fake_file_handle・files_struct::fh・file_bmap・Files・files_used・files_struct::fnum・fsp_singleton_cache::fsp・fsp_fi_cache・files_struct::fsp_name・files_struct::notify・connection_struct::notify_ctx・notify_remove()・files_struct::oplock_timeout・fd_handle::ref_count・string_free().
参照元 close_fake_file()・close_file_fchmod()・close_normal_file()・close_stat()・open_directory()・open_fake_file()・open_file_fchmod()・open_file_ntcreate()・print_fsp_open().
00427 { 00428 DLIST_REMOVE(Files, fsp); 00429 00430 string_free(&fsp->fsp_name); 00431 00432 if (fsp->fake_file_handle) { 00433 destroy_fake_file_handle(&fsp->fake_file_handle); 00434 } 00435 00436 if (fsp->fh->ref_count == 1) { 00437 SAFE_FREE(fsp->fh); 00438 } else { 00439 fsp->fh->ref_count--; 00440 } 00441 00442 if (fsp->notify) { 00443 notify_remove(fsp->conn->notify_ctx, fsp); 00444 TALLOC_FREE(fsp->notify); 00445 } 00446 00447 /* Ensure this event will never fire. */ 00448 TALLOC_FREE(fsp->oplock_timeout); 00449 00450 bitmap_clear(file_bmap, fsp->fnum - FILE_HANDLE_OFFSET); 00451 files_used--; 00452 00453 DEBUG(5,("freed files structure %d (%d used)\n", 00454 fsp->fnum, files_used)); 00455 00456 /* this is paranoia, just in case someone tries to reuse the 00457 information */ 00458 ZERO_STRUCTP(fsp); 00459 00460 if (fsp == chain_fsp) { 00461 chain_fsp = NULL; 00462 } 00463 00464 /* Closing a file can invalidate the positive cache. */ 00465 if (fsp == fsp_fi_cache.fsp) { 00466 ZERO_STRUCT(fsp_fi_cache); 00467 } 00468 00469 SAFE_FREE(fsp); 00470 }
files_struct* file_fnum | ( | uint16 | fnum | ) |
参照先 Files・files_struct::fnum・files_struct::next.
参照元 file_fsp().
00477 { 00478 files_struct *fsp; 00479 int count=0; 00480 00481 for (fsp=Files;fsp;fsp=fsp->next, count++) { 00482 if (fsp->fnum == fnum) { 00483 if (count > 10) { 00484 DLIST_PROMOTE(Files, fsp); 00485 } 00486 return fsp; 00487 } 00488 } 00489 return NULL; 00490 }
files_struct* file_fsp | ( | char * | buf, | |
int | where | |||
) |
参照先 chain_fsp・file_fnum().
参照元 call_nt_transact_create()・call_nt_transact_get_user_quota()・call_nt_transact_ioctl()・call_nt_transact_notify_change()・call_nt_transact_query_security_desc()・call_nt_transact_rename()・call_nt_transact_set_security_desc()・call_nt_transact_set_user_quota()・call_trans2ioctl()・call_trans2qfilepathinfo()・call_trans2setfilepathinfo()・call_trans2setfsinfo()・reply_close()・reply_flush()・reply_getattrE()・reply_ioctl()・reply_lock()・reply_lockingX()・reply_lockread()・reply_lseek()・reply_ntcreate_and_X()・reply_printclose()・reply_printwrite()・reply_read()・reply_read_and_X()・reply_readbmpx()・reply_readbraw()・reply_setattrE()・reply_unlock()・reply_write()・reply_write_and_X()・reply_writebmpx()・reply_writebraw()・reply_writebs()・reply_writeclose()・reply_writeunlock().
00497 { 00498 files_struct *fsp; 00499 00500 if (chain_fsp) { 00501 return chain_fsp; 00502 } 00503 00504 if (!buf) { 00505 return NULL; 00506 } 00507 00508 fsp = file_fnum(SVAL(buf, where)); 00509 if (fsp) { 00510 chain_fsp = fsp; 00511 } 00512 return fsp; 00513 }
void file_chain_reset | ( | void | ) |
参照先 chain_fsp.
参照元 construct_reply()・process_blocking_lock_queue().
00520 { 00521 chain_fsp = NULL; 00522 }
NTSTATUS dup_file_fsp | ( | files_struct * | fsp, | |
uint32 | access_mask, | |||
uint32 | share_access, | |||
uint32 | create_options, | |||
files_struct ** | result | |||
) |
参照先 files_struct::access_mask・files_struct::aio_write_behind・files_struct::can_lock・files_struct::can_read・files_struct::can_write・files_struct::conn・files_struct::dev・files_struct::fh・file_new()・files_struct::file_pid・files_struct::fsp_name・files_struct::initial_allocation_size・files_struct::inode・files_struct::is_directory・files_struct::is_stat・files_struct::last_write_time・files_struct::mode・files_struct::modified・files_struct::open_time・files_struct::oplock_type・files_struct::pending_modtime・files_struct::pending_modtime_owner・files_struct::print_file・fd_handle::ref_count・result・files_struct::share_access・status・string_set()・files_struct::vuid.
参照元 fcb_or_dos_open().
00533 { 00534 NTSTATUS status; 00535 files_struct *dup_fsp; 00536 00537 status = file_new(fsp->conn, &dup_fsp); 00538 00539 if (!NT_STATUS_IS_OK(status)) { 00540 return status; 00541 } 00542 00543 SAFE_FREE(dup_fsp->fh); 00544 00545 dup_fsp->fh = fsp->fh; 00546 dup_fsp->fh->ref_count++; 00547 00548 dup_fsp->dev = fsp->dev; 00549 dup_fsp->inode = fsp->inode; 00550 dup_fsp->initial_allocation_size = fsp->initial_allocation_size; 00551 dup_fsp->mode = fsp->mode; 00552 dup_fsp->file_pid = fsp->file_pid; 00553 dup_fsp->vuid = fsp->vuid; 00554 dup_fsp->open_time = fsp->open_time; 00555 dup_fsp->access_mask = access_mask; 00556 dup_fsp->share_access = share_access; 00557 dup_fsp->pending_modtime_owner = fsp->pending_modtime_owner; 00558 dup_fsp->pending_modtime = fsp->pending_modtime; 00559 dup_fsp->last_write_time = fsp->last_write_time; 00560 dup_fsp->oplock_type = fsp->oplock_type; 00561 dup_fsp->can_lock = fsp->can_lock; 00562 dup_fsp->can_read = (access_mask & (FILE_READ_DATA)) ? True : False; 00563 if (!CAN_WRITE(fsp->conn)) { 00564 dup_fsp->can_write = False; 00565 } else { 00566 dup_fsp->can_write = (access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ? True : False; 00567 } 00568 dup_fsp->print_file = fsp->print_file; 00569 dup_fsp->modified = fsp->modified; 00570 dup_fsp->is_directory = fsp->is_directory; 00571 dup_fsp->is_stat = fsp->is_stat; 00572 dup_fsp->aio_write_behind = fsp->aio_write_behind; 00573 string_set(&dup_fsp->fsp_name,fsp->fsp_name); 00574 00575 *result = dup_fsp; 00576 return NT_STATUS_OK; 00577 }
int real_max_open_files [static] |
files_struct* Files [static] |
files_struct* chain_fsp = NULL [static] |
int files_used [static] |
struct fsp_singleton_cache fsp_fi_cache [static] |