mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
As Andrew suggested, make smbrun return a fd for a deleted file which can then
be read.
Jeremy.
(This used to be commit e7d59d6de8
)
This commit is contained in:
@ -368,21 +368,15 @@ char *file_pload(char *syscmd, size_t *size)
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
load a file into memory
|
||||
****************************************************************************/
|
||||
char *file_load(char *fname, size_t *size)
|
||||
load a file into memory from a fd.
|
||||
****************************************************************************/
|
||||
|
||||
char *fd_load(int fd, size_t *size)
|
||||
{
|
||||
int fd;
|
||||
SMB_STRUCT_STAT sbuf;
|
||||
char *p;
|
||||
|
||||
if (!fname || !*fname) return NULL;
|
||||
|
||||
fd = open(fname,O_RDONLY);
|
||||
if (fd == -1) return NULL;
|
||||
|
||||
if (sys_fstat(fd, &sbuf) != 0) return NULL;
|
||||
|
||||
p = (char *)malloc(sbuf.st_size+1);
|
||||
@ -394,13 +388,31 @@ char *file_load(char *fname, size_t *size)
|
||||
}
|
||||
p[sbuf.st_size] = 0;
|
||||
|
||||
close(fd);
|
||||
|
||||
if (size) *size = sbuf.st_size;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
load a file into memory
|
||||
****************************************************************************/
|
||||
char *file_load(char *fname, size_t *size)
|
||||
{
|
||||
int fd;
|
||||
char *p;
|
||||
|
||||
if (!fname || !*fname) return NULL;
|
||||
|
||||
fd = open(fname,O_RDONLY);
|
||||
if (fd == -1) return NULL;
|
||||
|
||||
p = fd_load(fd, size);
|
||||
|
||||
close(fd);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
parse a buffer into lines
|
||||
@ -459,6 +471,22 @@ char **file_lines_load(char *fname, int *numlines, BOOL convert)
|
||||
return file_lines_parse(p, size, numlines, convert);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
load a fd into memory and return an array of pointers to lines in the file
|
||||
must be freed with file_lines_free(). If convert is true calls unix_to_dos on
|
||||
the list.
|
||||
****************************************************************************/
|
||||
char **fd_lines_load(int fd, int *numlines, BOOL convert)
|
||||
{
|
||||
char *p;
|
||||
size_t size;
|
||||
|
||||
p = fd_load(fd, &size);
|
||||
if (!p) return NULL;
|
||||
|
||||
return file_lines_parse(p, size, numlines, convert);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
load a pipe into memory and return an array of pointers to lines in the data
|
||||
|
Reference in New Issue
Block a user