Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45578 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92630 invoked from network); 16 Sep 2009 09:30:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2009 09:30:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=permerror Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 78.32.209.33 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 78.32.209.33 freshmint.phcomp.co.uk Linux 2.6 Received: from [78.32.209.33] ([78.32.209.33:62047] helo=mint.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 92/19-39049-A30B0BA4 for ; Wed, 16 Sep 2009 05:30:38 -0400 Received: from addw by mint.phcomp.co.uk with local (Exim 4.63) (envelope-from ) id 1MnqqN-000826-6U; Wed, 16 Sep 2009 10:30:31 +0100 Date: Wed, 16 Sep 2009 10:30:31 +0100 To: Ian Tighe Cc: internals@lists.php.net Message-ID: <20090916093031.GH16365@phcomp.co.uk> Mail-Followup-To: Ian Tighe , internals@lists.php.net References: <3A8BE18A46C746E69582175E92E503AC@saturn> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3A8BE18A46C746E69582175E92E503AC@saturn> User-Agent: Mutt/1.4.2.2i Organization: Parliament Hill Computers Ltd Subject: Re: [PHP-DEV] Detecting share violations over cifs with PHP? Feature request From: addw@phcomp.co.uk (Alain Williams) On Wed, Sep 16, 2009 at 10:14:55AM +0100, Ian Tighe wrote: > Hi. I hope this has been sent to the right place. > I am using files that are mount.cif share files. My client is a samba linux box but acting as a client over cifs to an XP box (several in fact). > I am descending the share recursively with opendir and readdir detecting files ( and of course directories ) before doing my processing. > I note from a wireshark trace I am getting errors - sharing violations reported by XP. I would very much like to detect these events to take action - ignore the file for instance - but right now I have a true or false return from readdir, is_dir, is_file or is_link which is not very helpful during a fault condition such as a sharing violation. In other words a sharing violation looks like a readdir saying no more files! > > It seems that once the error condition comes about all my reads of a directory and tests of file types fail until I reach the end of that directory and all of its parent directories. This is not so good. > > Am I missing a trick here? If not is it possible to bring out more error information so that I can detect these events. An error array as an additional overloaded argument to readdir, opendir (indeed any I/O) where the first element has the normal true/false perhaps but a second element has a return code for smb/cifs/file_system failure/error/warning condition? Exporting the value of errno would be really useful here. However: the value would be OS specific which would damage PHP program portability. Maybe a function like get_last_os_error() might be appropriate. This would return is PHP error number, ie map OS specific info (which is sometimes more than just errno) onto something OS independent. This might be a non tiny amount of work, but is only done if the application *really* wants/needs to know. What the function might return could be an array, where different elements contain different levels of details - including the OS specific stuff (some people are not bothered by portablity). I don't know. -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php Past chairman of UKUUG: http://www.ukuug.org/ #include