Skip to content

Commit

Permalink
删除PipeFlag结构体
Browse files Browse the repository at this point in the history
  • Loading branch information
fslongjin committed Sep 12, 2023
1 parent 9cc40f2 commit 2ba7a9f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
14 changes: 3 additions & 11 deletions kernel/src/ipc/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@ use crate::{
};

use alloc::sync::{Arc, Weak};
bitflags! {
pub struct PipeFlag:u32 {
// 管道标志位
const NORMAL=0;// 0:默认行为,创建一个阻塞管道。与使用 pipe 函数创建的管道行为一致。
// 设为fcntl里面的定义的数,方便C里面调用
const O_NONBLOCK = 2048; // 创建一个非阻塞管道
const O_CLOEXEC = 524288; // 在执行 exec 调用时关闭管道文件描述符。
}
}

/// 我们设定pipe_buff的总大小为1024字节
const PIPE_BUFF_SIZE: usize = 1024;

Expand Down Expand Up @@ -57,7 +49,7 @@ impl LockedPipeInode {
metadata: Metadata {
dev_id: 0,
inode_id: generate_inode_id(),
size: 0,
size: PIPE_BUFF_SIZE as i64,
blk_size: 0,
blocks: 0,
atime: TimeSpec::default(),
Expand Down Expand Up @@ -95,7 +87,7 @@ impl IndexNode for LockedPipeInode {
// 加锁
let mut inode = self.0.lock();

//如果管道里面没有数据,则唤醒写端,
// 如果管道里面没有数据,则唤醒写端,
while inode.valid_cnt == 0 {
inode.write_wait_queue.wakeup(PROC_INTERRUPTIBLE.into());
// 如果为非阻塞管道,直接返回错误
Expand Down
1 change: 1 addition & 0 deletions user/apps/shell/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct built_in_cmd_t shell_cmds[] = {
{"free", shell_cmd_free},
{"help", shell_help},
{"pipe", shell_pipe_test},
{"pipe2", shell_pipe2_test},
{"kill", shell_cmd_kill},

};
Expand Down
3 changes: 2 additions & 1 deletion user/apps/shell/cmd_test.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once

#include "cmd.h"
int shell_pipe_test(int argc, char **argv);
int shell_pipe_test(int argc, char **argv);
int shell_pipe2_test(int argc, char **argv);

0 comments on commit 2ba7a9f

Please sign in to comment.