Sponsored Content
Full Discussion: tar and fifos
Top Forums UNIX for Advanced & Expert Users tar and fifos Post 302086134 by blowtorch on Tuesday 22nd of August 2006 10:48:20 AM
Old 08-22-2006
Well, see, there you have a problem. Cause tar needs filenames. Atleast the Solaris tar barfed saying something like that... If you just want to write to an output file, why not use dd?
--EDIT
Just tried tar on Linux and it failed too. Here's the simulation that I am using. It may not be anywhere near what you have, but its the closest that I'm gonna get.
Code:
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<errno.h>

int main() {

        int fd,i;
        char a[2];

        fd=open("/tmp/pipe",O_WRONLY);
        if(fd==-1) {
                fprintf(stderr,"Error opening pipe: %d",errno);
                exit(-1);
        }
        for(i=65;i<91;i++) {
                sprintf(a,"%c",i);
                write(fd,&a[0],sizeof(char));
        }
        close(fd);
}

And here's how I am using dd:
Code:
$ ./a.out &
[1] 5795
$ dd if=/tmp/pipe bs=1
ABCDEFGHIJKLMNOPQRSTUVWXYZ26+0 records in
26+0 records out
26 bytes (26 B) copied, 0.000537 seconds, 48.4 kB/s
[1]+  Done                    ./a.out

Cheers

Last edited by blowtorch; 08-22-2006 at 12:03 PM..
 

10 More Discussions You Might Find Interesting

1. Programming

Praying for help: FIFOs, IPC

omg i need help so bad. I've been working on a school project for what seems like an eternity and i'm close to deadline. Using FIFO's (i ahve to) to communicate between parent and child proc's. Right now I'm stuck on a read/write. fifomsg is a struct with int length and char message fields. ... (5 Replies)
Discussion started by: Funktar
5 Replies

2. Programming

forks, ipc, fifos, update issues...

Hi, so I've got this program("main") that fork executes another ("user"). These programs communicate through fifos. One communication is a spawn call, where user passes an executable, main forks and executes it. So, I'm keeping track of all my processes using a task table. After the fork (for... (6 Replies)
Discussion started by: Funktar
6 Replies

3. Linux

A little help understanding FIFOs?

This isn't strictly a Linux question, but... I've been working on a project to archive some streaming media for time shifting using 'mplayer' and have been using FIFOs to archive in Ogg Vorbis format: mkfifo program_name.wav (mplayer -ao pcm -aofile program_name.wav &)... (0 Replies)
Discussion started by: deckard
0 Replies

4. UNIX for Advanced & Expert Users

UNIX domain sockets vs FIFOs

Is there a performance advantage of one of these over the other? Obviously, it makes no sense to use normal TCP sockets or UDP sockets w/ the overhead they carry. But what about UNIX domain sockets vs FIFOs? I'd think they'd be very similar, in terms of performance and in terms of how they're... (2 Replies)
Discussion started by: mgessner
2 Replies

5. UNIX for Advanced & Expert Users

How to create a Tar of multiple Files in Unix and FTP the tar to Windows.

Hi, On my Unix Server in my directory, I have 70 files distributed in the following directories (which have several other files too). These files include C Source Files, Shell Script Source Files, Binary Files, Object Files. a) /usr/users/oracle/bin b) /usr/users/oracle... (1 Reply)
Discussion started by: marconi
1 Replies

6. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

7. Programming

kill() function problem in client-server ipc message using 2 FIFOs

I want to have a message send & receive through 2 uni-direction FIFO Flow of data FIFO1 stdin--->parent(client) writefd--->FIFO1-->child(server) readfd FIFO2 child(server) writefd2---->FIFO2--->parent(client) readfd2--->stdout I need to have boundary structed message... (3 Replies)
Discussion started by: ouou
3 Replies

8. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

9. UNIX for Dummies Questions & Answers

Do I need to extract the entire tar file to confirm the tar folder is fine?

I would like to confirm my file.tar is been tar-ed correctly before I remove them. But I have very limited disc space to untar it. Can I just do the listing instead of actual extract it? Can I say confirm folder integrity if the listing is sucessful without problem? tar tvf file1.tar ... (1 Reply)
Discussion started by: vivien_chu
1 Replies

10. AIX

Tar - pre-checking before making the Tar file

Coming from this thread, just wondering if there is an option to check if the Tar of the files/directory will be without any file-errors without actually making the tar. Scenario: Let's say you have a directory of 20GB, but you don't have the space to make Tar file at the moment, and you want... (14 Replies)
Discussion started by: filosophizer
14 Replies
tar_open(3)							  C Library Calls						       tar_open(3)

NAME
tar_open, tar_close - access a tar archive via a handle SYNOPSIS
#include <libtar.h> int tar_open(TAR **t, char *pathname, tartype_t *type, int oflags, int mode, int options); int tar_fdopen(TAR **t, int fd, char *pathname, tartype_t *type, int oflags, int mode, int options); int tar_fd(TAR *t");" int tar_close(TAR *t");" VERSION
This man page documents version 1.2 of libtar. DESCRIPTION
The tar_open() function opens a tar archive file corresponding to the filename named by the pathname argument. The oflags argument must be either O_RDONLY or O_WRONLY. The type argument specifies the access methods for the given file type. The tartype_t structure has members named openfunc, closefunc, readfunc() and writefunc(), which are pointers to the functions for opening, closing, reading, and writing the file, respectively. If type is NULL, the file type defaults to a normal file, and the standard open(), close(), read(), and write() functions are used. The options argument is a logical-or'ed combination of zero or more of the following: TAR_GNU Use GNU extensions. TAR_VERBOSE Send status messages to stdout. TAR_NOOVERWRITE Do not overwrite pre-existing files. TAR_IGNORE_EOT Skip all-zero blocks instead of treating them as EOT. TAR_IGNORE_MAGIC Do not validate the magic field in file headers. TAR_CHECK_VERSION Check the version field in file headers. (This field is normally ignored.) TAR_IGNORE_CRC Do not validate the CRC of file headers. The tar_open() function allocates memory for a TAR handle, and a pointer to the allocated memory is saved in the location specified by t. The TAR handle may be passed to other libtar calls to modify the opened tar archive. The TAR handle maintains all of the information about the open tar archive, including the archive type, options, and oflags selected when tar_open() was called. The TAR handle generated by tar_open() contains a file header structure. When reading a tar archive, this structure contains the last file header read from the tar archive. When writing a tar archive, this structure is used as a staging area to construct the next file header to be written to the archive. In addition, the TAR handle contains a hash table which is used to keep track of the device and inode infor- mation for each file which gets written to the tar archive. This is used to detect hard links, so that files do not need to be duplicated in the archive. The tar_fdopen() function is identical to the tar_open() function, except that fd is used as the previously-opened file descriptor for the tar file instead of calling type->openfunc() to open the file. The tar_fd() function returns the file descriptor associated with the TAR handle t. The tar_close() function closes the file descriptor associated with the TAR handle t and frees all dynamically-allocated memory. RETURN VALUE
The tar_open(), tar_fdopen(), and tar_close() functions return 0 on success. On failure, they return -1 and set errno. The tar_fd() function returns the file descriptor associated with the TAR handle t. ERRORS
tar_open() will fail if: EINVAL The oflags argument was something other than O_RDONLY or O_WRONLY. In addition, tar_open() and tar_close() may fail if it cannot allocate memory using calloc(), or if the open or close functions for the specified tar archive type fail. SEE ALSO
open(2), close(2), calloc(3) University of Illinois Jan 2001 tar_open(3)
All times are GMT -4. The time now is 03:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy