Message-Id: <199905311824.SAA72470@out2.ibm.net> From: "Mark E." To: djgpp-workers AT delorie DOT com, Eli Zaretskii Date: Mon, 31 May 1999 14:25:09 -0400 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: enhancements to fcntl.c X-mailer: Pegasus Mail for Win32 (v3.11) Reply-To: djgpp-workers AT delorie DOT com > I've created a small program to see if the undocumented calls work. It > works fine under DOS and Win95, but may not under Win NT. I'd > appreciate it if someone could run this program under NT and post the > message it produces. Note: the executable opens the source file, so > make sure the source is in the same directory as the exe. I've updated the program to test the device info word. From experimentation, it seems the no-inherit bit is stored with the file mode instead of the device info word. I'd be interested to know if this is also true with Win NT. BTW, thanks Eli for testing this. #include #include #include #include #include #include unsigned char sft_entry[64]; static int get_sft_entry(int fd, char sft_entry[]) { __dpmi_regs regs; unsigned char index; /* Get JFT entry address. */ regs.x.ax = 0x1220; regs.x.bx = fd; __dpmi_int (0x2f, ®s); if (regs.x.flags & 1) { __doserr_to_errno(regs.x.ax); return -1; } /* First byte is the SFT entry number. */ dosmemget(regs.x.es * 16 + regs.x.di, 1, &index); /* Get the SFT entry for the handle. */ regs.x.ax = 0x1216; regs.x.bx = index; __dpmi_int (0x2f, ®s); if (regs.x.flags & 1) { __doserr_to_errno(regs.x.ax); return -2; } dosmemget(regs.x.es * 16 + regs.x.di, 63, sft_entry); return 0; } int main() { int fd = open("sftcheck.c", O_RDWR | O_NOINHERIT); int ret; __dpmi_regs r; r.x.ax = 0x4400; r.x.bx = fd; __dpmi_int(0x21, &r); printf("\nTesting Int 21 ax=0x4400 for no-inherit bit... "); if (r.x.dx & (1<<12)) printf("found!\n"); else printf("not found.\n"); printf("Trying to get SFT entry... "); ret = get_sft_entry(fd, sft_entry); if (ret < 0) { if (ret == -1) printf("unable to get JFT entry (int 21 ax=1220).\n"); else printf("unable to get SFT entry (int 21 ax=1216).\n"); close (fd); return 0; } else printf("success!\n"); printf("Testing device info byte for no-inherit flag... "); if (sft_entry[5] & (1<<12)) printf("found!\n"); else printf("not found.\n"); printf("Testing mode byte for O_RDWR... "); if ((sft_entry[2] & O_ACCMODE) == O_RDWR) printf("contains O_RDWR!\n"); else printf("does not contain O_RDWR.\n"); printf("Testing mode byte for no-inherit bit... "); if (sft_entry[2] & 128) printf("found!\n"); else printf("not found.\n"); printf("\n"); close (fd); return 0; } --- Mark Elbrecht, snowball3 AT bigfoot DOT com http://snowball.frogspace.net/