Too straight forward Jim I want that last fs block even if the fs has a silly 2 byte block size
Code:
#include <stdio.h>
#include <errno.h>
#include <sys/vfs.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define MAX_PHYSIO 128 /* size of phsyical io in blocks */
char *outbuf;
struct statfs vbuf;
int main() {
int tickle = 5; /* how often to print progress based on number of writes */
int count = 0;
int fd;
long outsize;
int j;
/* create the file */
if( (fd = open("fill.all", O_CREAT | O_WRONLY)) < 0 )
{
perror("fill.all: ");
exit(fd);
}
/* get filesystem info */
fstatfs( fd, &vbuf);
outsize = vbuf.f_bsize * MAX_PHYSIO; /* calculate output size */
outbuf = (char *) malloc(outsize); /* allocate the buffer */
printf("Free blocks: %d\nOutput Buffer size: %d\n", vbuf.f_bfree, outsize);
j = tickle ;
while( write(fd, outbuf, outsize) > 0 )
{
if ( j == 0)
{
fstatfs(fd ,&vbuf);
printf("Blocks left: %d\n", vbuf.f_bfree);
j = tickle;
}
else
j--;
}
fstatfs( fd, &vbuf);
if (vbuf.f_bfree > 0)
write(fd, outbuf, vbuf.f_bfree);
printf("done\n");
}
For extra fun you can add an fsync() call after the last write call. Could lock up your system for a bit ... depending on your RAID type and implementation
i want to write a server process in the sco unix 505.The server process will fork multi-child-processes when it first starts.once parent process listen and accept any connect from client,it will transfer the connected sockfd to any free child process and child process will read client request from... (4 Replies)
Hey people i'm very new to linux. I just put a extra 200 gig maxtor HD in my computer. Linux can tell it's there...but it says it cant mount it. How do i mount it manually?
thanks,
John (2 Replies)
Hi,
I am having an input file which contains a group of words,if one specific word comes which goes to next line.
example:
input file===>
shashi country= india comapny= none shashi shashi company= NONE shashi=my name
output===>
shashi country= india comapny= none
shashi
shashi... (6 Replies)
Hello..
I want to take back up from server to local machine and i dont know how to do it using cron and sftp . I can do it by manually typing password in the terminal and taking the back up. How to create a 'backup.sh' file for doing all the back up process and shut down automatically after... (1 Reply)
I need help with the following.
1) Write a program in any language that takes a single integer array parameter and returns the decimal average of the input values.
2) Write a program, in any language, that prints the integers from 1 to 10, along with a cumulative sum of the integers printed... (1 Reply)
I am hoping someone can give me a good free web resource for writing code to compile a binary executable. I am getting fairly decent at writing shell script, are the .f files just shell scripts? Also, I don't know where to begin on the makefiles. The reason I am curious is because I have been... (6 Replies)
I'm planning on using two Linux OS's alongside win 7, one being Fedora KDE 30.
So to prepare for the install I partitioned my harddrive using the Minitool Partition Wizard. I have a 320 GB hdd, so I nade one partiotion about 80 GB forFedora and then left about 70 GB as unused, to later... (2 Replies)
Discussion started by: AndersA
2 Replies
LEARN ABOUT OSX
mpi_pack
MPI_Pack(3OpenMPI)MPI_Pack(3OpenMPI)NAME
MPI_Pack - Packs data of a given datatype into contiguous memory.
SYNTAX C Syntax
#include <mpi.h>
int MPI_Pack(void *inbuf, int incount, MPI_Datatype datatype,
void *outbuf, int outsize, int *position, MPI_Comm comm)
Fortran Syntax
INCLUDE 'mpif.h'
MPI_PACK(INBUF, INCOUNT, DATATYPE, OUTBUF,OUTSIZE, POSITION,
COMM, IERROR)
<type> INBUF(*), OUTBUF(*)
INTEGER INCOUNT, DATATYPE, OUTSIZE, POSITION, COMM, IERROR
C++ Syntax
#include <mpi.h>
void Datatype::Pack(const void* inbuf, int incount, void *outbuf,
int outsize, int& position, const Comm &comm) const
INPUT PARAMETERS
inbuf Input buffer start (choice).
incount Number of input data items (integer).
datatype Datatype of each input data item (handle).
outsize Output buffer size, in bytes (integer).
comm Communicator for packed message (handle).
INPUT /OUTPUT PARAMETER
position Current position in buffer, in bytes (integer).
OUTPUT PARAMETERS
outbuf Output buffer start (choice).
IERROR Fortran only: Error status (integer).
DESCRIPTION
Packs the message in the send buffer specified by inbuf, incount, datatype into the buffer space specified by outbuf and outsize. The input
buffer can be any communication buffer allowed in MPI_Send. The output buffer is a contiguous storage area containing outsize bytes, start-
ing at the address outbuf (length is counted in bytes, not elements, as if it were a communication buffer for a message of type
MPI_Packed).
The input value of position is the first location in the output buffer to be used for packing. position is incremented by the size of the
packed message, and the output value of position is the first location in the output buffer following the locations occupied by the packed
message. The comm argument is the communicator that will be subsequently used for sending the packed message.
Example: An example using MPI_Pack:
int position, i, j, a[2];
char buff[1000];
....
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
if (myrank == 0)
{
/ * SENDER CODE */
position = 0;
MPI_Pack(&i, 1, MPI_INT, buff, 1000, &position, MPI_COMM_WORLD);
MPI_Pack(&j, 1, MPI_INT, buff, 1000, &position, MPI_COMM_WORLD);
MPI_Send( buff, position, MPI_PACKED, 1, 0, MPI_COMM_WORLD);
}
else /* RECEIVER CODE */
MPI_Recv( a, 2, MPI_INT, 0, 0, MPI_COMM_WORLD)
}
ERRORS
Almost all MPI routines return an error value; C routines as the value of the function and Fortran routines in the last argument. C++ func-
tions do not return errors. If the default error handler is set to MPI::ERRORS_THROW_EXCEPTIONS, then on error the C++ exception mechanism
will be used to throw an MPI:Exception object.
Before the error value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job, except for
I/O function errors. The error handler may be changed with MPI_Comm_set_errhandler; the predefined error handler MPI_ERRORS_RETURN may be
used to cause error values to be returned. Note that MPI does not guarantee that an MPI program can continue past an error.
SEE ALSO
MPI_Unpack
MPI_Pack_size
Open MPI 1.2 September 2006 MPI_Pack(3OpenMPI)