Sponsored Content
Top Forums UNIX for Advanced & Expert Users What is the cause of file truncation? Post 85317 by blowtorch on Tuesday 4th of October 2005 02:49:02 PM
Old 10-04-2005
I have observed this on one of our systems too. I tried to simulate this using the following programs:

fop.c - uses fopen and fwrite
Code:
#include<stdio.h>
#include<string.h>
#include<errno.h>

int main() {
        FILE *fp;
        char str[]="test";
        int ret;

        fp=fopen("/mount_pt/testfile","w");
        if(fp==NULL) {
                fprintf(stdout,"errno: %d",errno);
                exit(-1);
        }
        ret=fwrite(str,1,strlen(str),fp);
        fprintf(stdout,"ret of write: %d",ret);
        if(ret==0) {
                fprintf(stdout,"couldnot write! errno: %d",errno);
                exit(-1);
        }
        fclose(fp);
}

op.c - uses open and write
Code:
#include<stdio.h>
#include<fcntl.h>
#include<string.h>
#include<errno.h>

int main() {
        int fd;
        char str[]="test";
        int ret;

        fd=open("/mount_pt/testfile",O_CREAT|O_RDWR,0664);
        if(fd==-1) {
                fprintf(stdout,"errno: %d",errno);
                exit(-1);
        }
        ret=write(fd,str,strlen(str));
        fprintf(stdout,"ret of write: %d",ret);
        if(ret==-1) {
                fprintf(stdout,"couldnot write! errno: %d",errno);
                exit(-1);
        }
        close(fd);
}

I simulated a full filesystem by creating a 4MB filesystem and filling it up. Then ran the op.c and fop.c programs on this. op.c gives an error when trying to 'write'. However, fop.c goes through successfully - fwrite even returns the expected values, but all that is created is a 0 byte file.

This may have something to do with the buffering that is done when 'fwrite'ing - this causes the 'fwrite' to return success, even though 'write' fails.
But this does not really sound right.. could any one shed light on this?

Last edited by blowtorch; 10-04-2005 at 03:57 PM..
 

10 More Discussions You Might Find Interesting

1. Solaris

solaris 2.5.1 /usr/ucb/ps truncation problems

we aheva couple of old sun OS boxes, that we are trying to parse /usr/ucb/ps output. However it seems that something is occuring that is causeing th output of "/usr/ucb/ps -auxwww" to cut short the process name, whereas "ps -eaf" can display the entire process name. It will work for a while... (2 Replies)
Discussion started by: adralph
2 Replies

2. UNIX for Advanced & Expert Users

truncation when vi a file

Hi, I'm using the vi that comes with Solaris 2.8. When vi a file with lines that have long continuous characters e.g. more than 256 chars, these lines got truncated. This is a known limitation of the out of the box Solaris vi, and there is a suggestion to get another vi. Is there an... (0 Replies)
Discussion started by: selur-xinu
0 Replies

3. AIX

PS output truncation in AIX

folks; i need help with a truncation problem in AIX when running "ps" command. when i run ps in SUN, i got the full output but when i run it in AIX the output is truncated. is there any arguments i can pass to give longer output so i can overcome the issue? here's the details:(please note the... (2 Replies)
Discussion started by: moe2266
2 Replies

4. UNIX for Advanced & Expert Users

STDOUT truncation

Operating system - Solaris 8, Korn shell, xterm Command /usr/proc/bin/ptree outputs the process tree exactly as I want with all detail However, /usr/proc/bin/ptree | more truncates the process descriptions at an 80 character point. If the process tree has marched enough to the right,... (3 Replies)
Discussion started by: JerryHone
3 Replies

5. UNIX for Advanced & Expert Users

Syslog Truncation / Size Limit?

I searched and could not find an answer to this, and am having difficulty, so I would appreciate any assistance that can be offered. We're experiencing logs that are having all characters after the 850th one written being truncated. I am wondering if there is a default limit to the syslog... (1 Reply)
Discussion started by: Puck
1 Replies

6. Post Here to Contact Site Administrators and Moderators

SCO 5.6 File truncation

Sir, my apologies for not being able to correspond for a long time. I am running an appliction in SCO 5.6. If the records are more than one lakh, the output file is getting truncated to one lakh. Please help me in rectifying the issue whereby it allows creation of output with more than one lakh... (0 Replies)
Discussion started by: chssastry
0 Replies

7. Filesystems, Disks and Memory

SCO 5.6 + file truncation

Sir, my apologies for I had put this question in a different forum earlier. I am running an appliction in SCO 5.6. If the records are more than one lakh, the output file is getting truncated to one lakh. Please help me in rectifying the issue whereby it allows creation of output with more than... (0 Replies)
Discussion started by: chssastry
0 Replies

8. UNIX for Advanced & Expert Users

Truncation Occurs When Outputting Shell Script to stderr

Operating System: Solaris 10, Shell We are outputting the results of our scripts to the stderr file. However we have encountered a problem where some of the lines in the file are truncated. Is there a way to increase the terminal or column size within the script so that this does not... (4 Replies)
Discussion started by: fazzasx
4 Replies

9. UNIX and Linux Applications

Space truncation

HI All- We have script like the followinga='h1 ' b='12434 ' c=' fagkasdbkZ<M' output=$a$b$c echo $output > /home/dsomasun/fil_concat.txtBut in the output file spaces are truncated and Output is coming like the belowh1 1234 fagkasdbkZ<M please advise Please wrap all code,... (4 Replies)
Discussion started by: dhilipans1988
4 Replies

10. Shell Programming and Scripting

Shell script (sh file) logic to compare contents of one file with another file and output to file

Shell script logic Hi I have 2 input files like with file 1 content as (file1) "BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt File 2 contents as fle(2) "BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt I want to get... (22 Replies)
Discussion started by: pottic
22 Replies
SYSTEMD-TMPFILES(8)						 systemd-tmpfiles					       SYSTEMD-TMPFILES(8)

NAME
systemd-tmpfiles, systemd-tmpfiles-setup.service, systemd-tmpfiles-setup-dev.service, systemd-tmpfiles-clean.service, systemd-tmpfiles- clean.timer - Creates, deletes and cleans up volatile and temporary files and directories SYNOPSIS
systemd-tmpfiles [OPTIONS...] [CONFIGFILE...] systemd-tmpfiles-setup.service systemd-tmpfiles-setup-dev.service systemd-tmpfiles-clean.service systemd-tmpfiles-clean.timer DESCRIPTION
systemd-tmpfiles creates, deletes, and cleans up volatile and temporary files and directories, based on the configuration file format and location specified in tmpfiles.d(5). If invoked with no arguments, it applies all directives from all configuration files. If one or more filenames are passed on the command line, only the directives in these files are applied. If only the basename of a configuration file is specified, all configuration directories as specified in tmpfiles.d(5) are searched for a matching file. OPTIONS
The following options are understood: --create If this option is passed, all files and directories marked with f, F, w, d, D, p, L, c, b, m in the configuration files are created or written to. Files and directories marked with z, Z, m have their ownership, access mode and security labels set. --clean If this option is passed, all files and directories with an age parameter configured will be cleaned up. --remove If this option is passed, all files and directories marked with r, R in the configuration files are removed. --boot Also execute lines with an exclamation mark. --prefix=PATH Only apply rules that apply to paths with the specified prefix. This option can be specified multiple times. --exclude-prefix=PATH Ignore rules that apply to paths with the specified prefix. This option can be specified multiple times. --help Prints a short help text and exits. It is possible to combine --create, --clean, and --remove in one invocation. For example, during boot the following command line is executed to ensure that all temporary and volatile directories are removed and created according to the configuration file: systemd-tmpfiles --remove --create EXIT STATUS
On success, 0 is returned, a non-zero failure code otherwise. SEE ALSO
systemd(1), tmpfiles.d(5) systemd 208 SYSTEMD-TMPFILES(8)
All times are GMT -4. The time now is 03:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy