linux-utils: misc const/prototype fixups
This commit is contained in:
parent
af78e8d9e8
commit
3a39c65e3e
@ -67,7 +67,7 @@ Yet the profiling output show they are not significant CPU hogs, so
|
|||||||
we keep them so simple to make them obviously correct.
|
we keep them so simple to make them obviously correct.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void buffer_append(struct buffer *b, char *data, int len)
|
void buffer_append(struct buffer *b, const char *data, int len)
|
||||||
{
|
{
|
||||||
int newsize;
|
int newsize;
|
||||||
char *qdata;
|
char *qdata;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
extern void do_exec(char *);
|
extern void do_exec(const char *);
|
||||||
|
|
||||||
void fix_fds(int fdin, int fdout, int fderr)
|
void fix_fds(int fdin, int fdout, int fderr)
|
||||||
{
|
{
|
||||||
@ -40,7 +40,7 @@ void fix_fds(int fdin, int fdout, int fderr)
|
|||||||
close(fderr);
|
close(fderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_fork_exec(char *cmdline, int *pid, int *stdin_fd, int *stdout_fd,
|
void do_fork_exec(const char *cmdline, int *pid, int *stdin_fd, int *stdout_fd,
|
||||||
int *stderr_fd)
|
int *stderr_fd)
|
||||||
{
|
{
|
||||||
int inpipe[2], outpipe[2], errpipe[2];
|
int inpipe[2], outpipe[2], errpipe[2];
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
void perror_wrapper(char * msg)
|
void perror_wrapper(const char * msg)
|
||||||
{
|
{
|
||||||
int prev=errno;
|
int prev=errno;
|
||||||
perror(msg);
|
perror(msg);
|
||||||
@ -44,7 +44,7 @@ void set_block(int fd)
|
|||||||
fcntl(fd, F_SETFL, fl & ~O_NONBLOCK);
|
fcntl(fd, F_SETFL, fl & ~O_NONBLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_all(int fd, void *buf, int size)
|
int write_all(int fd, const void *buf, int size)
|
||||||
{
|
{
|
||||||
int written = 0;
|
int written = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
int write_all(int fd, void *buf, int size);
|
int write_all(int fd, const void *buf, int size);
|
||||||
int read_all(int fd, void *buf, int size);
|
int read_all(int fd, void *buf, int size);
|
||||||
int copy_fd_all(int fdout, int fdin);
|
int copy_fd_all(int fdout, int fdin);
|
||||||
void set_nonblock(int fd);
|
void set_nonblock(int fd);
|
||||||
|
@ -29,28 +29,28 @@ struct buffer {
|
|||||||
|
|
||||||
void buffer_init(struct buffer *b);
|
void buffer_init(struct buffer *b);
|
||||||
void buffer_free(struct buffer *b);
|
void buffer_free(struct buffer *b);
|
||||||
void buffer_append(struct buffer *b, char *data, int len);
|
void buffer_append(struct buffer *b, const char *data, int len);
|
||||||
void buffer_remove(struct buffer *b, int len);
|
void buffer_remove(struct buffer *b, int len);
|
||||||
int buffer_len(struct buffer *b);
|
int buffer_len(struct buffer *b);
|
||||||
void *buffer_data(struct buffer *b);
|
void *buffer_data(struct buffer *b);
|
||||||
|
|
||||||
|
|
||||||
void do_fork_exec(char *cmdline, int *pid, int *stdin_fd, int *stdout_fd,
|
void do_fork_exec(const char *cmdline, int *pid, int *stdin_fd, int *stdout_fd,
|
||||||
int *stderr_fd);
|
int *stderr_fd);
|
||||||
int peer_server_init(int port);
|
int peer_server_init(int port);
|
||||||
char *peer_client_init(int dom, int port);
|
char *peer_client_init(int dom, int port);
|
||||||
void wait_for_vchan_or_argfd(int max, fd_set * rdset, fd_set * wrset);
|
void wait_for_vchan_or_argfd(int max, fd_set * rdset, fd_set * wrset);
|
||||||
int read_ready_vchan_ext();
|
int read_ready_vchan_ext(void);
|
||||||
int read_all(int fd, void *buf, int size);
|
int read_all(int fd, void *buf, int size);
|
||||||
int read_all_vchan_ext(void *buf, int size);
|
int read_all_vchan_ext(void *buf, int size);
|
||||||
int write_all(int fd, void *buf, int size);
|
int write_all(int fd, const void *buf, int size);
|
||||||
int write_all_vchan_ext(void *buf, int size);
|
int write_all_vchan_ext(void *buf, int size);
|
||||||
int buffer_space_vchan_ext();
|
int buffer_space_vchan_ext(void);
|
||||||
void fix_fds(int fdin, int fdout, int fderr);
|
void fix_fds(int fdin, int fdout, int fderr);
|
||||||
void set_nonblock(int fd);
|
void set_nonblock(int fd);
|
||||||
void set_block(int fd);
|
void set_block(int fd);
|
||||||
|
|
||||||
int get_server_socket(char *);
|
int get_server_socket(const char *);
|
||||||
int do_accept(int s);
|
int do_accept(int s);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -60,7 +60,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int flush_client_data(int fd, int client_id, struct buffer *buffer);
|
int flush_client_data(int fd, int client_id, struct buffer *buffer);
|
||||||
int write_stdin(int fd, int client_id, char *data, int len,
|
int write_stdin(int fd, int client_id, const char *data, int len,
|
||||||
struct buffer *buffer);
|
struct buffer *buffer);
|
||||||
void set_nonblock(int fd);
|
void set_nonblock(int fd);
|
||||||
int fork_and_flush_stdin(int fd, struct buffer *buffer);
|
int fork_and_flush_stdin(int fd, struct buffer *buffer);
|
||||||
|
@ -64,7 +64,7 @@ int copy_file(int outfd, int infd, long long size, unsigned long *crc32);
|
|||||||
char *copy_file_status_to_str(int status);
|
char *copy_file_status_to_str(int status);
|
||||||
void set_size_limit(long long new_bytes_limit, long long new_files_limit);
|
void set_size_limit(long long new_bytes_limit, long long new_files_limit);
|
||||||
void set_verbose(int value);
|
void set_verbose(int value);
|
||||||
int write_all(int fd, void *buf, int size);
|
int write_all(int fd, const void *buf, int size);
|
||||||
int read_all(int fd, void *buf, int size);
|
int read_all(int fd, void *buf, int size);
|
||||||
int copy_fd_all(int fdout, int fdin);
|
int copy_fd_all(int fdout, int fdin);
|
||||||
void set_nonblock(int fd);
|
void set_nonblock(int fd);
|
||||||
@ -73,6 +73,6 @@ void set_block(int fd);
|
|||||||
extern unsigned long Crc32_ComputeBuf( unsigned long inCrc32, const void *buf,
|
extern unsigned long Crc32_ComputeBuf( unsigned long inCrc32, const void *buf,
|
||||||
size_t bufLen );
|
size_t bufLen );
|
||||||
|
|
||||||
extern int do_unpack();
|
extern int do_unpack(void);
|
||||||
|
|
||||||
#endif /* _LIBQUBES_RPC_FILECOPY_H */
|
#endif /* _LIBQUBES_RPC_FILECOPY_H */
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
//#include "qrexec.h"
|
//#include "qrexec.h"
|
||||||
|
|
||||||
int get_server_socket(char *socket_address)
|
int get_server_socket(const char *socket_address)
|
||||||
{
|
{
|
||||||
struct sockaddr_un sockname;
|
struct sockaddr_un sockname;
|
||||||
int s;
|
int s;
|
||||||
|
@ -38,7 +38,7 @@ int read_all_with_crc(int fd, void *buf, int size) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_status_and_crc(int code, char *last_filename) {
|
void send_status_and_crc(int code, const char *last_filename) {
|
||||||
struct result_header hdr;
|
struct result_header hdr;
|
||||||
struct result_header_ext hdr_ext;
|
struct result_header_ext hdr_ext;
|
||||||
int saved_errno;
|
int saved_errno;
|
||||||
@ -58,7 +58,7 @@ void send_status_and_crc(int code, char *last_filename) {
|
|||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_exit(int code, char *last_filename)
|
void do_exit(int code, const char *last_filename)
|
||||||
{
|
{
|
||||||
close(0);
|
close(0);
|
||||||
send_status_and_crc(code, last_filename);
|
send_status_and_crc(code, last_filename);
|
||||||
@ -66,7 +66,7 @@ void do_exit(int code, char *last_filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void fix_times_and_perms(struct file_header *untrusted_hdr,
|
void fix_times_and_perms(struct file_header *untrusted_hdr,
|
||||||
char *untrusted_name)
|
const char *untrusted_name)
|
||||||
{
|
{
|
||||||
struct timeval times[2] =
|
struct timeval times[2] =
|
||||||
{ {untrusted_hdr->atime, untrusted_hdr->atime_nsec / 1000},
|
{ {untrusted_hdr->atime, untrusted_hdr->atime_nsec / 1000},
|
||||||
@ -82,7 +82,7 @@ void fix_times_and_perms(struct file_header *untrusted_hdr,
|
|||||||
|
|
||||||
|
|
||||||
void process_one_file_reg(struct file_header *untrusted_hdr,
|
void process_one_file_reg(struct file_header *untrusted_hdr,
|
||||||
char *untrusted_name)
|
const char *untrusted_name)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int fdout = open(untrusted_name, O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW, 0700); /* safe because of chroot */
|
int fdout = open(untrusted_name, O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW, 0700); /* safe because of chroot */
|
||||||
@ -105,7 +105,7 @@ void process_one_file_reg(struct file_header *untrusted_hdr,
|
|||||||
|
|
||||||
|
|
||||||
void process_one_file_dir(struct file_header *untrusted_hdr,
|
void process_one_file_dir(struct file_header *untrusted_hdr,
|
||||||
char *untrusted_name)
|
const char *untrusted_name)
|
||||||
{
|
{
|
||||||
// fix perms only when the directory is sent for the second time
|
// fix perms only when the directory is sent for the second time
|
||||||
// it allows to transfer r.x directory contents, as we create it rwx initially
|
// it allows to transfer r.x directory contents, as we create it rwx initially
|
||||||
@ -122,7 +122,7 @@ void process_one_file_dir(struct file_header *untrusted_hdr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void process_one_file_link(struct file_header *untrusted_hdr,
|
void process_one_file_link(struct file_header *untrusted_hdr,
|
||||||
char *untrusted_name)
|
const char *untrusted_name)
|
||||||
{
|
{
|
||||||
char untrusted_content[MAX_PATH_LENGTH];
|
char untrusted_content[MAX_PATH_LENGTH];
|
||||||
unsigned int filelen;
|
unsigned int filelen;
|
||||||
@ -161,7 +161,7 @@ void process_one_file(struct file_header *untrusted_hdr)
|
|||||||
fprintf(stderr, "%s\n", untrusted_namebuf);
|
fprintf(stderr, "%s\n", untrusted_namebuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_unpack()
|
int do_unpack(void)
|
||||||
{
|
{
|
||||||
struct file_header untrusted_hdr;
|
struct file_header untrusted_hdr;
|
||||||
total_bytes = total_files = 0;
|
total_bytes = total_files = 0;
|
||||||
|
@ -69,7 +69,7 @@ Write "len" bytes from "data" to "fd". If not all written, buffer the rest
|
|||||||
to "buffer", and notify the peer that the client "client_id" pipe is full via
|
to "buffer", and notify the peer that the client "client_id" pipe is full via
|
||||||
MSG_XOFF message.
|
MSG_XOFF message.
|
||||||
*/
|
*/
|
||||||
int write_stdin(int fd, int client_id, char *data, int len,
|
int write_stdin(int fd, int client_id, const char *data, int len,
|
||||||
struct buffer *buffer)
|
struct buffer *buffer)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user