7 #include<Diverge/DrFS.h>
8 #include<Diverge/kstdio.h>
10 #include<Diverge/diverge.h>
11 #include<Diverge/BitMap.h>
12 #include<Diverge/dksh.h>
14 extern struct fnode *cdir;
15 extern struct DrFS_Prefix* drfs;
16 extern unsigned long map[64];
18 /*セクタのクリーンアップ 引数:セクタのアドレス*/
19 void SectorCleanUp(unsigned int sector)
21 FSDirPointer fsd=(FSDirPointer)sector;
29 unsigned int SearchObjectFromCDir(char* name, char mode, bool *error)
33 FSDirPointer dp=(FSDirPointer)cdir->tnp;
38 node=(struct fnode*)dp[C];
39 if(strcmp(node->name,name)==0){
40 struct faright right=CheckObjectRight(node);
55 /*正常->作成したオブジェクトのfnodeポインタ 異常->NULL & *error==true*/
56 struct fnode* MakeObject(char* name, unsigned short ar, unsigned int uid, unsigned int gid, unsigned int pid, bool *error)
59 struct fnode* node=(struct fnode*)SearchSectorPysicalMemory(error);
60 if(*error==true)return NULL;
61 SectorCleanUp((unsigned int)node);
64 unsigned int sector=SearchSectorPysicalMemory(error);
65 if(*error==true)return NULL;
66 SectorCleanUp(sector);
68 time_t timer=time(NULL);
70 strcpy(node->name,name);
75 node->id=(unsigned int)node;
83 struct fnode* parent=(struct fnode*)pid;
84 FSDirPointer sec=(FSDirPointer)parent->tnp;
98 if(*error==true)return NULL;
100 /*セクタ段数が0じゃない時の開いているセクタポインタを探すロジック、あとで実装する。*/
107 unsigned int SectorSearch(bool *error)
109 unsigned int C,bit=0xffffffff;
113 bit=SearchEmptyBit(&map[C]);
122 ReserveBit(&map[C], bit);
126 struct faright CheckObjectRight(const struct fnode* node)
128 struct faright right;
129 unsigned short ar=node->attribute;
131 struct tm* temp=localtime(&node->create);
132 right.create_time=*temp;
134 temp=localtime(&node->rewrite);
135 right.rewrite_time=*temp;
137 temp=localtime(&node->access);
138 right.access_time=*temp;
140 if((ar & 0x8000)==0){
146 if((ar & 0x4000)!=0){
152 if((ar & 0x2000)!=0){
158 if((ar & 0x1000)!=0){
164 if((ar & 0xc00)==0xc00){
166 }else if((ar & 0xc00)==0x800){
168 }else if((ar & 0xc00)==0x400){
174 if((ar & 0x300)==0x300){
176 }else if((ar & 0x300)==0x200){
178 }else if((ar & 0x300)==0x100){
184 if((ar & 0xc0)==0xc0){
185 right.others_right=3;
186 }else if((ar & 0xc0)==0x80){
187 right.others_right=2;
188 }else if((ar & 0xc0)==0x40){
189 right.others_right=1;
191 right.others_right=0;
194 if(node->id==cdir->id){
196 }else if(node->id==cdir->pid){
214 right.gid=0xffffffff;
220 unsigned int SearchSectorPysicalMemory(bool* error)
223 bit=SectorSearch(error);
224 if(*error==true)return NULL;
225 bit=(drfs->sector_size*bit)+FS_START_ADDR+1;
229 void PrintFileList(struct faright right, struct fnode* node, int mode)
241 kprintf("%s\n",node->name);
277 switch(right.user_right){
294 switch(right.group_right){
311 switch(right.others_right){
330 kputs(" RootGroup ");
333 kputs(" AdminGroup ");
336 kputs(" UserGroup ");
354 kprintf(" %d/%d/%d %d:%d:%d %dB",right.rewrite_time.tm_year+1970, right.rewrite_time.tm_mon, right.rewrite_time.tm_mday, right.rewrite_time.tm_hour, right.rewrite_time.tm_min, right.rewrite_time.tm_sec, node->fsize);
363 kprintf(" %s\n",node->name);