Skip to content

Commit a5a0d02

Browse files
committed
......
1 parent 1908043 commit a5a0d02

35 files changed

+904
-517
lines changed

代码/4540.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//initlsp

代码/Ab_dir.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#include"header.h"
1+
#include "header.h"
22
//显示绝对目录.
3-
void Ab_dir() {
3+
void Ab_dir()
4+
{
45
for (int i = 0; i < dir_pointer; i++)
56
printf("%s/", ab_dir[i]);
67
printf("\n");

代码/Chgrp.cpp

+24-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#include"header.h"
1+
#include "header.h"
22
//改变文件所属组.
3-
void Chgrp(char* filename) {
3+
void Chgrp(char *filename)
4+
{
45
printf("0=文件,1=目录,请选择:");
56
int tt;
67
scanf("%d", &tt);
@@ -10,8 +11,9 @@ void Chgrp(char* filename) {
1011
return;
1112
}
1213
int pos_in_directory = -1;
13-
inode* tmp_file_inode = new inode;
14-
do {
14+
inode *tmp_file_inode = new inode;
15+
do
16+
{
1517
pos_in_directory++;
1618
for (; pos_in_directory < DIRECTORY_NUM; pos_in_directory++)
1719
{
@@ -29,34 +31,42 @@ void Chgrp(char* filename) {
2931
fseek(fd, INODE_START + tmp_file_ino * INODE_SIZE, SEEK_SET);
3032
fread(tmp_file_inode, sizeof(inode), 1, fd);
3133
} while (tmp_file_inode->di_mode == tt);
32-
34+
3335
if (userID == tmp_file_inode->di_uid)
3436
{
35-
if (!(tmp_file_inode->permission & OWN_E)) {
37+
if (!(tmp_file_inode->permission & OWN_E))
38+
{
3639
printf("权限不够.\n");
3740
return;
3841
}
3942
}
40-
else if (users.groupID[userID] == tmp_file_inode->di_grp) {
41-
if (!(tmp_file_inode->permission & GRP_E)) {
43+
else if (users.groupID[userID] == tmp_file_inode->di_grp)
44+
{
45+
if (!(tmp_file_inode->permission & GRP_E))
46+
{
4247
printf("权限不够.\n");
4348
return;
4449
}
4550
}
46-
else {
47-
if (!(tmp_file_inode->permission & ELSE_E)) {
51+
else
52+
{
53+
if (!(tmp_file_inode->permission & ELSE_E))
54+
{
4855
printf("权限不够.\n");
4956
return;
5057
}
5158
}
52-
59+
5360
printf("请输入组号:");
5461
int ttt, i;
5562
scanf("%d", &ttt);
56-
for (i = 0; i < ACCOUNT_NUM; i++) {
57-
if (users.groupID[i] == ttt) break;
63+
for (i = 0; i < ACCOUNT_NUM; i++)
64+
{
65+
if (users.groupID[i] == ttt)
66+
break;
5867
}
59-
if (i == ACCOUNT_NUM) {
68+
if (i == ACCOUNT_NUM)
69+
{
6070
printf("用户错误!\n");
6171
return;
6272
}

代码/Chmod.cpp

+23-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#include"header.h"
1+
#include "header.h"
22
//修改文件权限
3-
void Chmod(char* filename) {
3+
void Chmod(char *filename)
4+
{
45
printf("0=文件,1=目录,请输入:");
56
int tt;
67
scanf("%d", &tt);
@@ -9,11 +10,12 @@ void Chmod(char* filename) {
910
printf("不合法.\n");
1011
return;
1112
}
12-
13+
1314
//1. 检查是否存在.
1415
int pos_in_directory = -1;
15-
inode* tmp_file_inode = new inode;
16-
do {
16+
inode *tmp_file_inode = new inode;
17+
do
18+
{
1719
pos_in_directory++;
1820
for (; pos_in_directory < DIRECTORY_NUM; pos_in_directory++)
1921
{
@@ -27,42 +29,49 @@ void Chmod(char* filename) {
2729
printf("没有找到.\n");
2830
return;
2931
}
30-
32+
3133
//2. 检查是否存在目录.
3234
int tmp_file_ino = currentDirectory.inodeID[pos_in_directory];
3335
fseek(fd, INODE_START + tmp_file_ino * INODE_SIZE, SEEK_SET);
3436
fread(tmp_file_inode, sizeof(inode), 1, fd);
3537
} while (tmp_file_inode->di_mode == tt);
36-
38+
3739
printf("请输入 0&1 串给予权限\n");
3840
printf("格式: rwerwerwe\n");
3941
char str[10];
4042
scanf("%s", &str);
4143
if (userID == tmp_file_inode->di_uid)
4244
{
43-
if (!(tmp_file_inode->permission & OWN_E)) {
45+
if (!(tmp_file_inode->permission & OWN_E))
46+
{
4447
printf("权限不够.\n");
4548
return;
4649
}
4750
}
48-
else if (users.groupID[userID] == tmp_file_inode->di_grp) {
49-
if (!(tmp_file_inode->permission & GRP_E)) {
51+
else if (users.groupID[userID] == tmp_file_inode->di_grp)
52+
{
53+
if (!(tmp_file_inode->permission & GRP_E))
54+
{
5055
printf("权限不够.\n");
5156
return;
5257
}
5358
}
54-
else {
55-
if (!(tmp_file_inode->permission & ELSE_E)) {
59+
else
60+
{
61+
if (!(tmp_file_inode->permission & ELSE_E))
62+
{
5663
printf("权限不够.\n");
5764
return;
5865
}
5966
}
6067
int temp = 0;
61-
for (int i = 0; i < 8; i++) {
68+
for (int i = 0; i < 8; i++)
69+
{
6270
if (str[i] == '1')
6371
temp += 1 << (8 - i);
6472
}
65-
if (str[8] == '1') temp += 1;
73+
if (str[8] == '1')
74+
temp += 1;
6675
tmp_file_inode->permission = temp;
6776
fseek(fd, INODE_START + tmp_file_inode->i_ino * INODE_SIZE, SEEK_SET);
6877
fwrite(tmp_file_inode, sizeof(inode), 1, fd);

0 commit comments

Comments
 (0)