X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:references:in-reply-to:subject:date :message-id:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=HUDH1+dPnWy6Yxpkr4EAISP/R5QfCttvT91MICxtB12 RrwVpIngDusl1tl67O28oW64lJ6RlpNOYNlsYyLP6Aga9yQRhzEc1LS9p6LMO6Zb GyS9IhI7BZRqvPtu+gTDzuf3vAw0+aroBajWUPMlAMEh77pTNyIKDgLpcNkoHhOg = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:references:in-reply-to:subject:date :message-id:mime-version:content-type:content-transfer-encoding; s=default; bh=JIbKwpDarl2TAPp19c1LoXTbcIY=; b=K1cxgwkqdHjO76O+1 O12/tDKS0DD4JIrukIZsTO96NUK4gtCk4+nhtcyvWmgC+IJ1xjXTt1/drGKiqRRo FLYdDVtm6SJUXRY8sXzKc84noW+zIZ+pnDbWJrSUMH2YTEox8UhR3qhJ7c+OSP6L xn8hgtfeHA16Fv9dpu5e0S9Qik= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Penny, licence, H*F:D*ac.uk, H*r:LOGIN X-HELO: ppsw-31.csi.cam.ac.uk From: "David Allsopp" To: References: <5a67c70d DOT 89349d0a DOT 83b53 DOT 40f2 AT mx DOT google DOT com> <4ce888e4-a825-be3b-afb5-77ba851a9760 AT SystematicSw DOT ab DOT ca> In-Reply-To: <4ce888e4-a825-be3b-afb5-77ba851a9760@SystematicSw.ab.ca> Subject: RE: Ejecting a USB drive using Cygwin (sync)? Date: Thu, 25 Jan 2018 09:58:39 -0000 Message-ID: <000301d395c3$1323f000$396bd000$@cl.cam.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-IsSubscribed: yes Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id w0P9wpYR021771 Brian Inglis wrote: > On 2018-01-23 16:36, Steven Penny wrote: > > On Tue, 23 Jan 2018 14:13:24, Brian Inglis wrote: > >> I found the following utility works well without elevation - Windows > >> code from > >> http://www.leapsecond.com/tools/eject.{c,exe}: > >> > >> // eject -- Allow safe removal of USB thumb drive. > >> // - Command line tool to flush/dismount/eject USB drive. > >> // - Simpler than mouse clicking through taskbar "Safely Remove > >> Hardware" icon. > >> // - Usable in batch file scripts. > >> // 02-Nov-2012 Tom Van Baak (tvb) www.LeapSecond.com/tools ... > >> // Per MSDN, follow procedure for safe removal of USB drive. > >> int drive_eject (char *drive) > >> { > >>     HANDLE hDev; > >>     // Convert vintage DOS drive letter to weird Windows object > >> pathname. > >>     char path[10]; > >>     sprintf(path, "\\\\.\\%s", drive); > >>     // Open (with write, but no lock) to flush pending writes. > >>     DEV_OPEN(path, GENERIC_READ | GENERIC_WRITE); > >>     FlushFileBuffers(hDev); > >>     CloseHandle(hDev); > >>     // Open (with read, and lock) to dismount and eject. > >>     DEV_OPEN(path, GENERIC_READ); > >>     DEV_IOCTL(FSCTL_LOCK_VOLUME); > >>     DEV_IOCTL(FSCTL_DISMOUNT_VOLUME); > >>     DEV_IOCTL(IOCTL_STORAGE_EJECT_MEDIA); > >>     DEV_IOCTL(FSCTL_UNLOCK_VOLUME); > >>     CloseHandle(hDev); > >>     return 0; > >> } > > > > No, this is not the code from that site. The code is similar, but I > > see you have at least removed some empty lines. If you are going to do > > so, you need to clearly present said changes to the community - > > something like "adapted from http://..." or "modified from http://...", > > etc. > > > > Software copyright - even open source license is serious, and you > > should give it due respect. > > I was providing information, that's why I said /from/, gave the link to > the original, and included the copyright, which does not include a link > to the MSDN article it mentions: I expect it's referring to this article: https://support.microsoft.com/en-us/help/165721. There's another quite good article on it at https://www.codeproject.com/Articles/259577/How-to-flush-a-storage-volumes-t he-file-cache-lock > checking any licences are left as an > exercise for any reader who wants to make use of the program or code > other than for their own private use. What licence is the ellipsis you added to the copyright line released under? ;o) --dra -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple