home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.programmer:5671 comp.unix.wizards:5208
- Path: sparky!uunet!spool.mu.edu!uwm.edu!psuvax1!rutgers!banana!vpbuild!adsi!markp
- From: markp@adsi.homecare.com (Mark Parr)
- Newsgroups: comp.unix.programmer,comp.unix.wizards
- Subject: Tape management program
- Message-ID: <1992Dec8.175936.5802@adsi.homecare.com>
- Date: 8 Dec 92 17:59:36 GMT
- Sender: markp@adsi.homecare.com (Mark Parr)
- Organization: Application Data Systems, Inc.
- Lines: 82
-
- I'm working on a C program as a front end to tape management program that
- I'm writing. The layout of our tape format is:
-
- [tape header][file1 header][file1][.....][filen header][filen]
-
-
- Headers are written to tape using the following syntax:
-
- sprintf(command, "dd of=%s 2> /dev/null", tape_device);
- fp = popen(command, "w");
- fwrite(fp, &header, (sizeof(header)), 1, fp);
- pclose(fp);
-
- where header is either the tape header structure or the file header
- structure.
-
-
- Adding files to the tape is done as follows:
-
- sprintf(command, "ls %s | cpio -oc > %s 2> /dev/null", file, tape_device);
- system(command);
-
- where file is the file to add.
-
-
- Extracting files first accomplished by verifying the correct tape then moving
- through the various files using:
-
- sprintf(command, "dd if=%s 2> /dev/null", tape_device);
- fp = fopen(command, "r");
- fread(&fileheader, sizeof(fileheader), 1, fp);
- pclose(fp);
-
- until fileheader.filename equals the file that is being extracted. At this
- time, the file is extracted using:
-
- sprintf(command, "cpio -icd < %s 2> /dev/null", tape_device);
- system(command);
-
-
- Care has been taken to make sure that tape_device is the correct device in
- regards to rewind before/after use.
-
-
- Everything works fine *except* for the command to actually extract the file.
- I am able to add files and headers and move up to the file to extract.
- However, the extract does not want to work for me. The call seems to come
- back clean, but the file is not extract. In fact, the tape remains in the
- same position. When I return to the shell, the tape has not be rewound at this
- point. I can then actually type the cpio command for the extract and it
- will work.
-
- To try and track things down, I changed the extract system call to a
-
- system("sh");
-
- and typed the command by hand at the shell prompt. That didn't work. (Note:
- the other cpio and dd commands work in this shell.)
-
- Something else weird: This program is being developed on a NCR 750 Tower. We
- are running a public doman Korn Shell on this system. Now, if while in the
- above shell, I enter the ksh and type the cpio command by hand, it works.
- Also, if I run the command as "system" call in another program (this is
- done by running the program that does not work to position the tape at the
- correct location and then running this new program) it will extract the file.
-
- The problem appears to be some kind of problem between my program and our
- "/bin/sh" -- but what has got me puzzled. In the early stages of development,
- the program extract part worked fine.
-
- I hope that there's someone out there that can give me some ideas on
- where to start in trying to solve this problem. Any ideas would be
- appreciated.
-
- Thanks,
- Mark
-
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- | |-------------| Application Data Systems | Phone: (601) 393-2046 | |
- | | Mark Parr | 1930-B 1st Commercial Dr. N | Fax: (601) 393-6605 | |
- | |-------------| Southaven, MS 38671 | markp@adsi.vp.com | |
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-