Changeset 860 for vendor/current/source3/smbd/dir.c
- Timestamp:
- May 12, 2014, 8:58:38 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/smbd/dir.c
r746 r860 50 50 unsigned int name_cache_index; 51 51 unsigned int file_number; 52 files_struct *fsp; /* Back pointer to containing fsp, only 53 set from OpenDir_fsp(). */ 52 54 }; 53 55 … … 591 593 { 592 594 if (fsp->dptr) { 593 /* 594 * Ugly hack. We have defined fdopendir to return ENOSYS if dirfd also isn't 595 * present. I hate Solaris. JRA. 596 */ 597 #ifdef HAVE_DIRFD 598 if (fsp->fh->fd != -1 && 599 fsp->dptr->dir_hnd && 600 dirfd(fsp->dptr->dir_hnd->dir)) { 601 /* The call below closes the underlying fd. */ 602 fsp->fh->fd = -1; 603 } 604 #endif 595 /* 596 * The destructor for the struct smb_Dir 597 * (fsp->dptr->dir_hnd) now handles 598 * all resource deallocation. 599 */ 605 600 dptr_close_internal(fsp->dptr); 606 601 fsp->dptr = NULL; … … 942 937 { 943 938 connection_struct *conn = dirptr->conn; 944 bool needslash; 939 size_t slashlen; 940 size_t pathlen; 945 941 946 942 *_smb_fname = NULL; 947 943 *_mode = 0; 948 944 949 needslash = ( dirptr->path[strlen(dirptr->path) -1] != '/'); 945 pathlen = strlen(dirptr->path); 946 slashlen = ( dirptr->path[pathlen-1] != '/') ? 1 : 0; 950 947 951 948 while (true) { … … 991 988 } 992 989 993 pathreal = talloc_asprintf(ctx, "%s%s%s", 994 dirptr->path, 995 needslash?"/":"", 996 dname); 990 /* 991 * This used to be 992 * pathreal = talloc_asprintf(ctx, "%s%s%s", dirptr->path, 993 * needslash?"/":"", dname); 994 * but this was measurably slower than doing the memcpy. 995 */ 996 997 pathreal = talloc_array( 998 ctx, char, 999 pathlen + slashlen + talloc_get_size(dname)); 997 1000 if (!pathreal) { 998 1001 TALLOC_FREE(dname); … … 1000 1003 return false; 1001 1004 } 1005 1006 memcpy(pathreal, dirptr->path, pathlen); 1007 pathreal[pathlen] = '/'; 1008 memcpy(pathreal + slashlen + pathlen, dname, 1009 talloc_get_size(dname)); 1002 1010 1003 1011 /* Create smb_fname with NULL stream_name. */ … … 1333 1341 static int smb_Dir_destructor(struct smb_Dir *dirp) 1334 1342 { 1335 if (dirp->dir) { 1336 #ifdef HAVE_DIRFD 1337 if (dirp->conn->sconn) { 1338 files_struct *fsp = file_find_fd(dirp->conn->sconn, 1339 dirfd(dirp->dir)); 1340 if (fsp) { 1341 /* The call below closes the underlying fd. */ 1342 fsp->fh->fd = -1; 1343 if (dirp->dir != NULL) { 1344 SMB_VFS_CLOSEDIR(dirp->conn,dirp->dir); 1345 if (dirp->fsp != NULL) { 1346 /* 1347 * The SMB_VFS_CLOSEDIR above 1348 * closes the underlying fd inside 1349 * dirp->fsp. 1350 */ 1351 dirp->fsp->fh->fd = -1; 1352 if (dirp->fsp->dptr != NULL) { 1353 SMB_ASSERT(dirp->fsp->dptr->dir_hnd == dirp); 1354 dirp->fsp->dptr->dir_hnd = NULL; 1343 1355 } 1344 } 1345 #endif 1346 SMB_VFS_CLOSEDIR(dirp->conn,dirp->dir); 1356 dirp->fsp = NULL; 1357 } 1347 1358 } 1348 1359 if (dirp->conn->sconn && !dirp->conn->sconn->using_smb2) { … … 1428 1439 if (fsp->is_directory && fsp->fh->fd != -1) { 1429 1440 dirp->dir = SMB_VFS_FDOPENDIR(fsp, mask, attr); 1430 if (dirp->dir == NULL) { 1441 if (dirp->dir != NULL) { 1442 dirp->fsp = fsp; 1443 } else { 1431 1444 DEBUG(10,("OpenDir_fsp: SMB_VFS_FDOPENDIR on %s returned " 1432 1445 "NULL (%s)\n", … … 1644 1657 *****************************************************************/ 1645 1658 1646 NTSTATUS can_delete_directory(struct connection_struct *conn, 1647 const char *dirname) 1659 NTSTATUS can_delete_directory_fsp(files_struct *fsp) 1648 1660 { 1649 1661 NTSTATUS status = NT_STATUS_OK; … … 1652 1664 char *talloced = NULL; 1653 1665 SMB_STRUCT_STAT st; 1654 struct smb_Dir *dir_hnd = OpenDir(talloc_tos(), conn, 1655 dirname, NULL, 0); 1666 struct connection_struct *conn = fsp->conn; 1667 struct smb_Dir *dir_hnd = OpenDir_fsp(talloc_tos(), 1668 conn, 1669 fsp, 1670 NULL, 1671 0); 1656 1672 1657 1673 if (!dir_hnd) { … … 1668 1684 } 1669 1685 1670 if (!is_visible_file(conn, dirname, dname, &st, True)) {1686 if (!is_visible_file(conn, fsp->fsp_name->base_name, dname, &st, True)) { 1671 1687 TALLOC_FREE(talloced); 1672 1688 continue; 1673 1689 } 1674 1690 1675 DEBUG(10,("can_delete_directory : got name %s - can't delete\n",1691 DEBUG(10,("can_delete_directory_fsp: got name %s - can't delete\n", 1676 1692 dname )); 1677 1693 status = NT_STATUS_DIRECTORY_NOT_EMPTY;
Note:
See TracChangeset
for help on using the changeset viewer.