Mercurial > yaffs-ecoscentric-gpl
comparison direct/yaffsfs.c @ 119:e2900d249f26
Add hardlinks to yaffs direct
| author | charles <charles> |
|---|---|
| date | Wed, 08 Feb 2006 22:38:24 +0000 |
| parents | 07a42c94dda5 |
| children | 2b3096daff30 |
comparison
equal
deleted
inserted
replaced
| 118:045defda0c79 | 119:e2900d249f26 |
|---|---|
| 23 #ifndef NULL | 23 #ifndef NULL |
| 24 #define NULL ((void *)0) | 24 #define NULL ((void *)0) |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 | 27 |
| 28 const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.7 2005-10-07 03:48:50 charles Exp $"; | 28 const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.8 2006-02-08 22:38:24 charles Exp $"; |
| 29 | 29 |
| 30 // configurationList is the list of devices that are supported | 30 // configurationList is the list of devices that are supported |
| 31 static yaffsfs_DeviceConfiguration *yaffsfs_configurationList; | 31 static yaffsfs_DeviceConfiguration *yaffsfs_configurationList; |
| 32 | 32 |
| 33 | 33 |
| 1400 } | 1400 } |
| 1401 yaffsfs_Unlock(); | 1401 yaffsfs_Unlock(); |
| 1402 return retVal; | 1402 return retVal; |
| 1403 } | 1403 } |
| 1404 | 1404 |
| 1405 int yaffs_link(const char *oldpath, const char *newpath); | 1405 int yaffs_link(const char *oldpath, const char *newpath) |
| 1406 { | |
| 1407 // Creates a link called newpath to existing oldpath | |
| 1408 yaffs_Object *obj = NULL; | |
| 1409 yaffs_Object *target = NULL; | |
| 1410 int retVal; | |
| 1411 | |
| 1412 | |
| 1413 yaffsfs_Lock(); | |
| 1414 | |
| 1415 obj = yaffsfs_FindObject(NULL,oldpath,0); | |
| 1416 target = yaffsfs_FindObject(NULL,newpath,0); | |
| 1417 | |
| 1418 if(!obj) | |
| 1419 { | |
| 1420 yaffsfs_SetError(-ENOENT); | |
| 1421 retVal = -1; | |
| 1422 } | |
| 1423 else if(target) | |
| 1424 { | |
| 1425 yaffsfs_SetError(-EEXIST); | |
| 1426 retVal = -1; | |
| 1427 } | |
| 1428 else | |
| 1429 { | |
| 1430 yaffs_Object *newdir = NULL; | |
| 1431 yaffs_Object *link = NULL; | |
| 1432 | |
| 1433 char *newname; | |
| 1434 | |
| 1435 newdir = yaffsfs_FindDirectory(NULL,newpath,&newname,0); | |
| 1436 | |
| 1437 if(!newdir) | |
| 1438 { | |
| 1439 yaffsfs_SetError(-ENOTDIR); | |
| 1440 retVal = -1; | |
| 1441 } | |
| 1442 else if(newdir->myDev != obj->myDev) | |
| 1443 { | |
| 1444 yaffsfs_SetError(-EXDEV); | |
| 1445 retVal = -1; | |
| 1446 } | |
| 1447 if(newdir && strlen(newname) > 0) | |
| 1448 { | |
| 1449 link = yaffs_Link(newdir,newname,obj); | |
| 1450 if(link) | |
| 1451 retVal = 0; | |
| 1452 else | |
| 1453 { | |
| 1454 yaffsfs_SetError(-ENOSPC); | |
| 1455 retVal = -1; | |
| 1456 } | |
| 1457 | |
| 1458 } | |
| 1459 } | |
| 1460 yaffsfs_Unlock(); | |
| 1461 | |
| 1462 return retVal; | |
| 1463 } | |
| 1464 | |
| 1406 int yaffs_mknod(const char *pathname, mode_t mode, dev_t dev); | 1465 int yaffs_mknod(const char *pathname, mode_t mode, dev_t dev); |
| 1407 | 1466 |
| 1408 int yaffs_DumpDevStruct(const char *path) | 1467 int yaffs_DumpDevStruct(const char *path) |
| 1409 { | 1468 { |
| 1410 char *rest; | 1469 char *rest; |
