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:message-id:date:from:subject:to:references :content-type; q=dns; s=default; b=SdSWJ0TqI5vJpvA79dA1bH6I3AarI 03GFhS0q8+1o0xpxCf0ewxdynU1eQoAMf0GK+H974Wrs19+14hGEBGFk2Dv6y9Uy ZMQTu4g8lMoz4JrRjBdYuK6HLo5cdF1HZyzitmsjQImd1y6VVv+7GEiRGxSDd4Wo zcU/K1LhoLormw= 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:message-id:date:from:subject:to:references :content-type; s=default; bh=IvyWwq+rXQLCk/9esmwpzEI3W04=; b=APN ShVtH7+1d3g9F1CJTItXSgB3l98Ng//ow+ppooH361vU+qYu8EgKaCkUG/9LlXqp 9V0pKWfBPegnshxW1bEKONeG8iLb1X9lxcX7XYj5K91aGmQqLzh8vsBf+HPJxFPx B76HckLdgLQzJ/aB8ORwTPN8rE1gM+xlhCH0+qAY= 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=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=clicking, vintage, DOS, mouse X-HELO: mail-oi0-f48.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:from:subject:to:references :user-agent; bh=abxzLWhzg/WPkfuSADaNS5o6DNIGvuBfsB0e7wvyOeY=; b=W2RP/7UqAKImSNVXdotEMbDGj/Ql5jnDiNij7jLuZSvovjS4L16UUSiG8GRFekNqcx 71KnILWqBTGpU3oekp3KQNKxWec3mi71XXyYVmkTkxWiddEykDh6GEvKe0iKeLd/uzDI Kav7n/7lVuS/0r6JiAvZ43mRTH0FluHAW6niA5uVA6OnN/khDML6tmFZQIwxiZI5+LSp xoIzeTr0LupDnLOfHcCfVmbB+YmqUH3ICRHQqZMQpEkiP0o1TzeWABjYqeetbbAR4Jil tPAs3boJxlUjXTnSp2mzDsC6tKYVan/E0B55yegzn9Pbwcq74Uwb3RboEZDlLURp0VBp NjYw== X-Gm-Message-State: AKwxytfUZDCUOLtcI051FcCsz1z9QD1Igq0IFxQ1+dRLzkFkbxlo7mIO gM4rQhZIr4a/qcCaqVmKyrqQ2A== X-Google-Smtp-Source: AH8x225+VPxexCxsCF/flGHPCdCslJejaOfOTrgh/RHhECBQPtB0ZfkmAEdwn1BpJgMrFf6UJJltZQ== X-Received: by 10.202.173.212 with SMTP id w203mr7024569oie.149.1516750605925; Tue, 23 Jan 2018 15:36:45 -0800 (PST) Message-ID: <5a67c70d.89349d0a.83b53.40f2@mx.google.com> Date: Tue, 23 Jan 2018 15:36:45 -0800 (PST) From: Steven Penny X-Google-Original-From: Steven Penny Subject: Re: Ejecting a USB drive using Cygwin (sync)? To: cygwin AT cygwin DOT com References: Content-Type: text/plain; charset=utf8; format=flowed User-Agent: Tryst/2.1.0 (github.com/svnpenn/tryst) 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. -- 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