forked from SpongebBob/HomeworkSchedule
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stat.c
executable file
·52 lines (44 loc) · 914 Bytes
/
stat.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ipc.h>
#include <fcntl.h>
#include "job.h"
#define DEBUG
/*
* 命令语法格式
* stat
*/
void usage()
{
printf("Usage: stat\n");
}
int main(int argc,char *argv[])
{
struct jobcmd statcmd;
int fd;
if(argc!=1)
{
usage();
return 1;
}
statcmd.type=STAT;
statcmd.defpri=0;
statcmd.owner=getuid();
statcmd.argnum=0;
#ifdef DEBUG
//---lp--debug task 5--
printf("statcmd cmdtype\t%d (-1 means ENQ, -2 means DEQ, -3 means STAT)\n"
"statcmd owner\t%d\n",
statcmd.type,statcmd.owner);
#endif
//打开fifo文件
if((fd=open("/tmp/server",O_WRONLY))<0)
error_sys("stat open fifo failed");
//通过相关fifo写入数据的方式传给job.c命令
if(write(fd,&statcmd,DATALEN)<0)
error_sys("stat write failed");
close(fd);
return 0;
}