You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.1 KiB
50 lines
1.1 KiB
long sys_getcwd(char*buf,size_t size)
|
|
{
|
|
struct buffer_head *bh;
|
|
struct m_inode*n_inode,*f_inode;
|
|
struct dir_entry*dir;
|
|
char *tmp,*b;
|
|
int k,i;
|
|
tmp=(char*)malloc(256);
|
|
b=(char*)malloc(256);
|
|
n_inode=current->pwd;
|
|
if(n_inode==current->root)strcpy(tmp,"/");
|
|
bh=bread(n_inode->i_dev,n_inode->i_zone[0]);
|
|
while(n_inode!=current->root)
|
|
{
|
|
dir=(struct dir_entry*)(bh->b_data+sizeof(struct dir_entry));
|
|
f_inode=iget(n_inode->i_dev,dir->inode);
|
|
brelse(bh);
|
|
bh=bread(f_inode->i_dev,f_inode->i_zone[0]);
|
|
k=0;
|
|
while(k<f_inode->i_size)
|
|
{
|
|
dir=(struct dir_entry*)(bh->b_data+k);
|
|
if(dir->inode==n_inode->i_num)break;
|
|
k+=sizeof(struct dir_entry);
|
|
}
|
|
strcpy(b,"/");
|
|
strcat(b,dir->name);
|
|
strcat(b,tmp);
|
|
strcpy(tmp,b);
|
|
n_inode=f_inode;
|
|
}
|
|
brelse(bh);
|
|
if(strlen(tmp)>size)return NULL;
|
|
for(i=0;i<256;i++)
|
|
put_fs_byte(tmp[i],buf+i);
|
|
return (long)buf;
|
|
}
|
|
|
|
|
|
|
|
|
|
int sys_sleep(unsigned int count)
|
|
{
|
|
int a=jiffies;
|
|
sys_signal(SIGALRM,SIG_IGN);
|
|
sys_alarm(count);
|
|
sys_pause();
|
|
if((jiffies-a)/100==count)return 0;
|
|
else return -1;
|
|
} |