Skip to content

Commit 124f951

Browse files
committed
update symlink
1 parent 695effc commit 124f951

File tree

3 files changed

+107
-2
lines changed

3 files changed

+107
-2
lines changed

agfs-sdk/go/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ err := client.Chmod("/script.sh", 0755)
114114

115115
// Delete a file
116116
err := client.Remove("/archive/oldfile.txt")
117+
118+
// Create symbolic link
119+
err := client.Symlink("/data/original", "/shortcuts/link")
120+
121+
// Read symbolic link target
122+
target, err := client.Readlink("/shortcuts/link")
123+
fmt.Printf("Link points to: %s\n", target)
117124
```
118125

119126
### Directory Operations
@@ -167,6 +174,38 @@ resp, err := client.Digest("/iso/installer.iso", "xxh3")
167174
fmt.Printf("Digest: %s\n", resp.Digest)
168175
```
169176

177+
### Symbolic Links
178+
179+
AGFS supports virtual symbolic links that work across all mounted filesystems without requiring backend support.
180+
181+
```go
182+
// Create a symbolic link
183+
err := client.Symlink("/s3fs/bucket/data", "/shortcuts/s3data")
184+
if err != nil {
185+
log.Fatalf("Failed to create symlink: %v", err)
186+
}
187+
188+
// Read the target of a symlink
189+
target, err := client.Readlink("/shortcuts/s3data")
190+
if err != nil {
191+
log.Fatalf("Failed to read symlink: %v", err)
192+
}
193+
fmt.Printf("Symlink points to: %s\n", target)
194+
195+
// Symlinks work transparently with other operations
196+
data, err := client.Read("/shortcuts/s3data/file.txt", 0, -1)
197+
198+
// Remove a symlink (does not affect the target)
199+
err = client.Remove("/shortcuts/s3data")
200+
```
201+
202+
**Features:**
203+
- Virtual symlinks at the AGFS layer (no backend support required)
204+
- Support for relative and absolute paths
205+
- Cross-mount symlinks (link across different filesystems)
206+
- Symlink chain resolution with cycle detection
207+
- Transparent access through symlinks for read/write operations
208+
170209
## Testing
171210

172211
To run the SDK tests:

agfs-sdk/python/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,38 @@ result = client.digest("/path/to/file.txt", algorithm="xxh3")
142142
print(f"Hash: {result['digest']}")
143143
```
144144

145+
### Symbolic Links
146+
147+
AGFS supports virtual symbolic links that work across all mounted filesystems without requiring backend support.
148+
149+
```python
150+
# Create a symbolic link
151+
client.symlink("/s3fs/bucket/data", "/shortcuts/s3data")
152+
153+
# Read the target of a symlink
154+
target = client.readlink("/shortcuts/s3data")
155+
print(f"Symlink points to: {target}")
156+
157+
# Symlinks work transparently with other operations
158+
content = client.cat("/shortcuts/s3data/file.txt")
159+
160+
# Remove a symlink (does not affect the target)
161+
client.rm("/shortcuts/s3data")
162+
163+
# Create relative path symlinks
164+
client.symlink("../config/app.conf", "/local/tmp/local_config")
165+
166+
# Cross-mount symlinks work
167+
client.symlink("/memfs/cache", "/local/shortcuts/cache")
168+
```
169+
170+
**Features:**
171+
- Virtual symlinks at the AGFS layer (no backend support required)
172+
- Support for relative and absolute paths
173+
- Cross-mount symlinks (link across different filesystems)
174+
- Symlink chain resolution with cycle detection
175+
- Transparent access through symlinks for read/write operations
176+
145177
## API Reference
146178

147179
### AGFSClient
@@ -160,6 +192,8 @@ print(f"Hash: {result['digest']}")
160192
- `chmod(path, mode)` - Change file permissions
161193
- `touch(path)` - Update file timestamp
162194
- `digest(path, algorithm="xxh3")` - Calculate file hash
195+
- `symlink(target, link_path)` - Create symbolic link
196+
- `readlink(link_path)` - Read symbolic link target
163197

164198
#### Directory Operations
165199
- `mkdir(path, mode="755")` - Create directory

agfs-shell/README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ agfs-shell is a lightweight, educational shell that demonstrates Unix pipeline c
6565
- **Comments**: `#` and `//` style comments
6666

6767
### Built-in Commands (42+)
68-
- **File Operations**: cd, pwd, ls, tree, cat, mkdir, touch, rm, mv, stat, cp, upload, download
68+
- **File Operations**: cd, pwd, ls, tree, cat, mkdir, touch, rm, mv, stat, cp, ln, upload, download
6969
- **Text Processing**: echo, grep, jq, wc, head, tail, tee, sort, uniq, tr, rev, cut
7070
- **Path Utilities**: basename, dirname
7171
- **Variables**: export, env, unset, local
@@ -592,13 +592,16 @@ pwd # /local/mydir
592592
```
593593

594594
#### ls [-l] [path]
595-
List directory contents.
595+
List directory contents. Symlinks are displayed in cyan color with arrow notation.
596596

597597
```bash
598598
ls # List current directory
599599
ls /local # List specific directory
600600
ls -l # Long format with details
601601
ls -l /local/*.txt # List with glob pattern
602+
603+
# Symlink display example:
604+
# aws2 -> /s3fs/aws # Symlinks shown with arrow and target
602605
```
603606

604607
#### tree [OPTIONS] [path]
@@ -694,6 +697,35 @@ download /local/tmp/data.json ~/Downloads/
694697
download -r /local/tmp/logs ~/backup/logs/
695698
```
696699

700+
#### ln [-s] target link_path
701+
Create symbolic links. The `-s` flag is required (hard links are not supported).
702+
703+
```bash
704+
# Create a symbolic link
705+
ln -s /s3fs/aws /s3fs/backup
706+
707+
# Create a symlink to a directory
708+
ln -s /local/data /shortcuts/mydata
709+
710+
# Relative path symlinks
711+
cd /local/tmp
712+
ln -s ../config/app.conf local_config
713+
714+
# Cross-mount symlinks work
715+
ln -s /memfs/cache /local/shortcuts/cache
716+
717+
# Symlinks appear in ls with cyan color and arrow notation
718+
ls -l /shortcuts
719+
# mydata -> /local/data
720+
```
721+
722+
**Features:**
723+
- Virtual symlinks at the AGFS layer (no backend support required)
724+
- Support for relative and absolute paths
725+
- Cross-mount symlinks (link across different filesystems)
726+
- Symlink chain resolution with cycle detection
727+
- Symlinks work with `cd`, `ls`, `cat`, and other file operations
728+
697729
### Text Processing
698730

699731
#### echo [args...]

0 commit comments

Comments
 (0)