Re: /usr/bin/dd *.iso to USB stick?

2023-09-23 Thread Christian Franke via Cygwin

Jim Garrison via Cygwin wrote:

On 9/21/2023 22:40, Martin Wege via Cygwin wrote:

Hello,

How can I use /usr/bin/dd to copy a *.iso image (Debian netinstall
boot image) to a USB stick as raw bytes?


I do this frequently.  You must start the Cygwin shell with admin
rights, then use Windows Disk Management mmc app to identify
the disk and convert from Disk n to /dev/sd[x], where Disk 0 is
/dev/sda, Disk 1 is /dev/sdb, etc.

BIG CAVEAT: You're in admin mode.  Use the wrong device name and you
will trash target device if it's writable, including your Windows boot
drive.  And no, the boot drive is not always Disk0 /dev/sda.

I always use hexedit to examine enough of the target device to assure
myself that it's the correct target.


This is much easier if 'ddrescue --ask' is used instead of 'dd' 
(https://cygwin.com/packages/summary/ddrescue.html). It prints device 
size, identify string and serial "number" string if available and asks 
for confirmation then:


# ddrescue --ask --force image.iso /dev/sde
GNU ddrescue 1.27
About to copy 4671 MBytes
from 'image.iso' (4_562_040Ki)
  to '/dev/sde' [Kingston DataTraveler 3.0::EE03D85142E0] (14_784Mi)
Proceed (y/N)? y
...

Device identity is also printed if the destination is a partition 
(/dev/sde1) on that device. The --force (-f) option is required if the 
destination is not a regular file. Note that for (S)ATA devices, the 
serial may be printed in the unusual LE word string byte order from ATA 
IDENTIFY data. This is a minor bug in some layer behind 
IOCTL_STORAGE_QUERY_PROPERTY.


ddrescue also works with some /proc/sys block devices as source, for 
example /proc/sys/Device/HarddiskVolumeShadowCopy2 or 
/proc/sys/Device/VeraCryptVolumeF  It could also be run from the limited 
WinPE environment, for example to create an image of C: if not booted.


--
Regards,
Christian



--
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple


Re: std::runtime_error on std::locale("")

2023-09-23 Thread Takashi Yano via Cygwin
On Fri, 22 Sep 2023 08:48:45 +0200
ASSI  wrote:
> Takashi Yano via Cygwin writes:
> > I wonder why the following code throws std::runtime_error
> > even though the LC_ALL is set to valid locale other than "C".
> > This does not occur only when LC_ALL is set to "C".
> 
> This functionality is currently only supported for Glibc targets in
> libstdc++.  I seem to remember that I've looked into this some time ago,
> but there didn't seem to be an easy way of enabling it for Cygwin at
> that time.

Thanks for the answer.

It might not be an easy way, but I tried to enabling the locale
feature for libstdc++.

Please try:

1) Run cygport gcc prep
2) Remove libstdc++-v3/config/locale/generic
3) Copy libstdc++-v3/config/locale/gnu to libstdc++-v3/config/locale/generic
4) Apply patches attached to the working source directory.
5) Run cygport gcc compile

I also tried to automate above steps in gcc.cygport.

Further, I tested and confirmed that a few test cases works as expected.

What do you think of this idea?

-- 
Takashi Yano 
diff --git 
a/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c++locale_internal.h 
b/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c++locale_internal.h
index 3ab6af8..81d72f3 100644
--- a/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c++locale_internal.h
+++ b/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c++locale_internal.h
@@ -41,6 +41,107 @@
 
 #include 
 
+#ifdef __CYGWIN__
+typedef locale_t __c_locale;
+#define __locale_t locale_t
+#define __nl_langinfo_l nl_langinfo_l
+#define __strcoll_l strcoll_l
+#define __strftime_l strftime_l
+#define __strtod_l strtod_l
+#define __strtof_l strtof_l
+#define __strtold_l strtold_l
+#define __strxfrm_l strxfrm_l
+#define __newlocale newlocale
+#define __freelocale freelocale
+#define __duplocale duplocale
+#define __uselocale uselocale
+#ifdef _GLIBCXX_USE_WCHAR_T
+#define __iswctype_l iswctype_l
+#define __towlower_l towlower_l
+#define __towupper_l towupper_l
+#define __wcscoll_l wcscoll_l
+#define __wcsftime_l wcsftime_l
+#define __wcsxfrm_l wcsxfrm_l
+#define __wctype_l wctype_l
+#endif
+// monetary
+#define __MON_DECIMAL_POINT _NL_MONETARY_MON_DECIMAL_POINT
+#define __MON_THOUSANDS_SEP _NL_MONETARY_MON_THOUSANDS_SEP
+#define __INT_FRAC_DIGITS _NL_MONETARY_INT_FRAC_DIGITS
+#define __MON_GROUPING _NL_MONETARY_MON_GROUPING
+#define __POSITIVE_SIGN _NL_MONETARY_POSITIVE_SIGN
+#define __NEGATIVE_SIGN _NL_MONETARY_NEGATIVE_SIGN
+#define __INT_CURR_SYMBOL _NL_MONETARY_INT_CURR_SYMBOL
+#define __INT_P_SIGN_POSN _NL_MONETARY_INT_P_SIGN_POSN
+#define __INT_N_SIGN_POSN _NL_MONETARY_INT_N_SIGN_POSN
+#define __INT_P_CS_PRECEDES _NL_MONETARY_INT_P_CS_PRECEDES
+#define __INT_N_CS_PRECEDES _NL_MONETARY_INT_N_CS_PRECEDES
+#define __INT_P_SEP_BY_SPACE _NL_MONETARY_INT_P_SEP_BY_SPACE
+#define __INT_N_SEP_BY_SPACE _NL_MONETARY_INT_N_SEP_BY_SPACE
+#define __CURRENCY_SYMBOL _NL_MONETARY_CURRENCY_SYMBOL
+#define __P_SIGN_POSN _NL_MONETARY_P_SIGN_POSN
+#define __N_SIGN_POSN _NL_MONETARY_N_SIGN_POSN
+#define __P_CS_PRECEDES _NL_MONETARY_P_CS_PRECEDES
+#define __N_CS_PRECEDES _NL_MONETARY_N_CS_PRECEDES
+#define __P_SEP_BY_SPACE _NL_MONETARY_P_SEP_BY_SPACE
+#define __N_SEP_BY_SPACE _NL_MONETARY_N_SEP_BY_SPACE
+#define __FRAC_DIGITS _NL_MONETARY_FRAC_DIGITS
+#define _NL_MONETARY_DECIMAL_POINT_WC _NL_MONETARY_WMON_DECIMAL_POINT
+#define _NL_MONETARY_THOUSANDS_SEP_WC _NL_MONETARY_WMON_THOUSANDS_SEP
+// numeric
+#define DECIMAL_POINT _NL_MONETARY_MON_DECIMAL_POINT // No other appropriate 
ones.
+#define THOUSANDS_SEP _NL_MONETARY_MON_THOUSANDS_SEP // No other appropriate 
ones.
+#define GROUPING _NL_NUMERIC_GROUPING
+// time
+#define _NL_WD_FMT _NL_TIME_WD_FMT
+#define _NL_WD_T_FMT _NL_TIME_WD_T_FMT
+#define _NL_WT_FMT _NL_TIME_WT_FMT
+#define _NL_WERA_D_FMT _NL_TIME_WERA_D_FMT
+#define _NL_WERA_D_T_FMT _NL_TIME_WERA_D_T_FMT
+#define _NL_WERA_T_FMT _NL_TIME_WERA_T_FMT
+#define _NL_WAM_STR _NL_TIME_WAM_STR
+#define _NL_WPM_STR _NL_TIME_WPM_STR
+#define _NL_WT_FMT_AMPM _NL_TIME_WT_FMT_AMPM
+#define _NL_WDAY_1 _NL_TIME_WWEEKDAY_1
+#define _NL_WDAY_2 _NL_TIME_WWEEKDAY_2
+#define _NL_WDAY_3 _NL_TIME_WWEEKDAY_3
+#define _NL_WDAY_4 _NL_TIME_WWEEKDAY_4
+#define _NL_WDAY_5 _NL_TIME_WWEEKDAY_5
+#define _NL_WDAY_6 _NL_TIME_WWEEKDAY_6
+#define _NL_WDAY_7 _NL_TIME_WWEEKDAY_7
+#define _NL_WABDAY_1 _NL_TIME_WWDAY_1
+#define _NL_WABDAY_2 _NL_TIME_WWDAY_2
+#define _NL_WABDAY_3 _NL_TIME_WWDAY_3
+#define _NL_WABDAY_4 _NL_TIME_WWDAY_4
+#define _NL_WABDAY_5 _NL_TIME_WWDAY_5
+#define _NL_WABDAY_6 _NL_TIME_WWDAY_6
+#define _NL_WABDAY_7 _NL_TIME_WWDAY_7
+#define _NL_WMON_1 _NL_TIME_WMONTH_1
+#define _NL_WMON_2 _NL_TIME_WMONTH_2
+#define _NL_WMON_3 _NL_TIME_WMONTH_3
+#define _NL_WMON_4 _NL_TIME_WMONTH_4
+#define _NL_WMON_5 _NL_TIME_WMONTH_5
+#define _NL_WMON_6 _NL_TIME_WMONTH_6
+#define _NL_WMON_7 _NL_TIME_WMONTH_7
+#define _NL_WMON_8 _NL_TIME_WMONTH_8
+#define _NL_WMON_9 _NL_TIME_WMONTH_9
+#define _NL_WMON_10 _NL_TIME_WMONTH_10
+#define _NL_WMON_11 _NL_TIME_WMONTH_11
+#define _NL_W

Re: std::runtime_error on std::locale("")

2023-09-23 Thread Takashi Yano via Cygwin
On Sat, 23 Sep 2023 17:23:59 +0900
Takashi Yano via Cygwin  wrote:

> On Fri, 22 Sep 2023 08:48:45 +0200
> ASSI  wrote:
> > Takashi Yano via Cygwin writes:
> > > I wonder why the following code throws std::runtime_error
> > > even though the LC_ALL is set to valid locale other than "C".
> > > This does not occur only when LC_ALL is set to "C".
> > 
> > This functionality is currently only supported for Glibc targets in
> > libstdc++.  I seem to remember that I've looked into this some time ago,
> > but there didn't seem to be an easy way of enabling it for Cygwin at
> > that time.
> 
> Thanks for the answer.
> 
> It might not be an easy way, but I tried to enabling the locale
> feature for libstdc++.
> 
> Please try:
> 
> 1) Run cygport gcc prep
> 2) Remove libstdc++-v3/config/locale/generic
> 3) Copy libstdc++-v3/config/locale/gnu to libstdc++-v3/config/locale/generic
> 4) Apply patches attached to the working source directory.
> 5) Run cygport gcc compile
> 
> I also tried to automate above steps in gcc.cygport.
> 
> Further, I tested and confirmed that a few test cases works as expected.
> 
> What do you think of this idea?

Sorry,
the patch file name gcc-11.4.0.src.patch should be gcc-11.4.0-1.src.patch.

-- 
Takashi Yano 

-- 
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple


Re: [hatari-devel] compilation failing for cygwin on cirrus CI

2023-09-23 Thread Takashi Yano via Cygwin
On Fri, 22 Sep 2023 20:51:49 +0200
Thomas Huth wrote:
> Am Sat, 16 Sep 2023 23:18:36 +0900
> schrieb Takashi Yano :
> ...
> > Thanks for the report. I looked into this problem and found the cause.
> > I will release new SDL2 package where the issue has been fixed.
> 
> Thank you very much for the quick fix! The Hatari CI pipeline is now
> working fine again:
> 
>  https://cirrus-ci.com/task/4529574676004864

Thanks for testing!

-- 
Takashi Yano 

-- 
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple


Re: Shell API to get Windows SID from Cygwin name?

2023-09-23 Thread Allen, Norton T. via Cygwin

On 9/22/2023 11:11 PM, Brian Inglis wrote:

On 2023-09-22 18:15, Allen, Norton T. via Cygwin wrote:

On 9/22/2023 8:07 AM, Brian Inglis via Cygwin wrote:

On 2023-09-21 23:58, Martin Wege via Cygwin wrote:

Does Cygwin have a shell (e.g. bash) API to lookup the Windows SID for
a given Cygwin user or group name?
/usr/bin/getent usersid thisisausername


Forget Windows! Think Unix:

$ getent passwd $USER    # sanitized output:
$USER:*:$UID:545:U-$HOSTNAME/$USER,S-1-5-21-...-...-...-1001:$HOME:/bin/bash 



According to the man page, getent passwd takes a numeric UID, not a 
user name. But if you don't provide a UID, it basically lists what 
would be in /etc/passwd, which you could parse to locate the row you 
want by username.


[IIRC getent evolved from SunOS YellowPages/YP/NIS/+ facilities and 
commands as LANs, sites, and orgs required more central control and 
distribution than could easily be managed using text files 
/etc/{hosts,protocols,services,networks,...}, while requiring 
flexibility to allow some local setup and configurable priority 
depending on system roles, provided by the Name Services Switch 
/etc/nsswitch.conf.]


I checked all distro man pages I can find online and have locally, and 
from SunOS and Solaris, key lookup and other features were supported 
from the early days, while BSDs appear to use GNU (glibc) getent (or 
at least its man page), as does Linux.


All data sources support lookup by non-numeric key get...nam(3), 
some by numeric key get...id(3), and some support enumeration 
set...ent(3), get...ent(3), end...ent(3), e.g.


$ man getent
...
passwd    When no key is provided, use
setpwent(3), getpwent(3), and endpwent(3)
to enumerate the passwd database.
When one or more key arguments are provided, pass each
numeric key to getpwuid(3) and each
nonnumeric key to getpwnam(3)
and display the result.
On Cygwin the key can also be a Windows SID.
...

Perhaps you were thinking of POSIX id(1p) which only takes a user 
login name?


Sorry, you are entirely correct. I tried with my username and got 
nothing. Then I remembered I have a different username on this system.




--
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple