Skip to content

Conversation

@electricface
Copy link
Contributor

@electricface electricface commented Dec 16, 2025

  • Implement the combine_path_and_last function to combine a base
    path and the final component to form a complete path.
  • Implement the deepin_notify_rename_ro_fs_err function, which
    calls prepare_and_notify_fs_error to send the error notification.

Signed-off-by: electricface [email protected]

Summary by Sourcery

Implement path combination helper and extend read-only filesystem error notifications for rename operations.

New Features:

  • Add a helper to construct full paths from a base path and final component for error reporting.
  • Send read-only filesystem error notifications for failed rename operations including both source and target paths.

Enhancements:

  • Relax error logging for notification failures from error-level to debug-level to reduce log noise.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 16, 2025

Reviewer's Guide

Implements a new helper to construct full paths from a base path plus final component and wires it into Deepin’s filesystem error notification path for read-only rename failures, while slightly cleaning up attributes and logging behavior.

Sequence diagram for read-only rename error notification flow

sequenceDiagram
    actor Process
    participant VFS
    participant DeepinErrNotify
    participant UserspaceListener

    Process->>VFS: vfs_rename(old_dentry, new_dentry)
    VFS-->>VFS: Detect EROFS on target filesystem
    VFS->>DeepinErrNotify: deepin_notify_rename_ro_fs_err(old_last, new_last, old_path, new_path)

    DeepinErrNotify-->>DeepinErrNotify: Create deepin_path_last[2]
    DeepinErrNotify->>DeepinErrNotify: prepare_and_notify_fs_error(path_lasts, 2)
    DeepinErrNotify-->>UserspaceListener: Send filesystem error notification
    UserspaceListener-->>UserspaceListener: Handle rename EROFS error event

    DeepinErrNotify-->>VFS: Return from deepin_notify_rename_ro_fs_err
    VFS-->>Process: Return -EROFS from rename
Loading

Class diagram for Deepin error notification helpers

classDiagram
    class DeepinErrNotify {
        +int deepin_err_notify_should_send()
        +char* combine_path_and_last(char* buffer, const struct path* path, const char* last)
        +void deepin_check_and_notify_ro_fs_err(const struct deepin_path_last* path_last, int count)
        +void deepin_notify_rename_ro_fs_err(const struct qstr* old_last, const struct qstr* new_last, const struct path* old_path, const struct path* new_path)
        +int prepare_and_notify_fs_error(const struct deepin_path_last* path_lasts, int count)
    }

    class deepin_path_last {
        +struct path path
        +const char* last
    }

    class qstr {
        +const char* name
        +unsigned int len
    }

    class path {
        +struct vfsmount* mnt
        +struct dentry* dentry
    }

    DeepinErrNotify ..> deepin_path_last : uses
    DeepinErrNotify ..> qstr : uses
    DeepinErrNotify ..> path : uses
    DeepinErrNotify ..> d_absolute_path : calls
    DeepinErrNotify ..> prepare_and_notify_fs_error : calls
    DeepinErrNotify ..> pr_debug : logs
Loading

File-Level Changes

Change Details Files
Implement path combination helper for constructing absolute paths from a base path and final component.
  • Define combine_path_and_last to build an absolute path using d_absolute_path and append the final component into a PATH_MAX-sized caller-provided buffer.
  • Handle potential mid-buffer return from d_absolute_path by memmoving the base path to the start of the buffer before appending.
  • Guard against PATH_MAX overflow and avoid generating double slashes when the base path is root or already ends with a slash.
fs/deepin_err_notify.c
Enhance and wire Deepin read-only filesystem error notifications for rename operations, and adjust related logging/attributes.
  • Introduce deepin_notify_rename_ro_fs_err to populate a deepin_path_last array for old and new rename targets and call prepare_and_notify_fs_error with both paths.
  • Change deepin_check_and_notify_ro_fs_err to log userspace notification failures at debug level instead of error level.
  • Remove the unused DEEPIN_ERR_NOTIFY_ATTR_FUNC_NAME attribute constant and include linux/stat.h for needed stat-related definitions.
fs/deepin_err_notify.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link

Hi @electricface. Thanks for your PR.

I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • In combine_path_and_last(), the memmove() call should copy base_len + 1 bytes to include the terminating NUL from d_absolute_path(), otherwise the resulting string can be left unterminated when base_path != buffer.
  • deepin_notify_rename_ro_fs_err() passes old_last->name/new_last->name as C strings, but struct qstr::name is not guaranteed to be NUL-terminated; consider using qstr->len or copying into a temporary NUL-terminated buffer before passing to prepare_and_notify_fs_error().
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In combine_path_and_last(), the memmove() call should copy base_len + 1 bytes to include the terminating NUL from d_absolute_path(), otherwise the resulting string can be left unterminated when base_path != buffer.
- deepin_notify_rename_ro_fs_err() passes old_last->name/new_last->name as C strings, but struct qstr::name is not guaranteed to be NUL-terminated; consider using qstr->len or copying into a temporary NUL-terminated buffer before passing to prepare_and_notify_fs_error().

## Individual Comments

### Comment 1
<location> `fs/deepin_err_notify.c:176-178` </location>
<code_context>
+	 * not the start. We need the path at the beginning so we can
+	 * append "/" + last to it.
+	 */
+	if (base_path != buffer)
+		memmove(buffer, base_path, base_len);
+
+	/* Avoid appending an extra "/" after root directory "/" which would
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Copy the terminating null byte in memmove for better robustness.

`memmove(buffer, base_path, base_len);` omits the terminating `\0`. While current concatenation always overwrites the end of the base string so this is safe today, copying `base_len + 1` preserves the invariant that `buffer` is a valid C string immediately after the move and reduces risk from future refactors or early returns.

```c
if (base_path != buffer)
	memmove(buffer, base_path, base_len + 1);
```

```suggestion
	 */
	if (base_path != buffer)
		memmove(buffer, base_path, base_len + 1);
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dongert
Once this PR has been reviewed and has the lgtm label, please assign avenger-285714 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

improve read-only error notification for renaming

- Implement the combine_path_and_last function to combine a base
path and the final component to form a complete path.
- Implement the deepin_notify_rename_ro_fs_err function, which
calls prepare_and_notify_fs_error to send the error notification.

Signed-off-by: electricface <[email protected]>
@dongert dongert merged commit 5628597 into deepin-community:linux-6.6.y Dec 17, 2025
10 of 11 checks passed
@electricface electricface deleted the swt/err-notify-p5 branch December 17, 2025 02:14
@Avenger-285714 Avenger-285714 self-requested a review December 17, 2025 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants