s3: Move "Files" to smbd_server_connection
authorVolker Lendecke <vl@samba.org>
Mon, 27 Sep 2010 00:29:36 +0000 (02:29 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 28 Sep 2010 05:36:15 +0000 (07:36 +0200)
source3/smbd/files.c
source3/smbd/globals.c
source3/smbd/globals.h

index d1b5fb1146febd4e901df0d80f4b967db1d70cbb..1715190cc325a5eb3604c66989e0b0f7b7de46d2 100644 (file)
@@ -113,7 +113,7 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
                TALLOC_FREE(fsp->fh);
        }
 
-       DLIST_ADD(Files, fsp);
+       DLIST_ADD(smbd_server_conn->files, fsp);
 
        DEBUG(5,("allocated file structure %d, fnum = %d (%d used)\n",
                 i, fsp->fnum, files_used));
@@ -143,7 +143,7 @@ void file_close_conn(connection_struct *conn)
 {
        files_struct *fsp, *next;
 
-       for (fsp=Files;fsp;fsp=next) {
+       for (fsp=smbd_server_conn->files;fsp;fsp=next) {
                next = fsp->next;
                if (fsp->conn == conn) {
                        close_file(NULL, fsp, SHUTDOWN_CLOSE);
@@ -159,7 +159,7 @@ void file_close_pid(uint16 smbpid, int vuid)
 {
        files_struct *fsp, *next;
 
-       for (fsp=Files;fsp;fsp=next) {
+       for (fsp=smbd_server_conn->files;fsp;fsp=next) {
                next = fsp->next;
                if ((fsp->file_pid == smbpid) && (fsp->vuid == vuid)) {
                        close_file(NULL, fsp, SHUTDOWN_CLOSE);
@@ -212,7 +212,7 @@ void file_close_user(int vuid)
 {
        files_struct *fsp, *next;
 
-       for (fsp=Files;fsp;fsp=next) {
+       for (fsp=smbd_server_conn->files;fsp;fsp=next) {
                next=fsp->next;
                if (fsp->vuid == vuid) {
                        close_file(NULL, fsp, SHUTDOWN_CLOSE);
@@ -231,7 +231,7 @@ struct files_struct *files_forall(
 {
        struct files_struct *fsp, *next;
 
-       for (fsp = Files; fsp; fsp = next) {
+       for (fsp = smbd_server_conn->files; fsp; fsp = next) {
                struct files_struct *ret;
                next = fsp->next;
                ret = fn(fsp, private_data);
@@ -251,10 +251,10 @@ files_struct *file_find_fd(int fd)
        int count=0;
        files_struct *fsp;
 
-       for (fsp=Files;fsp;fsp=fsp->next,count++) {
+       for (fsp=smbd_server_conn->files;fsp;fsp=fsp->next,count++) {
                if (fsp->fh->fd == fd) {
                        if (count > 10) {
-                               DLIST_PROMOTE(Files, fsp);
+                               DLIST_PROMOTE(smbd_server_conn->files, fsp);
                        }
                        return fsp;
                }
@@ -272,12 +272,12 @@ files_struct *file_find_dif(struct file_id id, unsigned long gen_id)
        int count=0;
        files_struct *fsp;
 
-       for (fsp=Files;fsp;fsp=fsp->next,count++) {
+       for (fsp=smbd_server_conn->files;fsp;fsp=fsp->next,count++) {
                /* We can have a fsp->fh->fd == -1 here as it could be a stat open. */
                if (file_id_equal(&fsp->file_id, &id) &&
                    fsp->fh->gen_id == gen_id ) {
                        if (count > 10) {
-                               DLIST_PROMOTE(Files, fsp);
+                               DLIST_PROMOTE(smbd_server_conn->files, fsp);
                        }
                        /* Paranoia check. */
                        if ((fsp->fh->fd == -1) &&
@@ -316,7 +316,7 @@ files_struct *file_find_di_first(struct file_id id)
 
        fsp_fi_cache.id = id;
 
-       for (fsp=Files;fsp;fsp=fsp->next) {
+       for (fsp=smbd_server_conn->files;fsp;fsp=fsp->next) {
                if (file_id_equal(&fsp->file_id, &id)) {
                        /* Setup positive cache. */
                        fsp_fi_cache.fsp = fsp;
@@ -366,7 +366,7 @@ bool file_find_subpath(files_struct *dir_fsp)
 
        dlen = strlen(d_fullname);
 
-       for (fsp=Files;fsp;fsp=fsp->next) {
+       for (fsp=smbd_server_conn->files;fsp;fsp=fsp->next) {
                char *d1_fullname;
 
                if (fsp == dir_fsp) {
@@ -403,7 +403,7 @@ void file_sync_all(connection_struct *conn)
 {
        files_struct *fsp, *next;
 
-       for (fsp=Files;fsp;fsp=next) {
+       for (fsp=smbd_server_conn->files;fsp;fsp=next) {
                next=fsp->next;
                if ((conn == fsp->conn) && (fsp->fh->fd != -1)) {
                        sync_file(conn, fsp, True /* write through */);
@@ -417,7 +417,7 @@ void file_sync_all(connection_struct *conn)
 
 void file_free(struct smb_request *req, files_struct *fsp)
 {
-       DLIST_REMOVE(Files, fsp);
+       DLIST_REMOVE(smbd_server_conn->files, fsp);
 
        TALLOC_FREE(fsp->fake_file_handle);
 
@@ -489,10 +489,10 @@ static struct files_struct *file_fnum(uint16 fnum)
        files_struct *fsp;
        int count=0;
 
-       for (fsp=Files;fsp;fsp=fsp->next, count++) {
+       for (fsp=smbd_server_conn->files;fsp;fsp=fsp->next, count++) {
                if (fsp->fnum == fnum) {
                        if (count > 10) {
-                               DLIST_PROMOTE(Files, fsp);
+                               DLIST_PROMOTE(smbd_server_conn->files, fsp);
                        }
                        return fsp;
                }
index 340789ba8e18060573775c9fde05e45233845559..155629fa9694893bacdd9807c69d8d9b4ef06875 100644 (file)
@@ -40,7 +40,6 @@ unsigned int allocated_write_caches = 0;
 
 int real_max_open_files = 0;
 struct bitmap *file_bmap = NULL;
-files_struct *Files = NULL;
 int files_used = 0;
 struct fsp_singleton_cache fsp_fi_cache = {
        .fsp = NULL,
index f4fb4f0b404f748a2f09d328bab11523b47db872..46c08222dacd55a5a3a651a319d93b709c75c5d1 100644 (file)
@@ -38,7 +38,6 @@ extern unsigned int allocated_write_caches;
 
 extern int real_max_open_files;
 extern struct bitmap *file_bmap;
-extern files_struct *Files;
 extern int files_used;
 /* A singleton cache to speed up searching by dev/inode. */
 struct fsp_singleton_cache {
@@ -463,6 +462,7 @@ struct smbd_server_connection {
        } nbt;
        bool using_smb2;
        int trans_num;
+       struct files_struct *files;
        struct {
                struct fd_event *fde;