* Does Linux has File Stream mapping support...?
@ 2005-11-18 10:38 Arijit Das
2005-11-18 20:14 ` James Courtier-Dutton
2005-11-19 4:27 ` Herbert Xu
0 siblings, 2 replies; 12+ messages in thread
From: Arijit Das @ 2005-11-18 10:38 UTC (permalink / raw)
To: linux-kernel
Is it possible to have File Stream Mapping in Linux? What I mean is
this...
FILE * fp1 = fopen("/foo", "w");
FILE * fp2 = fopen("/bar", "w");
FILE * fp_common = <Stream_Mapping_Func>(fp1, fp2);
fprint(fp_common, "This should be written to both files ... /foo and
/bar");
So, what I am looking for is anything written to "fp_common" should
actually be written to the streams fp1 and fp2.
Does Linux support this any way? Is there any way to achieve this...? Is
there anything like <Stream_Mapping_Func>(above) ...?
Do pardon me if you feel that it is a wrong Forum to ask this question
but I tried everywhere else and thought that implementers would best
know about it, if at all anything like that exists.
Thanks,
Arijit
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Does Linux has File Stream mapping support...?
[not found] <5abPs-7Da-41@gated-at.bofh.it>
@ 2005-11-18 12:30 ` Bodo Eggert
0 siblings, 0 replies; 12+ messages in thread
From: Bodo Eggert @ 2005-11-18 12:30 UTC (permalink / raw)
To: Arijit Das, linux-kernel
Arijit Das <Arijit.Das@synopsys.com> wrote:
> Is it possible to have File Stream Mapping in Linux? What I mean is
> this...
>
> FILE * fp1 = fopen("/foo", "w");
> FILE * fp2 = fopen("/bar", "w");
> FILE * fp_common = <Stream_Mapping_Func>(fp1, fp2);
>
> fprint(fp_common, "This should be written to both files ... /foo and
> /bar");
It's a userspace problem. man "tee".
Doing this in the kernel would be horrible.
--
Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF
verbreiteten Lügen zu sabotieren.
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: Does Linux has File Stream mapping support...?
@ 2005-11-18 12:51 Arijit Das
2005-11-18 12:59 ` Bas Westerbaan
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Arijit Das @ 2005-11-18 12:51 UTC (permalink / raw)
To: 7eggert, linux-kernel
Ye...I know of tee.
But the issue here is I have a HUGE Compiler (an Simulation tool) in which thousands of places there are "printf" statements to print messages to STDOUT stream. Now, a requirement came up which needs all those messages thrown to STDOUT also to be logged in a LOGFILE (in addition to STDOUT). Yes, this can be done through tee...but the usage model of the compiler doesn't leave that possibility open for me.
So, am looking for a solution inside the Compiler code.
Thanks,
Arijit
-----Original Message-----
From: Bodo Eggert [mailto:harvested.in.lkml@7eggert.dyndns.org]
Sent: Friday, November 18, 2005 6:00 PM
To: Arijit Das; linux-kernel@vger.kernel.org
Subject: Re: Does Linux has File Stream mapping support...?
Arijit Das <Arijit.Das@synopsys.com> wrote:
> Is it possible to have File Stream Mapping in Linux? What I mean is
> this...
>
> FILE * fp1 = fopen("/foo", "w");
> FILE * fp2 = fopen("/bar", "w");
> FILE * fp_common = <Stream_Mapping_Func>(fp1, fp2);
>
> fprint(fp_common, "This should be written to both files ... /foo and
> /bar");
It's a userspace problem. man "tee".
Doing this in the kernel would be horrible.
--
Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF
verbreiteten Lügen zu sabotieren.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Does Linux has File Stream mapping support...?
2005-11-18 12:51 Does Linux has File Stream mapping support...? Arijit Das
@ 2005-11-18 12:59 ` Bas Westerbaan
2005-11-18 13:01 ` Bas Westerbaan
2005-11-18 19:06 ` Bill Davidsen
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: Bas Westerbaan @ 2005-11-18 12:59 UTC (permalink / raw)
To: Arijit Das; +Cc: 7eggert, linux-kernel
Maybe an (ugly) way around it would be to simply use a parent process
which captures the stdout of your compiler and writes it to the log
file and prints it to its own stdout.
On 11/18/05, Arijit Das <Arijit.Das@synopsys.com> wrote:
> Ye...I know of tee.
>
> But the issue here is I have a HUGE Compiler (an Simulation tool) in which thousands of places there are "printf" statements to print messages to STDOUT stream. Now, a requirement came up which needs all those messages thrown to STDOUT also to be logged in a LOGFILE (in addition to STDOUT). Yes, this can be done through tee...but the usage model of the compiler doesn't leave that possibility open for me.
>
> So, am looking for a solution inside the Compiler code.
>
> Thanks,
> Arijit
>
> -----Original Message-----
> From: Bodo Eggert [mailto:harvested.in.lkml@7eggert.dyndns.org]
> Sent: Friday, November 18, 2005 6:00 PM
> To: Arijit Das; linux-kernel@vger.kernel.org
> Subject: Re: Does Linux has File Stream mapping support...?
>
> Arijit Das <Arijit.Das@synopsys.com> wrote:
>
> > Is it possible to have File Stream Mapping in Linux? What I mean is
> > this...
> >
> > FILE * fp1 = fopen("/foo", "w");
> > FILE * fp2 = fopen("/bar", "w");
> > FILE * fp_common = <Stream_Mapping_Func>(fp1, fp2);
> >
> > fprint(fp_common, "This should be written to both files ... /foo and
> > /bar");
>
> It's a userspace problem. man "tee".
>
> Doing this in the kernel would be horrible.
>
> --
> Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF
> verbreiteten Lügen zu sabotieren.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
Bas Westerbaan
http://blog.w-nz.com/
GPG Public Keys: http://w-nz.com/keys/bas.westerbaan.asc
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Does Linux has File Stream mapping support...?
2005-11-18 12:59 ` Bas Westerbaan
@ 2005-11-18 13:01 ` Bas Westerbaan
2005-11-18 14:28 ` Dick Streefland
0 siblings, 1 reply; 12+ messages in thread
From: Bas Westerbaan @ 2005-11-18 13:01 UTC (permalink / raw)
To: Arijit Das; +Cc: 7eggert, linux-kernel
Or you could - more cleanly - do a replace through all your source
files (with an editor or a tool) which replaces printf with log (or
something similar) and implement that function with the code to write
to the log file and to stdout.
On 11/18/05, Bas Westerbaan <bas.westerbaan@gmail.com> wrote:
> Maybe an (ugly) way around it would be to simply use a parent process
> which captures the stdout of your compiler and writes it to the log
> file and prints it to its own stdout.
>
>
> On 11/18/05, Arijit Das <Arijit.Das@synopsys.com> wrote:
> > Ye...I know of tee.
> >
> > But the issue here is I have a HUGE Compiler (an Simulation tool) in which thousands of places there are "printf" statements to print messages to STDOUT stream. Now, a requirement came up which needs all those messages thrown to STDOUT also to be logged in a LOGFILE (in addition to STDOUT). Yes, this can be done through tee...but the usage model of the compiler doesn't leave that possibility open for me.
> >
> > So, am looking for a solution inside the Compiler code.
> >
> > Thanks,
> > Arijit
> >
> > -----Original Message-----
> > From: Bodo Eggert [mailto:harvested.in.lkml@7eggert.dyndns.org]
> > Sent: Friday, November 18, 2005 6:00 PM
> > To: Arijit Das; linux-kernel@vger.kernel.org
> > Subject: Re: Does Linux has File Stream mapping support...?
> >
> > Arijit Das <Arijit.Das@synopsys.com> wrote:
> >
> > > Is it possible to have File Stream Mapping in Linux? What I mean is
> > > this...
> > >
> > > FILE * fp1 = fopen("/foo", "w");
> > > FILE * fp2 = fopen("/bar", "w");
> > > FILE * fp_common = <Stream_Mapping_Func>(fp1, fp2);
> > >
> > > fprint(fp_common, "This should be written to both files ... /foo and
> > > /bar");
> >
> > It's a userspace problem. man "tee".
> >
> > Doing this in the kernel would be horrible.
> >
> > --
> > Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF
> > verbreiteten Lügen zu sabotieren.
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
> >
>
>
>
> --
> Bas Westerbaan
> http://blog.w-nz.com/
> GPG Public Keys: http://w-nz.com/keys/bas.westerbaan.asc
>
--
Bas Westerbaan
http://blog.w-nz.com/
GPG Public Keys: http://w-nz.com/keys/bas.westerbaan.asc
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Does Linux has File Stream mapping support...?
2005-11-18 13:01 ` Bas Westerbaan
@ 2005-11-18 14:28 ` Dick Streefland
0 siblings, 0 replies; 12+ messages in thread
From: Dick Streefland @ 2005-11-18 14:28 UTC (permalink / raw)
To: linux-kernel
Bas Westerbaan <bas.westerbaan@gmail.com> wrote:
| Or you could - more cleanly - do a replace through all your source
| files (with an editor or a tool) which replaces printf with log (or
| something similar) and implement that function with the code to write
| to the log file and to stdout.
Simpler, but somewhat uglier, is to define a macro in one of your
header files (to be included after <stdio.h>):
#define printf(fmt, ...) { printf(fmt, ## __VA_ARGS__); fprintf(log_fp, fmt, ## __VA_ARGS__); }
--
Dick Streefland //// Altium BV
dick.streefland@altium.nl (@ @) http://www.altium.com
--------------------------------oOO--(_)--OOo---------------------------
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Does Linux has File Stream mapping support...?
2005-11-18 12:51 Does Linux has File Stream mapping support...? Arijit Das
2005-11-18 12:59 ` Bas Westerbaan
@ 2005-11-18 19:06 ` Bill Davidsen
2005-11-18 19:39 ` Lennart Sorensen
2005-11-21 9:18 ` Jim Nance
3 siblings, 0 replies; 12+ messages in thread
From: Bill Davidsen @ 2005-11-18 19:06 UTC (permalink / raw)
To: Arijit Das, Linux Kernel Mailing List
Arijit Das wrote:
> Ye...I know of tee.
>
> But the issue here is I have a HUGE Compiler (an Simulation tool) in which thousands of places there are "printf" statements to print messages to STDOUT stream. Now, a requirement came up which needs all those messages thrown to STDOUT also to be logged in a LOGFILE (in addition to STDOUT). Yes, this can be done through tee...but the usage model of the compiler doesn't leave that possibility open for me.
>
> So, am looking for a solution inside the Compiler code.
1 - using script allows stdout and file capture, might help
2 - redirect to a fifo, hang tee off the fifo
--
-bill davidsen (davidsen@tmr.com)
"The secret to procrastination is to put things off until the
last possible moment - but no longer" -me
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Does Linux has File Stream mapping support...?
2005-11-18 12:51 Does Linux has File Stream mapping support...? Arijit Das
2005-11-18 12:59 ` Bas Westerbaan
2005-11-18 19:06 ` Bill Davidsen
@ 2005-11-18 19:39 ` Lennart Sorensen
2005-11-21 9:18 ` Jim Nance
3 siblings, 0 replies; 12+ messages in thread
From: Lennart Sorensen @ 2005-11-18 19:39 UTC (permalink / raw)
To: Arijit Das; +Cc: 7eggert, linux-kernel
On Fri, Nov 18, 2005 at 06:21:59PM +0530, Arijit Das wrote:
> Ye...I know of tee.
>
> But the issue here is I have a HUGE Compiler (an Simulation tool) in which thousands of places there are "printf" statements to print messages to STDOUT stream. Now, a requirement came up which needs all those messages thrown to STDOUT also to be logged in a LOGFILE (in addition to STDOUT). Yes, this can be done through tee...but the usage model of the compiler doesn't leave that possibility open for me.
>
> So, am looking for a solution inside the Compiler code.
Replace all printf's with a MACRO that expands to two different printf's
one to stdout and one to a log. Not pretty though I suppose.
Or you make your own function to replace all printf's with that does the
output and any logging you want done.
Len Sorensen
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Does Linux has File Stream mapping support...?
2005-11-18 10:38 Arijit Das
@ 2005-11-18 20:14 ` James Courtier-Dutton
2005-11-18 20:41 ` linux-os (Dick Johnson)
2005-11-19 4:27 ` Herbert Xu
1 sibling, 1 reply; 12+ messages in thread
From: James Courtier-Dutton @ 2005-11-18 20:14 UTC (permalink / raw)
To: Arijit Das; +Cc: linux-kernel
Arijit Das wrote:
> Is it possible to have File Stream Mapping in Linux? What I mean is
> this...
>
> FILE * fp1 = fopen("/foo", "w");
> FILE * fp2 = fopen("/bar", "w");
> FILE * fp_common = <Stream_Mapping_Func>(fp1, fp2);
>
> fprint(fp_common, "This should be written to both files ... /foo and
> /bar");
>
> So, what I am looking for is anything written to "fp_common" should
> actually be written to the streams fp1 and fp2.
>
> Does Linux support this any way? Is there any way to achieve this...? Is
> there anything like <Stream_Mapping_Func>(above) ...?
>
> Do pardon me if you feel that it is a wrong Forum to ask this question
> but I tried everywhere else and thought that implementers would best
> know about it, if at all anything like that exists.
>
> Thanks,
> Arijit
> -
Why not just output to a file, and then use "tail -f filename"
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Does Linux has File Stream mapping support...?
2005-11-18 20:14 ` James Courtier-Dutton
@ 2005-11-18 20:41 ` linux-os (Dick Johnson)
0 siblings, 0 replies; 12+ messages in thread
From: linux-os (Dick Johnson) @ 2005-11-18 20:41 UTC (permalink / raw)
To: James Courtier-Dutton; +Cc: Arijit Das, Linux kernel
On Fri, 18 Nov 2005, James Courtier-Dutton wrote:
> Arijit Das wrote:
>> Is it possible to have File Stream Mapping in Linux? What I mean is
>> this...
>>
>> FILE * fp1 = fopen("/foo", "w");
>> FILE * fp2 = fopen("/bar", "w");
>> FILE * fp_common = <Stream_Mapping_Func>(fp1, fp2);
>>
>> fprint(fp_common, "This should be written to both files ... /foo and
>> /bar");
>>
>> So, what I am looking for is anything written to "fp_common" should
>> actually be written to the streams fp1 and fp2.
>>
>> Does Linux support this any way? Is there any way to achieve this...? Is
>> there anything like <Stream_Mapping_Func>(above) ...?
>>
>> Do pardon me if you feel that it is a wrong Forum to ask this question
>> but I tried everywhere else and thought that implementers would best
>> know about it, if at all anything like that exists.
>>
>> Thanks,
>> Arijit
>> -
>
> Why not just output to a file, and then use "tail -f filename"
I just did a 'google' to see if anybody had such a function.
It looks like he's going to have to write his own because there
isn't anything like that yet.
I don't know what you'd use it for because it's easy to
make two or more...
fputs(buffer, file1);
fputs(buffer, file2);
fputs(buffer, file3);
...etc.
Also, if he's using terminal I/O scripts, he should investigate
`tee`.
Maybe he thinks that stuff would get written simultaneously if
there were any such function!
Arijit, computers can't walk and chew gum at the same time.
Nothing gets written simultaneously! Just chose the order at
which you would like to have buffered I/O occur and, except
for 'stderr' even that order isn't guaranteed!
Cheers,
Dick Johnson
Penguin : Linux version 2.6.13.4 on an i686 machine (5589.54 BogoMips).
Warning : 98.36% of all statistics are fiction.
.
****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.
Thank you.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Does Linux has File Stream mapping support...?
2005-11-18 10:38 Arijit Das
2005-11-18 20:14 ` James Courtier-Dutton
@ 2005-11-19 4:27 ` Herbert Xu
1 sibling, 0 replies; 12+ messages in thread
From: Herbert Xu @ 2005-11-19 4:27 UTC (permalink / raw)
To: Arijit Das; +Cc: linux-kernel
Arijit Das <Arijit.Das@synopsys.com> wrote:
> Is it possible to have File Stream Mapping in Linux? What I mean is
> this...
>
> FILE * fp1 = fopen("/foo", "w");
> FILE * fp2 = fopen("/bar", "w");
> FILE * fp_common = <Stream_Mapping_Func>(fp1, fp2);
>
> fprint(fp_common, "This should be written to both files ... /foo and
> /bar");
Yes, as long as you're using glibc you can implement this using
"Custom Streams". Look for the function fopencookie in your glibc
documentation.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Does Linux has File Stream mapping support...?
2005-11-18 12:51 Does Linux has File Stream mapping support...? Arijit Das
` (2 preceding siblings ...)
2005-11-18 19:39 ` Lennart Sorensen
@ 2005-11-21 9:18 ` Jim Nance
3 siblings, 0 replies; 12+ messages in thread
From: Jim Nance @ 2005-11-21 9:18 UTC (permalink / raw)
To: Arijit Das; +Cc: 7eggert, linux-kernel
On Fri, Nov 18, 2005 at 06:21:59PM +0530, Arijit Das wrote:
> Ye...I know of tee.
>
> But the issue here is I have a HUGE Compiler (an Simulation tool)
> in which thousands of places there are "printf" statements to print
> messages to STDOUT stream. Now, a requirement came up which needs
> all those messages thrown to STDOUT also to be logged in a LOGFILE
> (in addition to STDOUT). Yes, this can be done through tee...but
> the usage model of the compiler doesn't leave that possibility open
> for me.
You have the source code for the compiler? Put a call to something
like this at the beginning of main(). I'm leaving out the error handling,
you can write that ;)
void startlogging()
{
pid_t tpid;
int pfd[2];
pipe(pfd);
tpid=fork();
if(tpid==0) {
/* child process */
close(0);
dup2(pfd[0], 0);
close(pfd[0]);
close(pfd[1]);
execl("/usr/bin/tee", "logfile");
} else {
close(1);
dup2(pfd[1], 1);
close(pfd[0]);
close(pfd[1]);
}
}
--
jlnance@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2005-11-21 9:19 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-18 12:51 Does Linux has File Stream mapping support...? Arijit Das
2005-11-18 12:59 ` Bas Westerbaan
2005-11-18 13:01 ` Bas Westerbaan
2005-11-18 14:28 ` Dick Streefland
2005-11-18 19:06 ` Bill Davidsen
2005-11-18 19:39 ` Lennart Sorensen
2005-11-21 9:18 ` Jim Nance
[not found] <5abPs-7Da-41@gated-at.bofh.it>
2005-11-18 12:30 ` Bodo Eggert
-- strict thread matches above, loose matches on Subject: below --
2005-11-18 10:38 Arijit Das
2005-11-18 20:14 ` James Courtier-Dutton
2005-11-18 20:41 ` linux-os (Dick Johnson)
2005-11-19 4:27 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox