本文整理汇总了C++中os_close_file函数的典型用法代码示例。如果您正苦于以下问题:C++ os_close_file函数的具体用法?C++ os_close_file怎么用?C++ os_close_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了os_close_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slirp_close
static void slirp_close(int fd, void *data)
{
struct slirp_data *pri = data;
int status,err;
os_close_file(fd);
os_close_file(pri->slave);
pri->slave = -1;
if(pri->pid<1) {
printk("slirp_close: no child process to shut down\n");
return;
}
#if 0
if(kill(pri->pid, SIGHUP)<0) {
printk("slirp_close: sending hangup to %d failed (%d)\n",
pri->pid, errno);
}
#endif
CATCH_EINTR(err = waitpid(pri->pid, &status, WNOHANG));
if(err < 0) {
printk("slirp_close: waitpid returned %d\n", errno);
return;
}
if(err == 0) {
printk("slirp_close: process %d has not exited\n", pri->pid);
return;
}
pri->pid = -1;
}
示例2: os_process_pc
unsigned long os_process_pc(int pid)
{
char proc_stat[STAT_PATH_LEN], buf[256];
unsigned long pc;
int fd, err;
sprintf(proc_stat, "/proc/%d/stat", pid);
fd = os_open_file(proc_stat, of_read(OPENFLAGS()), 0);
if(fd < 0){
printk("os_process_pc - couldn't open '%s', err = %d\n",
proc_stat, -fd);
return(ARBITRARY_ADDR);
}
err = os_read_file(fd, buf, sizeof(buf));
if(err < 0){
printk("os_process_pc - couldn't read '%s', err = %d\n",
proc_stat, -err);
os_close_file(fd);
return(ARBITRARY_ADDR);
}
os_close_file(fd);
pc = ARBITRARY_ADDR;
if(sscanf(buf, "%*d " COMM_SCANF " %*c %*d %*d %*d %*d %*d %*d %*d "
"%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d "
"%*d %*d %*d %*d %*d %lu", &pc) != 1){
printk("os_process_pc - couldn't find pc in '%s'\n", buf);
}
return(pc);
}
示例3: slirp_open
static int slirp_open(void *data)
{
struct slirp_data *pri = data;
int fds[2], pid, err;
err = os_pipe(fds, 1, 1);
if(err)
return(err);
err = slirp_tramp(pri->argw.argv, fds[1]);
if(err < 0){
printk("slirp_tramp failed - errno = %d\n", -err);
goto out;
}
pid = err;
pri->slave = fds[1];
pri->slip.pos = 0;
pri->slip.esc = 0;
pri->pid = err;
return(fds[0]);
out:
os_close_file(fds[0]);
os_close_file(fds[1]);
return err;
}
示例4: etap_pre_exec
static void etap_pre_exec(void *arg)
{
struct etap_pre_exec_data *data = arg;
dup2(data->control_remote, 1);
os_close_file(data->data_me);
os_close_file(data->control_me);
}
示例5: daemon_remove
static void daemon_remove(void *data)
{
struct daemon_data *pri = data;
os_close_file(pri->fd);
os_close_file(pri->control);
kfree(pri->data_addr);
kfree(pri->ctl_addr);
kfree(pri->local_addr);
}
示例6: slip_tramp
static int slip_tramp(char **argv, int fd)
{
struct slip_pre_exec_data pe_data;
char *output;
int status, pid, fds[2], err, output_len;
err = os_pipe(fds, 1, 0);
if(err < 0){
printk("slip_tramp : pipe failed, err = %d\n", -err);
goto out;
}
err = 0;
pe_data.stdin = fd;
pe_data.stdout = fds[1];
pe_data.close_me = fds[0];
err = run_helper(slip_pre_exec, &pe_data, argv, NULL);
if(err < 0)
goto out_close;
pid = err;
output_len = page_size();
output = um_kmalloc(output_len);
if(output == NULL){
printk("slip_tramp : failed to allocate output buffer\n");
os_kill_process(pid, 1);
err = -ENOMEM;
goto out_free;
}
os_close_file(fds[1]);
read_output(fds[0], output, output_len);
printk("%s", output);
CATCH_EINTR(err = waitpid(pid, &status, 0));
if(err < 0)
err = errno;
else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)){
printk("'%s' didn't exit with status 0\n", argv[0]);
err = -EINVAL;
}
else err = 0;
os_close_file(fds[0]);
out_free:
kfree(output);
return err;
out_close:
os_close_file(fds[0]);
os_close_file(fds[1]);
out:
return err;
}
示例7: pre_exec
static void pre_exec(void *d)
{
struct dog_data *data = d;
dup2(data->stdin, 0);
dup2(data->stdout, 1);
dup2(data->stdout, 2);
os_close_file(data->stdin);
os_close_file(data->stdout);
os_close_file(data->close_me[0]);
os_close_file(data->close_me[1]);
}
示例8: etap_close
static void etap_close(int fd, void *data)
{
struct ethertap_data *pri = data;
iter_addresses(pri->dev, etap_close_addr, &pri->control_fd);
os_close_file(fd);
os_shutdown_socket(pri->data_fd, 1, 1);
os_close_file(pri->data_fd);
pri->data_fd = -1;
os_close_file(pri->control_fd);
pri->control_fd = -1;
}
示例9: os_process_parent
int os_process_parent(int pid)
{
char stat[STAT_PATH_LEN];
char data[256];
int parent, n, fd;
if(pid == -1) return(-1);
snprintf(stat, sizeof(stat), "/proc/%d/stat", pid);
fd = os_open_file(stat, of_read(OPENFLAGS()), 0);
if(fd < 0){
printk("Couldn't open '%s', err = %d\n", stat, -fd);
return(FAILURE_PID);
}
n = os_read_file(fd, data, sizeof(data));
os_close_file(fd);
if(n < 0){
printk("Couldn't read '%s', err = %d\n", stat, -n);
return(FAILURE_PID);
}
parent = FAILURE_PID;
n = sscanf(data, "%*d " COMM_SCANF " %*c %d", &parent);
if(n != 1)
printk("Failed to scan '%s'\n", data);
return(parent);
}
示例10: change_pre_exec
static void change_pre_exec(void *arg)
{
struct change_pre_exec_data *data = arg;
os_close_file(data->close_me);
dup2(data->stdout, 1);
}
示例11: file_close
void file_close(file_t* file)
{
u32 i;
cache_entry_t* entry;
/* Unmap cached pages. */
for (i = 0; i < CACHE_SIZE; i++) {
entry = &file->cache.entries[i];
if (entry->ptr != NULL) {
if (entry->ref > 0) {
fprintf(stderr, "file_close: unmapping used page %u (%p)\n",
entry->pageid, entry->ptr);
}
DPRINT("file_close: unmapping cached page %u (%p)\n",
entry->pageid, entry->ptr);
if (os_put_page(file->handle, entry->ptr) == 0)
file->stats.unmapped++;
}
}
#if !defined(NSTATS)
file_dump_info(file);
#endif /* !defined(NSTATS) */
/* Unmap the header page. */
os_put_page(file->handle, file->header);
/* Close the file. */
os_close_file(file->handle);
/* Free the file object. */
memset(file, 0, sizeof(file_t));
free(file);
}
示例12: destroy_context
void destroy_context(struct mm_struct *mm)
{
struct mm_context *mmu = &mm->context;
if (proc_mm)
os_close_file(mmu->id.u.mm_fd);
else {
/*
* If init_new_context wasn't called, this will be
* zero, resulting in a kill(0), which will result in the
* whole UML suddenly dying. Also, cover negative and
* 1 cases, since they shouldn't happen either.
*/
if (mmu->id.u.pid < 2) {
printk(KERN_ERR "corrupt mm_context - pid = %d\n",
mmu->id.u.pid);
return;
}
os_kill_ptraced_process(mmu->id.u.pid, 1);
}
if (skas_needs_stub)
free_page(mmu->id.stack);
free_ldt(mmu);
}
示例13: file_removed
static int file_removed(struct dentry *dentry, const char *file)
{
char *host_file;
int extra, fd;
extra = 0;
if(file != NULL) extra += strlen(file) + 1;
host_file = dentry_name(dentry, extra + strlen("/remove"));
if(host_file == NULL){
printk("file_removed : allocation failed\n");
return(-ENOMEM);
}
if(file != NULL){
strcat(host_file, "/");
strcat(host_file, file);
}
strcat(host_file, "/remove");
fd = os_open_file(host_file, of_read(OPENFLAGS()), 0);
kfree(host_file);
if(fd >= 0){
os_close_file(fd);
return(1);
}
return(0);
}
示例14: os_process_pc
unsigned long os_process_pc(int pid)
{
char proc_stat[STAT_PATH_LEN], buf[256];
unsigned long pc = ARBITRARY_ADDR;
int fd, err;
sprintf(proc_stat, "/proc/%d/stat", pid);
fd = open(proc_stat, O_RDONLY, 0);
if (fd < 0) {
printk(UM_KERN_ERR "os_process_pc - couldn't open '%s', "
"errno = %d\n", proc_stat, errno);
goto out;
}
CATCH_EINTR(err = read(fd, buf, sizeof(buf)));
if (err < 0) {
printk(UM_KERN_ERR "os_process_pc - couldn't read '%s', "
"err = %d\n", proc_stat, errno);
goto out_close;
}
os_close_file(fd);
pc = ARBITRARY_ADDR;
if (sscanf(buf, "%*d " COMM_SCANF " %*c %*d %*d %*d %*d %*d %*d %*d "
"%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d "
"%*d %*d %*d %*d %*d %lu", &pc) != 1)
printk(UM_KERN_ERR "os_process_pc - couldn't find pc in '%s'\n",
buf);
out_close:
close(fd);
out:
return pc;
}
示例15: tuntap_open_tramp
static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
char *buffer, int buffer_len, int *used_out)
{
struct tuntap_pre_exec_data data;
char version_buf[sizeof("nnnnn\0")];
char *argv[] = { "uml_net", version_buf, "tuntap", "up", gate,
NULL };
char buf[CMSG_SPACE(sizeof(*fd_out))];
struct msghdr msg;
struct cmsghdr *cmsg;
struct iovec iov;
int pid, n, err;
sprintf(version_buf, "%d", UML_NET_VERSION);
data.stdout = remote;
data.close_me = me;
pid = run_helper(tuntap_pre_exec, &data, argv, NULL);
if(pid < 0) return(-pid);
os_close_file(remote);
msg.msg_name = NULL;
msg.msg_namelen = 0;
if(buffer != NULL){
iov = ((struct iovec) { buffer, buffer_len });