Posix support in Mingw

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Posix support in Mingw

roy basavaraju
Hi,

    i am working an application, which needs to read user_id(uid), group_id(gid). for this i need posix headers grp.h & pwd.h.
So my issue is if i replace these header files with any of the gnu libraries which supports in mingw, will my application able to read these file atributes correctly when it si running on a linux target..

if i summerise, i have to dvelop an filesystem related  application in mingw, with this executable i have to generate filesystem image in windows.. this filesystem image i will flash in a linux based target.. it should work perfectly as the filesystem generated in linux environment..

Thanks for u r help..
Ram

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: Posix support in Mingw

Jonathan Schleifer-4
MinGW does not offer any sort of POSIX layer for Windows. What you're  
looking for is Microsoft Services for Unix or Cygwin.

--
Jonathan


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

PGP.sig (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Posix support in Mingw

Tor Lillqvist
In reply to this post by roy basavaraju
> i am working an application, which needs to read user_id(uid),
> group_id(gid).

Read them from where? You mean, get the "id" of the user running the
application, and of his group?

> for this i need posix headers grp.h & pwd.h

No you don't. Windows isn't POSIX. The POSIX concept of a single
integer (often restricted to 16-bit values even) being able to
represent a "user id" or "group id" does not exist in Windows. MinGW
is a tool-chain to build Windows programs. No POSIX emulation is
provided (in addition to the POSIX-inspired functions already present
in the Microsoft C library, like open() and read().)

If you mean read user and group ids from some file system image, you
don't need <pwd.h> and <grp.h> for that either. Just read them from
the inodes as stored in the file system image. Or am I missing
something?

> So my issue is if i replace these header files with any of the gnu libraries
> which supports in mingw, will my application able to read these file
> atributes correctly when it si running on a linux target..

"When running on a Linux target"? If you are building code to run on
Linux (cross-compiling from Windows?), then of course you should use
the headers for that cross-compilation environment, not MinGW's
headers. In fact I don't see what MinGW has to do with suich
(cross-)compilation at all?

> if i summerise, i have to dvelop an filesystem related  application in
> mingw, with this executable i have to generate filesystem image in windows..
> this filesystem image i will flash in a linux based target..

OK, now this finally starts to make sense. So is your problem that you
want to take files that exist in some directory tree in the Windows
file system and store them in this image of a Linux file system, and
you don't know what user id and group id to use for files?

(Or presumably protection, for that matter. Don't be misguided and
think that the st_mode that the stat() in the Microsoft C library
fills in is of much use. It has little to do with the "faked"
protection bits that the POSIX emulation in MSYS or Cygwin provide,
that you see in the output of a MSYS or Cygwin ls command, or set with
a MSYS or Cygwin chmod command, for instance.)

Just use some suitable heuristics and extra data. You can't create an
source tree for the file system on Windows and expect to be able
create the Linux file system with complete arbitrary user, group and
mode settings from only the information in a Windows file system
anyway, as Windows does not have the same kind of file protection
mechanisms. You will have to use some extra data explicitly telling
what protection, use and group to use for the files in various
directories, in general, and with special cases singled out.

> it should work perfectly as the filesystem generated in linux environment..

Not possible, as I have tried to describe. On Linux (or some other
POSIX) you can have the files in the source tree already have the
desired protection, user and group they should have in the target file
system. Not on Windows.

--tml

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: Posix support in Mingw

roy basavaraju
Hi tml,
 
   Thank you very much. i got good clarity from your explanation.. however i want to give more information from my side so that we can draw some conclusions.

  actually what i am trying to do is:

you might be knowing yaffs2 file system in embedded linux. they have provided a tool called mkyaffs2image, which creates a yaffs2.img file from file system directory. this image will be flashed on linux based target  to access these directries..

 So what i am doing is, i have taken same mkyaff2image tool(which is developed in linux & for linux targets) and trying to compile in Mingw. so here i want to create s yaffs2.img  from a directory. So i have to read the uid & gid of each directory & file  and store in yaffs2.img.

So please conclude whether i can acheive my target with mingw alone. i can go ahead with Cygwin, which has posix emulation layer. but my application must not depend on cygwin1.dll.

or u can suggest me, is it possible to use mingw through cygwin, so that my application might not depend on cygwin1.dll.

Please help me to take some decission on this area like should i go ahead with mingw in acheiving my goal.

Thanks for u r help,
Ram


On Sat, Mar 7, 2009 at 2:08 AM, Tor Lillqvist <[hidden email]> wrote:
> i am working an application, which needs to read user_id(uid),
> group_id(gid).

Read them from where? You mean, get the "id" of the user running the
application, and of his group?

> for this i need posix headers grp.h & pwd.h

No you don't. Windows isn't POSIX. The POSIX concept of a single
integer (often restricted to 16-bit values even) being able to
represent a "user id" or "group id" does not exist in Windows. MinGW
is a tool-chain to build Windows programs. No POSIX emulation is
provided (in addition to the POSIX-inspired functions already present
in the Microsoft C library, like open() and read().)

If you mean read user and group ids from some file system image, you
don't need <pwd.h> and <grp.h> for that either. Just read them from
the inodes as stored in the file system image. Or am I missing
something?

> So my issue is if i replace these header files with any of the gnu libraries
> which supports in mingw, will my application able to read these file
> atributes correctly when it si running on a linux target..

"When running on a Linux target"? If you are building code to run on
Linux (cross-compiling from Windows?), then of course you should use
the headers for that cross-compilation environment, not MinGW's
headers. In fact I don't see what MinGW has to do with suich
(cross-)compilation at all?

> if i summerise, i have to dvelop an filesystem related  application in
> mingw, with this executable i have to generate filesystem image in windows..
> this filesystem image i will flash in a linux based target..

OK, now this finally starts to make sense. So is your problem that you
want to take files that exist in some directory tree in the Windows
file system and store them in this image of a Linux file system, and
you don't know what user id and group id to use for files?

(Or presumably protection, for that matter. Don't be misguided and
think that the st_mode that the stat() in the Microsoft C library
fills in is of much use. It has little to do with the "faked"
protection bits that the POSIX emulation in MSYS or Cygwin provide,
that you see in the output of a MSYS or Cygwin ls command, or set with
a MSYS or Cygwin chmod command, for instance.)

Just use some suitable heuristics and extra data. You can't create an
source tree for the file system on Windows and expect to be able
create the Linux file system with complete arbitrary user, group and
mode settings from only the information in a Windows file system
anyway, as Windows does not have the same kind of file protection
mechanisms. You will have to use some extra data explicitly telling
what protection, use and group to use for the files in various
directories, in general, and with special cases singled out.

> it should work perfectly as the filesystem generated in linux environment..

Not possible, as I have tried to describe. On Linux (or some other
POSIX) you can have the files in the source tree already have the
desired protection, user and group they should have in the target file
system. Not on Windows.

--tml

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: Posix support in Mingw

JonY-2
On 3/8/2009 08:30, roy basavaraju wrote:

> Hi tml,
>
>     Thank you very much. i got good clarity from your explanation.. however i
> want to give more information from my side so that we can draw some
> conclusions.
>
>    actually what i am trying to do is:
>
> you might be knowing yaffs2 file system in embedded linux. they have
> provided a tool called mkyaffs2image, which creates a yaffs2.img file from
> file system directory. this image will be flashed on linux based target  to
> access these directries..
>
>   So what i am doing is, i have taken same mkyaff2image tool(which is
> developed in linux&  for linux targets) and trying to compile in Mingw. so
> here i want to create s yaffs2.img  from a directory. So i have to read the
> uid&  gid of each directory&  file  and store in yaffs2.img.
>

Hi,

Windows doesn't have UIDs or GIDs, so it is not possible to read them at
all.

> So please conclude whether i can acheive my target with mingw alone. i can
> go ahead with Cygwin, which has posix emulation layer. but my application
> must not depend on cygwin1.dll.
>

Why must it not depend on cygwin1.dll?

> or u can suggest me, is it possible to use mingw through cygwin, so that my
> application might not depend on cygwin1.dll.
>

MinGW and Cygwin do not magically make UNIX apps run on Windows. MinGW
on Cygwin functions the same as MinGW without Cygwin; MinGW is unlikely
to ever provide POSIX permission emulation.

> Please help me to take some decission on this area like should i go ahead
> with mingw in acheiving my goal.
>

Maybe you can add stub functions which returns 0 for both UID and GID,
but you should already be aware of the possible security implications.

Finally, please spell properly, avoid using unnecessary abbreviation
such as "u", it will allow others to take you more seriously. You also
forgot the following, especially the 1st,

>> Most annoying abuses are:
>> 1) Top posting
>> 2) Thread hijacking
>> 3) HTML/MIME encoded mail
>> 4) Improper quoting
>> 5) Improper trimming

Regards

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: Posix support in Mingw

Keith Marshall
On Sunday 08 March 2009 02:20:01 JonY wrote:
> Maybe you can add stub functions which returns 0 for both UID and
> GID, but you should already be aware of the possible security
> implications.

Or any other value which might suit your needs; bear in mind that UID
zero represents `superuser', i.e. the most privileged user on the
system, and that GID zero is similarly the most privileged group,
with effectively superuser capability.

--

Regards,
Keith.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: Posix support in Mingw

Tor Lillqvist
In reply to this post by roy basavaraju
>  So what i am doing is, i have taken same mkyaff2image tool(which is
> developed in linux & for linux targets) and trying to compile in Mingw. so
> here i want to create s yaffs2.img  from a directory. So i have to read the
> uid & gid of each directory & file  and store in yaffs2.img.

OK, as I thought then.

Don't forget that you also have to get the desired mode bits (the
rwxrwxrwx protection bits plus the setuid, setgid and sticky bits)
from somewhere and store them, too, in the file system image. For a
properly functioning Linux file syetem, especially one that contains
the system files, it is essential that these are correct, too.

What you want to do can't be done on Windows without some ancilliary
data structures that tell the desrired uid, gid and mode for each
directory and file. It is questionable whether even building and
running the mkyaff2image tool on Cygwin would be good enough, as one
apparently can't give files and directories arbitrary uids and gids on
Cygwin, which would be needed in order to make the source tree
correspond exactly to the destination file system image. Just try
"mkdir foo; chown 0 foo" in Cygwin. In order to build an exact source
tree, you obviously would want to create several files and directories
that should be owned by root (uid 0). But discussing Cygwin is
off-topic here anyway.

> So please conclude whether i can acheive my target with mingw alone.

Not without a significant amount of additional programming to add
functionality to the mkyaff2image tool.

> I can go ahead with Cygwin, which has posix emulation layer. but my application
> must not depend on cygwin1.dll.

No. If you build a Cygwin program, then it depends on cygwin1.dll by
definition. (But as I said above, I think what you want to do isn't
possible even on Cygwin. But this is the mingw list anyway.)

--tml

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: Posix support in Mingw

roy basavaraju

On Sun, Mar 8, 2009 at 2:44 AM, Tor Lillqvist <[hidden email]> wrote:
>  So what i am doing is, i have taken same mkyaff2image tool(which is
> developed in linux & for linux targets) and trying to compile in Mingw. so
> here i want to create s yaffs2.img  from a directory. So i have to read the
> uid & gid of each directory & file  and store in yaffs2.img.

OK, as I thought then.

Don't forget that you also have to get the desired mode bits (the
rwxrwxrwx protection bits plus the setuid, setgid and sticky bits)
from somewhere and store them, too, in the file system image. For a
properly functioning Linux file syetem, especially one that contains
the system files, it is essential that these are correct, too.

What you want to do can't be done on Windows without some ancilliary
data structures that tell the desrired uid, gid and mode for each
directory and file. It is questionable whether even building and
running the mkyaff2image tool on Cygwin would be good enough, as one
apparently can't give files and directories arbitrary uids and gids on
Cygwin, which would be needed in order to make the source tree
correspond exactly to the destination file system image. Just try
"mkdir foo; chown 0 foo" in Cygwin. In order to build an exact source
tree, you obviously would want to create several files and directories
that should be owned by root (uid 0). But discussing Cygwin is
off-topic here anyway.

> So please conclude whether i can acheive my target with mingw alone.

Not without a significant amount of additional programming to add
functionality to the mkyaff2image tool.

> I can go ahead with Cygwin, which has posix emulation layer. but my application
> must not depend on cygwin1.dll.

No. If you build a Cygwin program, then it depends on cygwin1.dll by
definition. (But as I said above, I think what you want to do isn't
possible even on Cygwin. But this is the mingw list anyway.)

--tml


Hi,

   Ok. I agree with you. if I use libtar OR libarchive kind of tar tool, which will take a tar file as input and extract it on the fly and give input to mkyaffs2image tool. So here we are not extracting onto windows & so we are preserving the uid and gid of the files.

  But ofcourse, libtar also using posix header files like grp.h and pwd.h

  anyway thanks for your kind sugessions. please let me know, if any posibilities on mingw to acheive my target.

also please forgive me, if have not followed mingw mailing list rules.

Thanks,
ram





------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: Posix support in Mingw

Tor Lillqvist
>   But of course, libtar also using posix header files like grp.h and pwd.h

So it is then up to you to modify it so that it doesn't need those for
the subset of its functionality that you want to use. Do it cleanly
and submit a patch to its maintainer so that others can benefit of
your work.

--tml

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users