[comp.os.os2.programmer] Max Open File Problem

barry@hpdmd48.boi.hp.com (Barry Kurtz) (01/08/91)

I am having trouble porting a program to OS/2 under Microsoft C that
I've successfully ported among DOS and SCO UNIX systems.  The program
requires at least 16 files to be open at one time.  This is easily
handled on both DOS and UNIX.  The files are opened by the standard
"fopen" library function.  I find that OS/2 limits me to about 14 user
files at one time (probably a 20 file total limit).  I've investigated
the FCBS parameter in CONFIG.SYS and the DosSetMaxFH function in the
OS/2 library to no avail.  However, if I use DosSetMaxFH in conjunction
with the OS/2-specific DosOpen function I can open the desired number of
files.  Converting all fopens and fprintfs to the DOSxxx library
functions would make the program much less portable - so this is not an
acceptable answer.

Does anyone know of a way to open more than 14 user files under OS/2
using the Microsoft C 6.0 compiler?  Any help would be greatly
appreciated.


Barry Kurtz
Hewlett-Packard
Boise, Idaho

ballard@cheddar.ucs.ubc.ca (Alan Ballard) (01/10/91)

In article <6070002@hpdmd48.boi.hp.com> barry@hpdmd48.boi.hp.com (Barry Kurtz) writes:

>Does anyone know of a way to open more than 14 user files under OS/2
>using the Microsoft C 6.0 compiler?  Any help would be greatly
>appreciated.
 
You may have to reassemble the startup code.  See the file
/msc/source/startup/os2/crt0data.asm that comes with the MSC distribution.
It includes commented-out code to increase DosSetMaxFH, which you are
supposed to enable of you need more than 20. 
 
Alternatively, you might try just adding the call to DosSetMaxFH to your
program before you actually open any files.  I don't see why this wouldn't
work. 
Alan Ballard                   | Internet: ballard@ucs.ubc.ca
University Computing Services  |   Bitnet: USERAB1@UBCMTSG
University of British Columbia |    Phone: 604-228-3074
Vancouver B.C. Canada V6R 1W5  |      Fax: 604-228-5116

cur022%cluster@ukc.ac.uk (Bob Eager) (01/10/91)

In article <6070002@hpdmd48.boi.hp.com>, barry@hpdmd48.boi.hp.com (Barry Kurtz) writes:
> Does anyone know of a way to open more than 14 user files under OS/2
> using the Microsoft C 6.0 compiler?  Any help would be greatly
> appreciated.
> 

There is a well hidden set of files on the distribution disks that enable
you to rebuild the C runtime startup code to support a larger number of
open files. Run SETUP/COPY, and ask for the STARTUP.DOC file. That'll tell
you the names of the other files to ask for.
-------------------------+-------------------------------------------------
Bob Eager                | University of Kent at Canterbury
                         | +44 227 764000 ext 7589
-------------------------+-------------------------------------------------

barry@hpdmd48.boi.hp.com (Barry Kurtz) (01/11/91)

Thanks for the many responses I've received here and by e-mail.  I
re-compiled and updated the libraries as per the instructions in the
SOURCE directory and things seem to work fine.  

Thanks again for your help,

Barry Kurtz
Hewlett-Packard
Boise, Idaho