From 98c082489bec0a0ce4db1daf4390e785381f229a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 28 Dec 2006 21:50:31 +0000 Subject: r20394: This is a *VERY* early start of my work on notify. Checking in because Jeremy was bugging me. Potentially this becomes quite intrusive, I'm not sure if I should open a temporary branch for this. Jeremy, Jerry, do you think 3_0 is the right place for this? Volker (This used to be commit bcf5c751cbe203c00814642e26440cf88f300bce) --- source3/smbd/files.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'source3/smbd/files.c') diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 7069818dee..8df7a29a65 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -100,6 +100,12 @@ NTSTATUS file_new(connection_struct *conn, files_struct **result) ZERO_STRUCTP(fsp->fh); + if (!(fsp->notify = TALLOC_ZERO_P(NULL, struct notify_changes))) { + SAFE_FREE(fsp->fh); + SAFE_FREE(fsp); + return NT_STATUS_NO_MEMORY; + } + fsp->fh->ref_count = 1; fsp->fh->fd = -1; @@ -361,6 +367,35 @@ files_struct *file_find_di_next(files_struct *start_fsp) return NULL; } +/**************************************************************************** + Find the directory fsp given a device and inode with the lowest + file_id. First use is for notify actions. +****************************************************************************/ + +files_struct *file_find_dir_lowest_id(SMB_DEV_T dev, SMB_INO_T inode) +{ + files_struct *fsp; + files_struct *min_fsp = NULL; + + for (fsp = Files; fsp; fsp = fsp->next) { + if (!fsp->is_directory + || fsp->dev != dev || fsp->inode != inode) { + continue; + } + + if (min_fsp == NULL) { + min_fsp = fsp; + continue; + } + + if (fsp->fh->file_id < min_fsp->fh->file_id) { + min_fsp = fsp; + } + } + + return min_fsp; +} + /**************************************************************************** Find a fsp that is open for printing. ****************************************************************************/ @@ -439,6 +474,8 @@ void file_free(files_struct *fsp) fsp->fh->ref_count--; } + TALLOC_FREE(fsp->notify); + bitmap_clear(file_bmap, fsp->fnum - FILE_HANDLE_OFFSET); files_used--; -- cgit