diff options
author | Jeremy Allison <jra@samba.org> | 2005-12-13 18:11:50 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:05:49 -0500 |
commit | ab7a4f7e8e4b946a8acd0a205c16dbf6a3afecad (patch) | |
tree | d91dcd5c2a731925cec24e67c5a4e78dd3b7dac0 /source3/smbd/open.c | |
parent | 7d2771e758d4e8ef0adb45e55775b524de4dba9a (diff) | |
download | samba-ab7a4f7e8e4b946a8acd0a205c16dbf6a3afecad.tar.gz samba-ab7a4f7e8e4b946a8acd0a205c16dbf6a3afecad.tar.bz2 samba-ab7a4f7e8e4b946a8acd0a205c16dbf6a3afecad.zip |
r12213: Final fix for #3303 - send rename messages to smbd's
that have open file handles to allow them to correctly
implement delete on close. There is a further correctness
fix I'm intending to add to this to cope with different share
paths, but not right now...
Jeremy.
(This used to be commit 932e337db8788e75344e1c7cf1ef009d090cb039)
Diffstat (limited to 'source3/smbd/open.c')
-rw-r--r-- | source3/smbd/open.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c index b3f0589dc7..7621ee001d 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -2042,3 +2042,50 @@ files_struct *open_file_stat(connection_struct *conn, char *fname, return fsp; } + +/**************************************************************************** + Receive notification that one of our open files has been renamed by another + smbd process. +****************************************************************************/ + +void msg_file_was_renamed(int msg_type, struct process_id src, void *buf, size_t len) +{ + files_struct *fsp; + struct file_renamed_message *frm = (struct file_renamed_message *)buf; + const char *sharepath; + const char *newname; + size_t sp_len; + + if (buf == NULL || len < sizeof(*frm)) { + DEBUG(0, ("msg_file_was_renamed: Got invalid msg len %d\n", (int)len)); + return; + } + + sharepath = &frm->names[0]; + newname = sharepath + strlen(sharepath) + 1; + sp_len = strlen(sharepath); + + DEBUG(10,("msg_file_was_renamed: Got rename message for sharepath %s, new name %s, " + "dev %x, inode %.0f\n", + sharepath, newname, (unsigned int)frm->dev, (double)frm->inode )); + + for(fsp = file_find_di_first(frm->dev, frm->inode); fsp; fsp = file_find_di_next(fsp)) { + if (memcmp(fsp->conn->connectpath, sharepath, sp_len) == 0) { + DEBUG(10,("msg_file_was_renamed: renaming file fnum %d from %s -> %s\n", + fsp->fnum, fsp->fsp_name, newname )); + string_set(&fsp->fsp_name, newname); + } else { + /* TODO. JRA. */ + /* Now we have the complete path we can work out if this is + actually within this share and adjust newname accordingly. */ + DEBUG(10,("msg_file_was_renamed: share mismatch (sharepath %s " + "not sharepath %s) " + "fnum %d from %s -> %s\n", + fsp->conn->connectpath, + sharepath, + fsp->fnum, + fsp->fsp_name, + newname )); + } + } +} |